Problem/Motivation

Working on #3031379: Add a new test type to do real update testing we end up running tests from PHPUnit a lot.

PHPUnit shows us an error like this:

$ ./vendor/bin/phpunit -c core --testsuite unit

[...]

...........................................................  2655 / 17890 ( 14%)
...........................................................  2714 / 17890 ( 15%)
...........................................................  2773 / 17890 ( 15%)
...........................................................  2832 / 17890 ( 15%)
......................................
THE ERROR HANDLER HAS CHANGED!

One of the unfortunate things about symfony/phpunit-bridge is that it doesn't tell us very much about what happened here. Watching the PHP error log, we see:

PHP Fatal error:  Cannot redeclare drupal_valid_test_ua() (previously declared in /Users/paul/projects/drupal/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php:249) in /Users/paul/projects/drupal/core/includes/bootstrap.inc on line 648

Sure enough, fixing this error so that we don't redeclare drupal_valid_test_ua() in the test makes the error handler error go away.

The cause here is likely similar to #3052625: DeprecationListenerTrait croaks on tests with no results in that the test that has a fatal does not have any results, so the listener is unable to register other error handlers properly.

Proposed resolution

Don't redeclare drupal_valid_test_ua() in DrupalKernelTest.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#12 3054649-12.patch455 bytesalexpott
#9 interdiff.txt722 bytesmile23
#9 3054649_8.patch1.67 KBmile23
#2 3054649_2.patch1.27 KBmile23

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Issue summary: View changes
Status: Active » Needs review
Related issues: +#3052625: DeprecationListenerTrait croaks on tests with no results
StatusFileSize
new1.27 KB

A patch.

mile23’s picture

Issue summary: View changes
mile23’s picture

Results: Test Result (1,488 failures / +1488)

Unrelated? I hope?

Status: Needs review » Needs work

The last submitted patch, 2: 3054649_2.patch, failed testing. View results

berdir’s picture

Does #3038513: Move drupal_generate_test_ua() into the test system fix this too? I guess we can't backport that, though.

mile23’s picture

If #3038513: Move drupal_generate_test_ua() into the test system is really scoped for D9 then it won't fix it before then.

berdir’s picture

That's just a regular deprecation issue, the only D9 thing is that the old methods will be removed then.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB
new722 bytes

#2 failed because testInitializeSettings() says @requires function apcu_fetch, which ended up as skipped on my machine. Therefore I didn't notice it.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

This makes sense to me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Hmmm... so the question here is what is defining or including bootstrap.inc elsewhere. Imo we should not be doing an include here without running all the tests in a separate process.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new455 bytes

This fixes things in a way that \Drupal\Tests\Core\ClassLoader\ClassLoaderTest doesn't affect the loaded code for all unit tests that come after it.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

That seems like a good idea, confirmed that it fixes the error. Additionally, this is a legacy test, so it will go away in D9.

catch’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.8.x and 8.7.x, thanks!

  • catch committed 945fbea on 8.8.x
    Issue #3054649 by Mile23, alexpott: DrupalKernelTest results in ERROR...

  • catch committed 95d1d36 on 8.7.x
    Issue #3054649 by Mile23, alexpott: DrupalKernelTest results in ERROR...
mile23’s picture

It looks like 8.7.x didn't have this test before it was pushed, resulting in a branch fail: https://www.drupal.org/pift-ci-job/1334211

  • alexpott committed f2117cd on 8.7.x
    Revert "Issue #3054649 by Mile23, alexpott: DrupalKernelTest results in...

Status: Fixed » Closed (fixed)

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