Problem/Motivation
The problem is with this assertion.
$this->assertStringContainsString('Drupal_Tests_image_Functional_ImageDimensionsTest-1', $process->getOutput());
Because the number attached to the test is based on files on the filesystem, if you've ever run a test its very unlikely to start with a one. and so the output will fail.
For example, my unit test suite run had this failure.
2) Drupal\Tests\Core\Test\PhpUnitCliTest::testFunctionalTestDebugHtmlOutput
Failed asserting that 'PHPUnit 9.5.20 #StandWithUkraine\n
\n
Runtime: PHP 8.1.2\n
Configuration: /app/core/phpunit.xml.dist\n
\n
Testing Drupal\Tests\image\Functional\ImageDimensionsTest\n
. 1 / 1 (100%)\n
\n
Time: 00:07.274, Memory: 10.00 MB\n
\n
OK (1 test, 60 assertions)\n
\n
HTML output was generated\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-51-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-52-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-53-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-54-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-55-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-56-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-57-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-58-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-59-73418261.html\n
http://d10.lndo.site/sites/simpletest/browser_output/Drupal_Tests_image_Functional_ImageDimensionsTest-60-73418261.html\n
' contains "Drupal_Tests_image_Functional_ImageDimensionsTest-1".
Steps to reproduce
This is one of the sometimes frustrating unit tests that require more then unit tests to function. I only mention this because you'll need a test setup that can run functional tests to run this unit tests and recreate the failure. With the appropriate collection of environment variables though you can run this to recreate it.
php ./vendor/bin/phpunit -c core core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php
php ./vendor/bin/phpunit -c core core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php
php ./vendor/bin/phpunit -c core core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php
The third run should create results outside the teens causing the failure.
Proposed resolution
Remove the -1 from the assertion? I'm not sure what the intention was but I don't think its needed.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3281175
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3281175-phpunitclitest-fails-outside
changes, plain diff MR !2291
Comments
Comment #3
neclimdulThis should be enough to make things work.
Comment #4
longwaveMakes sense to me, I guess the
-1was assuming that the output directory is clean, but outside of Drupal CI that is not guaranteed.Comment #5
mondrakeThanks, I wrote that test - no particular thinking behind that, just not the best c/p ever…
Actually I think someone commented sometimes that this shoud be a functional test, not a unit one… but not here, right.
Comment #6
alexpottCommitted 362fc2d and pushed to 10.0.x. Thanks!