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

Command icon 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:

Comments

neclimdul created an issue. See original summary.

neclimdul’s picture

Priority: Normal » Minor
Status: Active » Needs review

This should be enough to make things work.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense to me, I guess the -1 was assuming that the output directory is clean, but outside of Drupal CI that is not guaranteed.

mondrake’s picture

Thanks, 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.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 362fc2d and pushed to 10.0.x. Thanks!

  • alexpott committed 362fc2d on 10.0.x
    Issue #3281175 by neclimdul: PhpUnitCliTest fails outside of CI
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.