Commit 2e1d8c89 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

2 petits Tests fonctionnels pour apprendre à utiliser le module : Recherche...

2 petits Tests fonctionnels pour apprendre à utiliser le module : Recherche d'un individu par numéro Harpege et par login !
parent b8057f28
......@@ -3,6 +3,7 @@
namespace UnicaenLdapFuncTest\Service;
use PHPUnit_Framework_TestCase;
use UnicaenLdap\Entity\People as PeopleEntity;
use UnicaenLdap\Filter\People as PeopleFilter;
use UnicaenLdapFuncTest\Bootstrap;
......@@ -12,7 +13,6 @@ use UnicaenLdapFuncTest\Bootstrap;
class ServiceTest extends PHPUnit_Framework_TestCase
{
/**
*
* @var \UnicaenLdap\Service\Service
*/
protected $service;
......@@ -20,21 +20,40 @@ class ServiceTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$serviceManager = Bootstrap::getServiceManager();
$this->service = $serviceManager->get('ldapServicePeople');
$this->service = Bootstrap::getServiceManager()->get('ldapServicePeople');
}
public function testConstructor()
public function testCanRetrieveServiceFromManager()
{
$this->assertInstanceOf('UnicaenLdap\Service\Service', $this->service);
$this->assertEquals('dc=unicaen,dc=fr', $this->service->getLdap()->getBaseDn());
$this->assertTrue(true);
$service = Bootstrap::getServiceManager()->get('ldapServicePeople');
$this->assertInstanceOf('UnicaenLdap\Service\Service', $service);
$this->assertEquals('dc=unicaen,dc=fr', $service->getLdap()->getBaseDn());
}
public function testCanSearch()
public function testCanFindPeopleByNoIndividu()
{
$filter = PeopleFilter::noIndividu("21237");
$result = $this->service->search($filter);
var_dump(get_class($result));
$this->assertPeopleFindResult($result);
}
public function testCanFindPeopleByUsername()
{
$filter = PeopleFilter::username("gauthierb");
$result = $this->service->search($filter);
$this->assertPeopleFindResult($result);
}
private function assertPeopleFindResult($result)
{
$this->assertCount(1, $result);
$this->assertContainsOnlyInstancesOf("UnicaenLdap\Entity\People", $result);
$result->rewind();
$people = $result->current(); /** @var PeopleEntity $people */
$this->assertEquals($people->get('cn'), 'Gauthier Bertrand');
}
}
\ No newline at end of file
<?php
$settings = array(
'host' => 'host.domain.fr',
'port' => 389,
'version' => 3,
'baseDn' => "ou=xxxxxxxxxxx,dc=domain,dc=fr",
'bindRequiresDn' => true,
'username' => "uid=xxxxxxxxx,ou=xxxxxxxxxx,dc=domain,dc=fr",
'password' => "xxxxxxxxxxxx",
'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))",
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-ldap' => $settings,
);
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