Description
In #32842, I implemented a new ForwardCompatTestTrait
in the phpunit-bridge to allow tests to run on the new php74-snapshot job, see #32289 This trait adds the void
return type that phpunit 8 requires, while preserving compatibility with branch 3.4, which supports PHP 5.5. As a reminder, we target to make 3.4 run on PHP 7.4.
As of #32882, the phpunit-bridge is able to run phpunit 4.8 to 8 and PHP 5.5 to 7.4. It does so by polyfilling some missing methods and by patching the return type of setUp*/tearDown* methods when needed.
Now, there are failures we need to overcome on PHP 7.4 + phpunit 8, as reported here:
https://travis-ci.org/symfony/symfony/jobs/567908746
We need to implement polyfill methods in ForwardCompatTestTrait
to allow fixing the deprecation warnings that phpunit 8 displays.
With #32887 in place, the process would be:
- open a PR against branch 4.4 to make the phpunit-bridge polyfill a missing feature when needed
- open a PR against branch 3.4 with the fix applied, and with the
SYMFONY_PHPUNIT_BRIDGE_PR
set to the number of the previous PR in.travis.yaml
- we'll merge 1. once things are validated, and you'll have to revert the change on
.travis.yaml
before we merge 2.
Here is the list of things that phpunit 8 reports and should be fixed:
- Use assertContainsEquals when needed #32969 The optional $checkForObjectIdentity parameter of assert(Not)Contains() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assert(Not)ContainsEquals() instead.
- Use assertEqualsWithDelta when needed #32968 The optional $delta parameter of assertEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertEqualsWithDelta() instead.
- Use assertStringContainsString when needed #32971 Using assert(Not)Contains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertString(Not)ContainsString() or assertString(Not)ContainsStringIgnoringCase() instead.
- [PhpUnitBridge] Remove calls to deprecated function assertAttributeX #32923 readAttribute()/getObjectAttribute()/assertAttributeEquals()/assertAttributeSame() is deprecated and will be removed in PHPUnit 9.
- [PhpUnitBridge] Remove deprecated methods assertArraySubset #32909 assertArraySubset() is deprecated and will be removed in PHPUnit 9.
- [PhpUnitBridge] added polyfill for assertStringContainsString*() #32878 [PhpUnitBridge] add more assert*() polyfills #32907 polyfill assertString(Not)ContainsString(IgnoringCase), assertEqualsWithDelta and assert(Not)ContainsEquals
- [PhpUnitBridge] Remove @expectedException annotation #32875 The @ExpectedException, @expectedExceptionCode, @expectedExceptionMessage, and @expectedExceptionMessageRegExp annotations are deprecated. They will be removed in PHPUnit 9. Refactor your test to use expectException(), expectExceptionCode(), expectExceptionMessage(), or expectExceptionMessageRegExp() instead.
- [PhpUnitBridge] Fix deprecation assertInternalType #32846 assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), or assertIsIterable() instead.
- Add polyfill for TestCase::createMock() #32865 Declaration of ...::createMock($classname) must be compatible with PHPUnit\Framework\TestCase::createMock
- Ensure signatures for setUp|tearDown|setUpAfterClass|tearDownAfterClass methods in tests are compatible with phpunit 8.2 #32854 add
void
return types on branch 4.3+ where setup/teardown methods are still used - Fix phpunit 8 compat to unlock testing Symfony on PHP 7.4 php-cache/integration-tests#102 do the same with 3rd party deps that we use
And fix PHP 7.4 deprecations:
- Fix tests/code for php 7.4 #32981 Invalid characters passed for attempted conversion
- Fix tests/code for php 7.4 #32981 Trying to access array offset on value of type [...]
- Fix tests/code for php 7.4 #32981 array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead
- [ProxyManagerBridge] Polyfill for unmaintained version #32992 Function ReflectionType::__toString() is deprecated
- [Yaml] PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string given #32862 Uncaught TypeError: abs() expects parameter 1 to be int or float, string given
- [Yaml] PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string given #32862 PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string given
- Skip tests that fatal-error on PHP 7.4 because of missing parent classes #32864 skip tests that are fatal on PHP 7.4 for now - we can work on them later
- Fix using array_key_exists() on objects, it is deprecated in PHP 7.4 twigphp/Twig#3097 fix using array_key_exists() on objects in Twig
- Fix "access array offset on value of type null" PHP 7.4 notices doctrine/orm#7785 Remove imprecise
T_IDENTIFIER
capture groups, leading to simpler token sequences doctrine/annotations#258 Trying to access array offset on value of type [...]
Then:
- Fix deprecations on 4.3 #33000 same on 4.3
- same on 4.4/master
- fix PHP 7.4 breaks resiliency when loading classes with missing parents #32995
I'm opening this issue to ask for help to the community, this is a lot of work that can be split efficiently I believe.