isEmployee($email)); } /** * @return iterable */ public static function addresses(): iterable { yield 'the configured domain' => ['someone@ep-reisen.de', true]; yield 'mixed case is still the same domain' => ['Someone@EP-Reisen.DE', true]; yield 'plus addressing does not touch the domain' => ['someone+booking@ep-reisen.de', true]; yield 'an at sign in the local part' => ['"odd@name"@ep-reisen.de', true]; yield 'another domain' => ['someone@example.org', false]; yield 'a subdomain is not the domain' => ['someone@mail.ep-reisen.de', false]; yield 'a domain merely ending in it' => ['someone@notep-reisen.de', false]; yield 'the domain as a prefix' => ['someone@ep-reisen.de.evil.test', false]; yield 'no at sign at all' => ['ep-reisen.de', false]; yield 'empty' => ['', false]; yield 'null' => [null, false]; } public function testWithoutConfiguredDomainsNobodyIsAnEmployee(): void { self::assertFalse((new EmployeeDomainMatcher([]))->isEmployee('someone@ep-reisen.de')); } public function testConfiguredDomainsAreNormalised(): void { $matcher = new EmployeeDomainMatcher([' EP-Reisen.DE ', '@example.org']); self::assertTrue($matcher->isEmployee('someone@ep-reisen.de')); self::assertTrue($matcher->isEmployee('someone@example.org')); } }