- Issue created by @scott_euser
- First commit to issue fork.
- 🇮🇳India immaculatexavier
Done the below Fixes for PHPUnit 10:
- Removed usage of $this in static providerCanLoginWithoutTfa().
- Replaced $this->equalTo() with Assert::equalTo() from PHPUnit\Framework\Assert.
- Replaced $this->stringContains() with Assert::stringContains().
- Used UnitTestCase::createStub(TranslationInterface::class) for generating translation stubs inside static context.
Needs review.
- 🇬🇧United Kingdom scott_euser
Thanks! I think still somehow its too strict though. E.g. if I run
ddev exec -d /var/www/html "./vendor/bin/phpunit -c ./core/phpunit.xml.dist ./modules/contrib/tfa/tests/src/Unit/TfaContextTest.php"
At:
/var/www/html/modules/contrib/tfa/tests/src/Unit/TfaContextTest.php:430
I get false errors like
- 'stringTranslation' => MockObject_TranslationInterface_00404523 Object #398 ( - '__phpunit_state' => PHPUnit\Framework\MockObject\TestDoubleState Object #433 ( + 'stringTranslation' => MockObject_TranslationInterface_3106f881 Object #2004 ( + '__phpunit_state' => PHPUnit\Framework\MockObject\TestDoubleState Object #2006 (
Which are nearly the same and for the purposes of the test should be considered the same I believe
- 🇺🇸United States cmlara
-c ./core/phpunit.xml.dist
I would suggest to attempt running without the core config to see if this helps your local testing.
Is this perhaps for a diffrent version of PHPUnit? We do us PHPUnit 10 currently with I belive Drupal Core 11.2 bumping us to 11.2 once GitLab templates updates the target core version.We intentionally use
--no-configuration
in GitLabCi to resolve other issues that core is excessively strict about (such as 3rd party calling deprecated code) that do not apply to contrib and are generally considered the responsibility of PHPStan (core runs L2, we run L9)Since these were written I did learn there is a method (register translation service in global container mock) to allow string casts to work which would have possibly allowed me to compare straight strings instead of the translatable object to allow for simpler comparisons.
We do need to convert to static as I believe it is either PHPUnit 11.5 or 12 that will make that mandatory (this one was missed somewhere in the process) .
Remaining comment of failures from #5 would need to investigate. I do believe I have seen some asserts will be changing location in PHPUnit 12.
I see the following in the test run window:
OK, but there were issues! Tests: 197, Assertions: 1648, Warnings: 1, PHPUnit Deprecations: 12.
IIRC core config fail on deprecation while we would desire not to (items that will need to be changed in the future)