appConfig = $this->createMock(IAppConfig::class); $this->emailValidator = new EmailValidator($this->appConfig); } public static function mailAddressProvider(): array { return [ ['lukas@nextcloud.com', true, false], ['lukas@localhost', true, false], ['lukas@192.168.1.1', true, false], ['lukas@éxämplè.com', true, false], ['asdf', false, false], ['', false, false], ['lukas@nextcloud.org@nextcloud.com', false, false], ['test@localhost', true, false], ['test@localhost', false, true], ]; } #[DataProvider('mailAddressProvider')] public function testIsValid($email, $expected, $strict): void { $this->appConfig ->expects($this->atMost(1)) ->method('getValueString') ->with('core', 'enforce_strict_email_check', 'yes') ->willReturn($strict ? 'yes' : 'no'); $this->assertSame($expected, $this->emailValidator->isValid($email)); } }