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

Use PHPUnit 9.3 on php 8 #37771

Merged
merged 1 commit into from Aug 12, 2020
Merged

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Aug 8, 2020

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Part of #37564
License MIT
Doc PR N/A

Our CI for PHP 8 is currently a blind spot, mainly because the PHPUnit version 8.3 that we use for the test suite is incompatible with php 8. This PR changes the PHPUnit version used on Travis for php 8 to PHPUnit 9.3.

Our test suite might not be 100% compatible with that new PHPUnit release yet, but this change should allow us to run most tests on php 8 again and enable us to iteratively migrate to PHPUnit 9.3.

@derrabus
Copy link
Member Author

derrabus commented Aug 8, 2020

I'm browsing through all failures on the php 8 run at the moment and see if I can fix or file separate issues for them.

@stof
Copy link
Member

stof commented Aug 10, 2020

Errors related to PHPUnit 9.3:

  • TestCase::at() is deprecated. We would need to migrate away from it (the replacement is compatible with older PHPUnit versions, so this can be done separately)
  • the PHPUnit bridge is not compatible, due to trying to use PHPUnit\TextUI\Exception
  • assertDirectoryNotExists is deprecated in favor of assertDirectoryDoesNotExist. the bridge might provide a polyfill for the new method for older PHPUnit versions.
  • Support for using expectException() with PHPUnit\Framework\Error\Warning is deprecated and will be removed in PHPUnit 10. Use expectWarning() instead.

Errors related to PHP 8:

  • doctrine/annotations is currently broken due to changes in the tokens for namespaces. This is being worked on in Doctrine so this will be solved.
  • Symfony\Component\Cache\Tests\Adapter\MemcachedAdapterTest and Symfony\Component\Cache\Tests\Simple\MemcachedCacheTextModeTest fail because the exception message for undefined class constants changed.
  • Symfony\Component\ExpressionLanguage\Tests\Node\GetAttrNodeTest::testEvaluate fails because of an incompatibility with named arguments (probably using call_user_fun_array with an associative array)
  • Symfony\Component\Filesystem\Tests\FilesystemTest fails with a TypeError on wrong mode. The tests should probably be skipped.
  • Symfony\Component\Yaml\Tests\DumperTest::testSpecifications has a failure

@derrabus
Copy link
Member Author

Thanks for the overview. I can look into the individual issues in the upcoming days, but nevertheless I think that we can merge this PR already. It improves the php 8 CI from "completely broken" to "just a little broken". 😃

A few notes:

TestCase::at() is deprecated.

➡️ #37780

assertDirectoryNotExists is deprecated in favor of assertDirectoryDoesNotExist. the bridge might provide a polyfill for the new method for older PHPUnit versions.

It does already:

public static function assertDirectoryDoesNotExist($directory, $message = '')
{
static::assertDirectoryNotExists($directory, $message);
}

@stof
Copy link
Member

stof commented Aug 10, 2020

It does already:

then that's even easier. We can migrate to use the new method everywhere.

But this polyfill is weird. It never calls the parent implementation.

@derrabus
Copy link
Member Author

But this polyfill is weird. It never calls the parent implementation.

That's because PhpUnitBridge patches the trait directly into the TestCase class.

@derrabus
Copy link
Member Author

Also related to php 8: We still see the message Method ReflectionParameter::getClass() is deprecated frequently. As far as I can tell, we would need to backport #36975 to the 3.4 branch if we wanted to fix them.

@fabpot
Copy link
Member

fabpot commented Aug 12, 2020

Thank you @derrabus.

@fabpot fabpot merged commit 78cc0ef into symfony:3.4 Aug 12, 2020
@stof
Copy link
Member

stof commented Aug 12, 2020

  • doctrine/annotations is currently broken due to changes in the tokens for namespaces. This is being worked on in Doctrine so this will be solved.

for reference, this is now solved.

@derrabus derrabus deleted the bugfix/phpunit-9.3-on-php-8 branch August 12, 2020 18:11
This was referenced Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants