diff --git a/.gitattributes b/.gitattributes index c26a1fd..a5b5f9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ -/Tests export-ignore /documentation export-ignore +/tests export-ignore /.* export-ignore /phpunit.xml.dist export-ignore /psalm.xml export-ignore diff --git a/EmailValidator/Validation/DNSCheckValidation.php b/EmailValidator/Validation/DNSCheckValidation.php deleted file mode 100644 index 77575fd..0000000 --- a/EmailValidator/Validation/DNSCheckValidation.php +++ /dev/null @@ -1,77 +0,0 @@ -checkDNS($host); - } - - public function getError() : ?InvalidEmail - { - return $this->error; - } - - public function getWarnings() - { - return $this->warnings; - } - - /** - * @param string $host - * - * @return bool - */ - protected function checkDNS($host) - { - $variant = INTL_IDNA_VARIANT_2003; - if ( defined('INTL_IDNA_VARIANT_UTS46') ) { - $variant = INTL_IDNA_VARIANT_UTS46; - } - $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; - - $Aresult = true; - $MXresult = checkdnsrr($host, 'MX'); - - if (!$MXresult) { - $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); - $Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'); - if (!$Aresult) { - $this->error = new InvalidEmail(new NoDNSRecord(), $host); - } - } - return $MXresult || $Aresult; - } -} diff --git a/README.md b/README.md index 7a2ec73..0e03e66 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ # EmailValidator -[!https://img.shields.io/packagist/v/egulias/email-validator.svg?style=flat-square](https://packagist.org/packages/egulias/email-validator) [![Build Status](https://travis-ci.org/egulias/EmailValidator.svg?branch=master)](https://travis-ci.org/egulias/EmailValidator) [![Coverage Status](https://coveralls.io/repos/egulias/EmailValidator/badge.svg?branch=master)](https://coveralls.io/r/egulias/EmailValidator?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6) -============================= +[!https://img.shields.io/packagist/v/egulias/email-validator.svg?style=flat-square](https://packagist.org/packages/egulias/email-validator) +[![Build Status](https://travis-ci.org/egulias/EmailValidator.svg?branch=master)](https://travis-ci.org/egulias/EmailValidator) +[![Coverage Status](https://coveralls.io/repos/egulias/EmailValidator/badge.svg?branch=master)](https://coveralls.io/r/egulias/EmailValidator?branch=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6) + ## Suported RFCs ## + This library aims to support: RFC 5321, 5322, 6530, 6531, 6532. @@ -9,7 +14,7 @@ RFC 5321, 5322, 6530, 6531, 6532. ## Requirements ## * [Composer](https://getcomposer.org) is required for installation - * [Spoofchecking](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php) and [DNSCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/DNSCheckValidation.php) validation requires that your PHP system has the [PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php) (also known as PHP Intl) + * [Spoofchecking](/src/Validation/SpoofCheckValidation.php) and [DNSCheckValidation](/src/Validation/DNSCheckValidation.php) validation requires that your PHP system has the [PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php) (also known as PHP Intl) ## Installation ## @@ -20,6 +25,7 @@ composer require egulias/email-validator ``` ## Getting Started ## + `EmailValidator`requires you to decide which (or combination of them) validation/s strategy/ies you'd like to follow for each [validation](#available-validations). A basic example with the RFC validation @@ -36,11 +42,11 @@ $validator->isValid("example@example.com", new RFCValidation()); //true ### Available validations ### -1. [RFCValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/RFCValidation.php) -2. [NoRFCWarningsValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/NoRFCWarningsValidation.php) -3. [DNSCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/DNSCheckValidation.php) -4. [SpoofCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php) -5. [MultipleValidationWithAnd](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/MultipleValidationWithAnd.php) +1. [RFCValidation](/src/Validation/RFCValidation.php) +2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php) +3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php) +4. [SpoofCheckValidation](/src/Validation/SpoofCheckValidation.php) +5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php) 6. [Your own validation](#how-to-extend) `MultipleValidationWithAnd` @@ -65,10 +71,11 @@ $validator->isValid("example@example.com", $multipleValidations); //true ### How to extend ### -It's easy! You just need to implement [EmailValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/EmailValidation.php) and you can use your own validation. +It's easy! You just need to implement [EmailValidation](/src/Validation/EmailValidation.php) and you can use your own validation. ## Other Contributors ## + (You can find current contributors [here](https://github.com/egulias/EmailValidator/graphs/contributors)) As this is a port from another library and work, here are other people related to the previous one: @@ -78,5 +85,5 @@ As this is a port from another library and work, here are other people related t * Dominic Sayers [@dominicsayers](https://github.com/dominicsayers): The original isemail function ## License ## -Released under the MIT License attached with this code. +Released under the MIT License attached with this code. diff --git a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php b/Tests/EmailValidator/Validation/DNSCheckValidationTest.php deleted file mode 100644 index 16149f2..0000000 --- a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php +++ /dev/null @@ -1,64 +0,0 @@ -assertTrue($validation->isValid($validEmail, new EmailLexer())); - } - - public function testInvalidDNS() - { - $validation = new DNSCheckValidation(); - $this->assertFalse($validation->isValid("example@invalid.example.com", new EmailLexer())); - } - - public function testDNSWarnings() - { - $validation = new DNSCheckValidation(); - $expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()]; - $validation->isValid("example@invalid.example.com", new EmailLexer()); - $this->assertEquals($expectedWarnings, $validation->getWarnings()); - } - - public function testNoDNSError() - { - $validation = new DNSCheckValidation(); - $expectedError = new InvalidEmail(new NoDNSRecord(),"invalid.example.com."); - $validation->isValid("example@invalid.example.com", new EmailLexer()); - $this->assertEquals($expectedError, $validation->getError()); - } -} diff --git a/Tests/EmailValidator/Validation/ValitadionTest.php b/Tests/EmailValidator/Validation/ValitadionTest.php deleted file mode 100644 index fedaf62..0000000 --- a/Tests/EmailValidator/Validation/ValitadionTest.php +++ /dev/null @@ -1,13 +0,0 @@ -markTestIncomplete("implement return type Validation"); - } -} diff --git a/composer.json b/composer.json index abbad47..84d0432 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,12 @@ }, "autoload": { "psr-4": { - "Egulias\\EmailValidator\\": "EmailValidator" + "Egulias\\EmailValidator\\": "src" } }, "autoload-dev": { "psr-4": { - "Egulias\\Tests\\": "Tests" + "Egulias\\EmailValidator\\Tests\\": "tests" } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1122406..fea68f4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,14 +12,14 @@ > - ./Tests/EmailValidator + ./tests/EmailValidator ./vendor/ - ./EmailValidator/ + ./src/ diff --git a/psalm.baseline.xml b/psalm.baseline.xml index f81df72..13a922e 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -1,16 +1,16 @@ - + self::$nullToken - + parse - + Spoofchecker Spoofchecker diff --git a/psalm.xml b/psalm.xml index fb17dc8..e6be752 100644 --- a/psalm.xml +++ b/psalm.xml @@ -8,7 +8,7 @@ errorBaseline="./psalm.baseline.xml" > - + diff --git a/EmailValidator/EmailLexer.php b/src/EmailLexer.php similarity index 100% rename from EmailValidator/EmailLexer.php rename to src/EmailLexer.php diff --git a/EmailValidator/EmailParser.php b/src/EmailParser.php similarity index 100% rename from EmailValidator/EmailParser.php rename to src/EmailParser.php diff --git a/EmailValidator/EmailValidator.php b/src/EmailValidator.php similarity index 100% rename from EmailValidator/EmailValidator.php rename to src/EmailValidator.php diff --git a/EmailValidator/Exception/AtextAfterCFWS.php b/src/Exception/AtextAfterCFWS.php similarity index 100% rename from EmailValidator/Exception/AtextAfterCFWS.php rename to src/Exception/AtextAfterCFWS.php diff --git a/EmailValidator/Exception/CRLFAtTheEnd.php b/src/Exception/CRLFAtTheEnd.php similarity index 100% rename from EmailValidator/Exception/CRLFAtTheEnd.php rename to src/Exception/CRLFAtTheEnd.php diff --git a/EmailValidator/Exception/CRLFX2.php b/src/Exception/CRLFX2.php similarity index 100% rename from EmailValidator/Exception/CRLFX2.php rename to src/Exception/CRLFX2.php diff --git a/EmailValidator/Exception/CRNoLF.php b/src/Exception/CRNoLF.php similarity index 100% rename from EmailValidator/Exception/CRNoLF.php rename to src/Exception/CRNoLF.php diff --git a/EmailValidator/Exception/CharNotAllowed.php b/src/Exception/CharNotAllowed.php similarity index 100% rename from EmailValidator/Exception/CharNotAllowed.php rename to src/Exception/CharNotAllowed.php diff --git a/EmailValidator/Exception/CommaInDomain.php b/src/Exception/CommaInDomain.php similarity index 100% rename from EmailValidator/Exception/CommaInDomain.php rename to src/Exception/CommaInDomain.php diff --git a/EmailValidator/Exception/ConsecutiveAt.php b/src/Exception/ConsecutiveAt.php similarity index 100% rename from EmailValidator/Exception/ConsecutiveAt.php rename to src/Exception/ConsecutiveAt.php diff --git a/EmailValidator/Exception/ConsecutiveDot.php b/src/Exception/ConsecutiveDot.php similarity index 100% rename from EmailValidator/Exception/ConsecutiveDot.php rename to src/Exception/ConsecutiveDot.php diff --git a/src/Exception/DomainAcceptsNoMail.php b/src/Exception/DomainAcceptsNoMail.php new file mode 100644 index 0000000..40a9970 --- /dev/null +++ b/src/Exception/DomainAcceptsNoMail.php @@ -0,0 +1,9 @@ +error = new InvalidEmail(new LocalOrReservedDomain(), $host); + return false; + } + + return $this->checkDns($host); + } + + public function getError() : ?InvalidEmail + { + return $this->error; + } + + public function getWarnings() + { + return $this->warnings; + } + + /** + * @param string $host + * + * @return bool + */ + protected function checkDns($host) + { + $variant = INTL_IDNA_VARIANT_2003; + if (defined('INTL_IDNA_VARIANT_UTS46')) { + $variant = INTL_IDNA_VARIANT_UTS46; + } + + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; + + return $this->validateDnsRecords($host); + } + + + /** + * Validate the DNS records for given host. + * + * @param string $host A set of DNS records in the format returned by dns_get_record. + * + * @return bool True on success. + */ + private function validateDnsRecords($host) + { + // Get all MX, A and AAAA DNS records for host + $dnsRecords = dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); + + + // No MX, A or AAAA DNS records + if (empty($dnsRecords)) { + $this->error = new InvalidEmail(new ReasonNoDNSRecord(), ''); + return false; + } + + // For each DNS record + foreach ($dnsRecords as $dnsRecord) { + if (!$this->validateMXRecord($dnsRecord)) { + // No MX records (fallback to A or AAAA records) + + if (empty($this->mxRecords)) { + $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); + } + return false; + } + } + + + return true; + } + + /** + * Validate an MX record + * + * @param array $dnsRecord Given DNS record. + * + * @return bool True if valid. + */ + private function validateMxRecord($dnsRecord) + { + if ($dnsRecord['type'] !== 'MX') { + return true; + } + + // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) + if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { + $this->error = new InvalidEmail(new DomainAcceptsNoMail(), ""); + return false; + } + + $this->mxRecords[] = $dnsRecord; + + return true; + } +} \ No newline at end of file diff --git a/EmailValidator/Validation/EmailValidation.php b/src/Validation/EmailValidation.php similarity index 100% rename from EmailValidator/Validation/EmailValidation.php rename to src/Validation/EmailValidation.php diff --git a/EmailValidator/Validation/Exception/EmptyValidationList.php b/src/Validation/Exception/EmptyValidationList.php similarity index 100% rename from EmailValidator/Validation/Exception/EmptyValidationList.php rename to src/Validation/Exception/EmptyValidationList.php diff --git a/EmailValidator/Validation/MultipleValidationWithAnd.php b/src/Validation/MultipleValidationWithAnd.php similarity index 100% rename from EmailValidator/Validation/MultipleValidationWithAnd.php rename to src/Validation/MultipleValidationWithAnd.php diff --git a/EmailValidator/Validation/NoRFCWarningsValidation.php b/src/Validation/NoRFCWarningsValidation.php similarity index 100% rename from EmailValidator/Validation/NoRFCWarningsValidation.php rename to src/Validation/NoRFCWarningsValidation.php diff --git a/EmailValidator/Validation/RFCValidation.php b/src/Validation/RFCValidation.php similarity index 100% rename from EmailValidator/Validation/RFCValidation.php rename to src/Validation/RFCValidation.php diff --git a/EmailValidator/Validation/SpoofCheckValidation.php b/src/Validation/SpoofCheckValidation.php similarity index 100% rename from EmailValidator/Validation/SpoofCheckValidation.php rename to src/Validation/SpoofCheckValidation.php diff --git a/EmailValidator/Warning/AddressLiteral.php b/src/Warning/AddressLiteral.php similarity index 100% rename from EmailValidator/Warning/AddressLiteral.php rename to src/Warning/AddressLiteral.php diff --git a/EmailValidator/Warning/CFWSNearAt.php b/src/Warning/CFWSNearAt.php similarity index 100% rename from EmailValidator/Warning/CFWSNearAt.php rename to src/Warning/CFWSNearAt.php diff --git a/EmailValidator/Warning/CFWSWithFWS.php b/src/Warning/CFWSWithFWS.php similarity index 100% rename from EmailValidator/Warning/CFWSWithFWS.php rename to src/Warning/CFWSWithFWS.php diff --git a/EmailValidator/Warning/Comment.php b/src/Warning/Comment.php similarity index 100% rename from EmailValidator/Warning/Comment.php rename to src/Warning/Comment.php diff --git a/EmailValidator/Warning/DeprecatedComment.php b/src/Warning/DeprecatedComment.php similarity index 100% rename from EmailValidator/Warning/DeprecatedComment.php rename to src/Warning/DeprecatedComment.php diff --git a/EmailValidator/Warning/DomainLiteral.php b/src/Warning/DomainLiteral.php similarity index 100% rename from EmailValidator/Warning/DomainLiteral.php rename to src/Warning/DomainLiteral.php diff --git a/EmailValidator/Warning/DomainTooLong.php b/src/Warning/DomainTooLong.php similarity index 100% rename from EmailValidator/Warning/DomainTooLong.php rename to src/Warning/DomainTooLong.php diff --git a/EmailValidator/Warning/EmailTooLong.php b/src/Warning/EmailTooLong.php similarity index 100% rename from EmailValidator/Warning/EmailTooLong.php rename to src/Warning/EmailTooLong.php diff --git a/EmailValidator/Warning/IPV6BadChar.php b/src/Warning/IPV6BadChar.php similarity index 100% rename from EmailValidator/Warning/IPV6BadChar.php rename to src/Warning/IPV6BadChar.php diff --git a/EmailValidator/Warning/IPV6ColonEnd.php b/src/Warning/IPV6ColonEnd.php similarity index 100% rename from EmailValidator/Warning/IPV6ColonEnd.php rename to src/Warning/IPV6ColonEnd.php diff --git a/EmailValidator/Warning/IPV6ColonStart.php b/src/Warning/IPV6ColonStart.php similarity index 100% rename from EmailValidator/Warning/IPV6ColonStart.php rename to src/Warning/IPV6ColonStart.php diff --git a/EmailValidator/Warning/IPV6Deprecated.php b/src/Warning/IPV6Deprecated.php similarity index 100% rename from EmailValidator/Warning/IPV6Deprecated.php rename to src/Warning/IPV6Deprecated.php diff --git a/EmailValidator/Warning/IPV6DoubleColon.php b/src/Warning/IPV6DoubleColon.php similarity index 100% rename from EmailValidator/Warning/IPV6DoubleColon.php rename to src/Warning/IPV6DoubleColon.php diff --git a/EmailValidator/Warning/IPV6GroupCount.php b/src/Warning/IPV6GroupCount.php similarity index 100% rename from EmailValidator/Warning/IPV6GroupCount.php rename to src/Warning/IPV6GroupCount.php diff --git a/EmailValidator/Warning/IPV6MaxGroups.php b/src/Warning/IPV6MaxGroups.php similarity index 100% rename from EmailValidator/Warning/IPV6MaxGroups.php rename to src/Warning/IPV6MaxGroups.php diff --git a/EmailValidator/Warning/LabelTooLong.php b/src/Warning/LabelTooLong.php similarity index 100% rename from EmailValidator/Warning/LabelTooLong.php rename to src/Warning/LabelTooLong.php diff --git a/EmailValidator/Warning/LocalTooLong.php b/src/Warning/LocalTooLong.php similarity index 100% rename from EmailValidator/Warning/LocalTooLong.php rename to src/Warning/LocalTooLong.php diff --git a/EmailValidator/Warning/NoDNSMXRecord.php b/src/Warning/NoDNSMXRecord.php similarity index 100% rename from EmailValidator/Warning/NoDNSMXRecord.php rename to src/Warning/NoDNSMXRecord.php diff --git a/EmailValidator/Warning/ObsoleteDTEXT.php b/src/Warning/ObsoleteDTEXT.php similarity index 100% rename from EmailValidator/Warning/ObsoleteDTEXT.php rename to src/Warning/ObsoleteDTEXT.php diff --git a/EmailValidator/Warning/QuotedPart.php b/src/Warning/QuotedPart.php similarity index 100% rename from EmailValidator/Warning/QuotedPart.php rename to src/Warning/QuotedPart.php diff --git a/EmailValidator/Warning/QuotedString.php b/src/Warning/QuotedString.php similarity index 100% rename from EmailValidator/Warning/QuotedString.php rename to src/Warning/QuotedString.php diff --git a/EmailValidator/Warning/TLD.php b/src/Warning/TLD.php similarity index 100% rename from EmailValidator/Warning/TLD.php rename to src/Warning/TLD.php diff --git a/EmailValidator/Warning/Warning.php b/src/Warning/Warning.php similarity index 100% rename from EmailValidator/Warning/Warning.php rename to src/Warning/Warning.php diff --git a/Tests/EmailValidator/Dummy/DummyReason.php b/tests/EmailValidator/Dummy/DummyReason.php similarity index 80% rename from Tests/EmailValidator/Dummy/DummyReason.php rename to tests/EmailValidator/Dummy/DummyReason.php index 588addc..3cfbb23 100644 --- a/Tests/EmailValidator/Dummy/DummyReason.php +++ b/tests/EmailValidator/Dummy/DummyReason.php @@ -1,5 +1,5 @@ assertTrue($validation->isValid($validEmail, new EmailLexer())); + } + + public function testInvalidDNS() + { + $validation = new DNSCheckValidation(); + $this->assertFalse($validation->isValid("example@invalid.example.com", new EmailLexer())); + } + + /** + * @dataProvider localOrReservedEmailsProvider + */ + public function testLocalOrReservedDomainError($localOrReservedEmails) + { + $validation = new DNSCheckValidation(); + $expectedError = new InvalidEmail(new LocalOrReservedDomain(), $localOrReservedEmails); + $validation->isValid($localOrReservedEmails, new EmailLexer()); + $this->assertEquals($expectedError, $validation->getError()); + } + + public function testDomainAcceptsNoMailError() + { + $validation = new DNSCheckValidation(); + $expectedError = new InvalidEmail(new DomainAcceptsNoMail(), ""); + $isValidResult = $validation->isValid("nullmx@example.com", new EmailLexer()); + $this->assertEquals($expectedError, $validation->getError()); + $this->assertFalse($isValidResult); + } + + public function testDNSWarnings() + { + $this->markTestSkipped('Need to found a domain with AAAA redords and no MX that fails later in the validations'); + $validation = new DNSCheckValidation(); + $expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()]; + $validation->isValid("example@invalid.example.com", new EmailLexer()); + $this->assertEquals($expectedWarnings, $validation->getWarnings()); + } + + public function testNoDNSError() + { + $validation = new DNSCheckValidation(); + $expectedError = new InvalidEmail(new NoDNSRecord(), ''); + $validation->isValid("example@invalid.example.com", new EmailLexer()); + $this->assertEquals($expectedError, $validation->getError()); + } +} \ No newline at end of file diff --git a/Tests/EmailValidator/Validation/IsEmailFunctionTests.php b/tests/EmailValidator/Validation/IsEmailFunctionTests.php similarity index 89% rename from Tests/EmailValidator/Validation/IsEmailFunctionTests.php rename to tests/EmailValidator/Validation/IsEmailFunctionTests.php index 565741a..e8b3997 100644 --- a/Tests/EmailValidator/Validation/IsEmailFunctionTests.php +++ b/tests/EmailValidator/Validation/IsEmailFunctionTests.php @@ -1,6 +1,6 @@ load($testSuite); $elements = $document->getElementsByTagName('test'); diff --git a/Tests/EmailValidator/Validation/MultipleValidationWithAndTest.php b/tests/EmailValidator/Validation/MultipleValidationWithAndTest.php similarity index 94% rename from Tests/EmailValidator/Validation/MultipleValidationWithAndTest.php rename to tests/EmailValidator/Validation/MultipleValidationWithAndTest.php index 1f2168d..54afe56 100644 --- a/Tests/EmailValidator/Validation/MultipleValidationWithAndTest.php +++ b/tests/EmailValidator/Validation/MultipleValidationWithAndTest.php @@ -1,6 +1,6 @@ getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock(); + $validationTrue = $this->getMockBuilder(EmailValidation::class)->getMock(); $validationTrue->expects($this->any())->method("isValid")->willReturn(true); $validationTrue->expects($this->any())->method("getWarnings")->willReturn([]); @@ -68,7 +66,7 @@ class MultipleValidationWithAndTest extends TestCase $expectedResult = array_merge($warnings1, $warnings2); $lexer = new EmailLexer(); - $validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock(); + $validation1 = $this->getMockBuilder(EmailValidation::class)->getMock(); $validation1->expects($this->any())->method("isValid")->willReturn(true); $validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1); $validation1->expects($this->any())->method("getError")->willReturn($invalidEmail); diff --git a/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php b/tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php similarity index 94% rename from Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php rename to tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php index 703ec2c..6d56ffa 100644 --- a/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php +++ b/tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php @@ -1,6 +1,6 @@ assertFalse($this->validator->isValid($email, $this->lexer)); } diff --git a/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php b/tests/EmailValidator/Validation/SpoofCheckValidationTest.php similarity index 95% rename from Tests/EmailValidator/Validation/SpoofCheckValidationTest.php rename to tests/EmailValidator/Validation/SpoofCheckValidationTest.php index e345a19..4895fda 100644 --- a/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php +++ b/tests/EmailValidator/Validation/SpoofCheckValidationTest.php @@ -1,6 +1,6 @@