Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update phpunit 9 => 10 and psalm 4 => 5 #368

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"symfony/polyfill-intl-idn": "^1.26"
},
"require-dev": {
"phpunit/phpunit": "^9.5.27",
"vimeo/psalm": "^4.30"
"phpunit/phpunit": "^10.2",
"vimeo/psalm": "^5.12"
},
"suggest": {
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
Expand Down
28 changes: 19 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" executionOrder="defects" processIsolation="false" stopOnFailure="false">
<coverage>
<include>
<directory>./src/</directory>
</include>
<exclude>
<directory suffix=".php">./src/Result/Reason</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
executionOrder="defects"
cacheDirectory=".phpunit.cache"
>
<coverage/>

<testsuites>
<testsuite name="EmailValidator Test Suite">
<directory>./tests/EmailValidator</directory>
<exclude>./vendor/</exclude>
</testsuite>
</testsuites>

<source>
<include>
<directory>./src/</directory>
</include>
<exclude>
<directory suffix=".php">./src/Result/Reason</directory>
</exclude>
</source>

</phpunit>
8 changes: 4 additions & 4 deletions tests/EmailValidator/EmailLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public function testLexerParsesInvalidUTF8($char)
$this->assertEquals(EmailLexer::INVALID, $lexer->current->type);
}

public function invalidUTF8CharsProvider()
public static function invalidUTF8CharsProvider()
{
$chars = array();
for ($i = 0; $i < 0x100; ++$i) {
$c = $this->utf8Chr($i);
$c = self::utf8Chr($i);
if (preg_match('/(?=\p{Cc})(?=[^\t\n\n\r])/u', $c) && !preg_match('/\x{0000}/u', $c)) {
$chars[] = array($c);
}
Expand All @@ -64,7 +64,7 @@ public function invalidUTF8CharsProvider()
return $chars;
}

protected function utf8Chr($code_point)
protected static function utf8Chr($code_point)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the reasoning behind this change please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhpUnit 10 is deprecating data providers that are not static.
sebastianbergmann/phpunit@9caafe2
https://docs.phpunit.de/en/10.0/writing-tests-for-phpunit.html#data-providers

This will trigger warnings in phpunit testruns. Some CI break with warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular change is needed to make the data provider static, that is calling this function.

{

if ($code_point < 0 || 0x10FFFF < $code_point || (0xD800 <= $code_point && $code_point <= 0xDFFF)) {
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testLexerSearchToken()
$this->assertTrue($lexer->find(EmailLexer::S_HTAB));
}

public function getTokens()
public static function getTokens()
{
return array(
array("foo", EmailLexer::GENERIC),
Expand Down
2 changes: 1 addition & 1 deletion tests/EmailValidator/EmailParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class EmailParserTest extends TestCase
{
public function emailPartsProvider()
public static function emailPartsProvider()
{
return [
['[email protected]', 'test', 'foo.com'],
Expand Down
4 changes: 2 additions & 2 deletions tests/EmailValidator/Validation/DNSCheckValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class DNSCheckValidationTest extends TestCase
{
public function validEmailsProvider()
public static function validEmailsProvider()
{
return [
// dot-atom
Expand All @@ -37,7 +37,7 @@ public function validEmailsProvider()
];
}

public function localOrReservedEmailsProvider()
public static function localOrReservedEmailsProvider()
{
return [
// Reserved Top Level DNS Names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testEmailWithSpoofsIsInvalid()
$this->assertFalse($validation->isValid("Кириллица"."latin漢字"."ひらがな"."カタカナ", new EmailLexer()));
}

public function validUTF8EmailsProvider()
public static function validUTF8EmailsProvider()
{
return [
// Cyrillic
Expand Down
4 changes: 2 additions & 2 deletions tests/EmailValidator/Validation/MessageIDValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testValidMessageIDs(string $messageID)
$this->assertTrue($validator->isValid($messageID, new EmailLexer()));
}

public function validMessageIDs() : array
public static function validMessageIDs() : array
{
return [
['[email protected]+&%$.d'],
Expand All @@ -38,7 +38,7 @@ public function testInvalidMessageIDs(string $messageID)
$this->assertFalse($validator->isValid($messageID, new EmailLexer()));
}

public function invalidMessageIDs() : array
public static function invalidMessageIDs() : array
{
return [
['example'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testEmailWithoutWarningsIsValid($email)
$this->assertNull($validation->getError());
}

public function getValidEmailsWithoutWarnings()
public static function getValidEmailsWithoutWarnings()
{
return [
['[email protected]',],
Expand Down
10 changes: 5 additions & 5 deletions tests/EmailValidator/Validation/RFCValidationDomainPartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testValidEmails($email)
$this->assertTrue($this->validator->isValid($email, $this->lexer));
}

public function getValidEmails()
public static function getValidEmails()
{
return array(
['[email protected]'],
Expand All @@ -88,7 +88,7 @@ public function testInvalidEmails($email)
$this->assertFalse($this->validator->isValid($email, $this->lexer));
}

public function getInvalidEmails()
public static function getInvalidEmails()
{
return [
['[email protected] test'],
Expand Down Expand Up @@ -161,7 +161,7 @@ public function testInvalidEmailsWithErrorsCheck($error, $email)
$this->assertEquals($error, $this->validator->getError());
}

public function getInvalidEmailsWithErrors()
public static function getInvalidEmailsWithErrors()
{
return [
[new InvalidEmail(new NoDomainPart(), ''), 'example@'],
Expand Down Expand Up @@ -203,7 +203,7 @@ public function testValidEmailsWithWarningsCheck($expectedWarnings, $email)
}
}

public function getValidEmailsWithWarnings()
public static function getValidEmailsWithWarnings()
{
return [
//Check if this is actually possible
Expand Down Expand Up @@ -232,7 +232,7 @@ public function getValidEmailsWithWarnings()
];
}

public function invalidUTF16Chars()
public static function invalidUTF16Chars()
{
return [
['example@symƒony.com'],
Expand Down
8 changes: 4 additions & 4 deletions tests/EmailValidator/Validation/RFCValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testValidEmails($email)
$this->assertTrue($this->validator->isValid($email, $this->lexer));
}

public function getValidEmails()
public static function getValidEmails()
{
return array(
['â@iana.org'],
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testValidEmailsWithWarningsCheck($email, $expectedWarnings)
$this->assertEquals($expectedWarnings, $this->validator->getWarnings());
}

public function getValidEmailsWithWarnings()
public static function getValidEmailsWithWarnings()
{
return [
['a5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com', [new LocalTooLong()]],
Expand Down Expand Up @@ -120,7 +120,7 @@ public function testInvalidEmails($email)
$this->assertFalse($this->validator->isValid($email, $this->lexer));
}

public function getInvalidEmails()
public static function getInvalidEmails()
{
return [
['user [email protected]'],
Expand Down Expand Up @@ -164,7 +164,7 @@ public function testInvalidDEmailsWithErrorsCheck($error, $email)
$this->assertEquals($error, $this->validator->getError());
}

public function getInvalidEmailsWithErrors()
public static function getInvalidEmailsWithErrors()
{
return [
[new InvalidEmail(new NoLocalPart(), "@"), '@example.co.uk'],
Expand Down