Commit d67106ab authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Ajout tests pour meilleure couverture.

parent 81399c57
......@@ -45,6 +45,22 @@ class LdapDbTest extends PHPUnit_Framework_TestCase
->setServiceManager($this->serviceManager);
}
public function testServiceManagerIsNullByDefault()
{
$storage = new LdapDb();
$this->assertNull($storage->getServiceManager());
}
public function testCanRetrieveDefaultOptionsFromServiceManager()
{
$this->serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager', array('get'));
$this->serviceManager->expects($this->once())
->method('get')
->will($this->returnValue(new \UnicaenAuth\Options\ModuleOptions()));
$this->storage->setServiceManager($this->serviceManager);
$this->storage->getOptions();
}
public function testInnerStoragesAreNullByDefault()
{
$storage = new LdapDb();
......@@ -52,16 +68,21 @@ class LdapDbTest extends PHPUnit_Framework_TestCase
$this->assertNull($storage->getLdapStorage());
}
public function testStorageIsEmptyOnlyIfInnerStoragesAreBothEmpty()
public function testStorageIsEmptyOnlyIfBothInnerStoragesAreEmpty()
{
$this->storage->getDbStorage()->write('content');
$this->storage->getLdapStorage()->write('content');
$this->assertFalse($this->storage->isEmpty());
$this->storage->getDbStorage()->clear();
$this->storage->clear();
$this->storage->getLdapStorage()->write('content');
$this->assertFalse($this->storage->isEmpty());
$this->storage->getLdapStorage()->clear();
$this->storage->clear();
$this->storage->getDbStorage()->write('content');
$this->assertFalse($this->storage->isEmpty());
$this->storage->clear();
$this->assertTrue($this->storage->isEmpty());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment