diff --git a/src/TestUtils/DummyLDAPApiProvider.php b/src/TestUtils/DummyLDAPApiProvider.php index c1dde5ba782857609171a96bf5ec60caa4cc93ce..57f654245b56a99fd0918d3742be4531fdf5fe13 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 991099f6739b65f37917b0daf07bac042c3965b2..dba64b08f388379d102ede3b6567ca5c54adb694 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'); + } }