From ba91d2e533d24d188de7d1f20043fda87950a242 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Thu, 18 Nov 2021 13:36:59 +0100 Subject: [PATCH] Add more tests --- src/TestUtils/DummyLDAPApiProvider.php | 11 +---------- tests/PersonTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/TestUtils/DummyLDAPApiProvider.php b/src/TestUtils/DummyLDAPApiProvider.php index c1dde5b..57f6542 100644 --- a/src/TestUtils/DummyLDAPApiProvider.php +++ b/src/TestUtils/DummyLDAPApiProvider.php @@ -15,20 +15,11 @@ class DummyLDAPApiProvider implements LDAPApiProviderInterface */ public function personFromUserItemPostHook(array $attributes, Person $person, bool $full = false) { - // For example, you can parse the date of birth from the LDAP attribute and set it to the person object. - -// $birthDate = $attributes['dateofbirth'][0]; -// $person->setBirthDate($birthDate); + $person->setExtraData('test', 'my-test-string'); } public function getPersonForExternalServiceHook(string $service, string $serviceID): Person { - // For example, you can use the service and serviceID to get the person from some other service. - -// if ($service === 'SOME-SERVICE') { -// return getPersonFromSomeService($serviceID); -// } - throw new BadRequestHttpException("Unknown service: $service"); } } diff --git a/tests/PersonTest.php b/tests/PersonTest.php index 991099f..dba64b0 100644 --- a/tests/PersonTest.php +++ b/tests/PersonTest.php @@ -83,4 +83,15 @@ class PersonTest extends ApiTestCase $this->assertEquals('1994-06-24', $person->getBirthDate()); } } + + public function testLDAPApiProvider() + { + $user = new AdldapUser([ + 'cn' => ['foobar'], + ], $this->newBuilder()); + + $person = $this->api->personFromUserItem($user, false); + + $this->assertEquals($person->getExtraData('test'), 'my-test-string'); + } } -- GitLab