summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Coevoet <stof@notk.org>2012-10-06 15:38:50 +0200
committerChristophe Coevoet <stof@notk.org>2012-10-06 15:38:50 +0200
commit6096a82c77f35d1e420e67d55b6da139a6453664 (patch)
tree2b0e06189380c050397e2557033fefc44bce59d9
parent77202d4c3d20188f72ac4a53893d52201a360e07 (diff)
Added some more tests
-rw-r--r--test/Bdu/Tests/ApiTest.php23
-rw-r--r--test/Bdu/Tests/ConfigurationTest.php23
2 files changed, 45 insertions, 1 deletions
diff --git a/test/Bdu/Tests/ApiTest.php b/test/Bdu/Tests/ApiTest.php
index 8b625a0..e14f330 100644
--- a/test/Bdu/Tests/ApiTest.php
+++ b/test/Bdu/Tests/ApiTest.php
@@ -16,7 +16,7 @@
* http://www.gnu.org/copyleft/gpl.html *
***********************************************************************/
-class Bdu_Tests_ApiTest extends PHPUnit_Framework_TestCase
+class Bdu_Tests_ApiTest extends Bdu_Tests_TestCase
{
public function testSearchStudentByLogin()
{
@@ -206,6 +206,27 @@ class Bdu_Tests_ApiTest extends PHPUnit_Framework_TestCase
$this->assertSame('Foobar', $api->getStudentPhotoUrl('11goreti'), '->getStudentPhotoUrl returns a Data Scheme Uri if the student exists');
}
+ public function testBatchRetrieveStudents()
+ {
+ $uow = $this->getMockBuilder('Bdu_Util_UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $student = new Bdu_Entity_Student('11goreti', $uow);
+ $uow->expects($this->once())
+ ->method('rawSearch')
+ ->with($this->equalTo('(uid=11goreti)'), array())
+ ->will($this->returnValue($this->getStudentData()));
+ $uow->expects($this->once())
+ ->method('getStudent')
+ ->with($this->equalTo('11goreti'), false)
+ ->will($this->returnValue($student));
+
+ $api = new Bdu_Api($uow);
+ $api->batchRetrieveStudents(array($student));
+
+ $this->assertNotNull($this->readAttribute($student, 'prop'), 'batchRetrieve populate the student\'s properties');
+ }
+
public function testIsValidLogin()
{
$uow = $this->getMockBuilder('Bdu_Util_UnitOfWork')
diff --git a/test/Bdu/Tests/ConfigurationTest.php b/test/Bdu/Tests/ConfigurationTest.php
index 25a3abe..b876b7d 100644
--- a/test/Bdu/Tests/ConfigurationTest.php
+++ b/test/Bdu/Tests/ConfigurationTest.php
@@ -24,6 +24,9 @@ class Bdu_Tests_ConfigurationTest extends PHPUnit_Framework_TestCase
$config->setCredentials('11goreti', Bdu_Configuration::TYPE_PEOPLE, '1234poney');
$this->assertSame(array('uid=11goreti,ou=people,dc=campus,dc=ecp,dc=fr', '1234poney'), $config->getCredentials());
+
+ $config->setLdapRoot('dc=ecp,dc=fr');
+ $this->assertSame(array('uid=11goreti,ou=people,dc=ecp,dc=fr', '1234poney'), $config->getCredentials());
}
public function testLogger()
@@ -96,4 +99,24 @@ class Bdu_Tests_ConfigurationTest extends PHPUnit_Framework_TestCase
throw $e;
}
}
+
+ public function testLdapHost()
+ {
+ $config = new Bdu_Configuration();
+
+ $this->assertEquals(Bdu_Configuration::LDAP_HOST, $config->getLdapHost());
+
+ $config->setLdapHost('foobar');
+ $this->assertEquals('foobar', $config->getLdapHost());
+ }
+
+ public function testLdapBaseDn()
+ {
+ $config = new Bdu_Configuration();
+
+ $this->assertEquals(Bdu_Configuration::LDAP_BASE_DN, $config->getLdapBaseDn());
+
+ $config->setLdapBaseDn('foobar');
+ $this->assertEquals('foobar', $config->getLdapBaseDn());
+ }
}