Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
291 stars 205 forks source link

Tests failing with PHP 7 #458

Closed philipjohn closed 3 years ago

philipjohn commented 6 years ago

PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /tmp/wordpress-tests-lib/includes/testcase.php on line 15

https://travis-ci.org/Automattic/Co-Authors-Plus/jobs/291114352

Tests are passing in 5.6 but it looks like something to do with our setup means that the testing framework isn't properly available in PHP 7. It's probably an old code problem!

mjangda commented 6 years ago

This is likely related: https://core.trac.wordpress.org/changeset/40547 (we probably need to add the compat layer).

philipjohn commented 6 years ago

Fixed by #482

jeherve commented 6 years ago

Recent PRs appear to have the same problem. Would it make sense to move to WP 4.7 instead of WP 4.6 in the tests? I believe that may solve the problem, as per this ticket: https://core.trac.wordpress.org/ticket/39822

WP 4.7 was released in December 2016, so maybe it is fair to test for that version now, 2 major releases later?

TheCrowned commented 6 years ago

I am running tests with WP latest (at this time, 4.9.6) and PHP 7.2.5, and everything runs smoothly. Is this still an issue?

nielslange commented 3 years ago

When running the unit tests using WP 5.3 and WP 5.7 with PHP 7.4, I see the following warnings and errors:

// Running PHPUnit using WordPress 5.3
$ phpunit
Installing...
Installing network...
Running as multisite...
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

  Warning - The configuration file did not pass validation!
  The following problems have been detected:

  Line 13:
  - Element 'testsuite': The attribute 'name' is required but missing.

  Test results may not be as expected.

................................................................. 65 / 98 ( 66%)
............................FF...                                 98 / 98 (100%)

Time: 8.94 seconds, Memory: 32.00 MB

There were 2 failures:

1) Test_Template_Tags::test_coauthors_get_avatar_default
Failed asserting that 1 matches expected 0.

/Users/nielslange/wpvip/plugins/Co-Authors-Plus/tests/test-template-tags.php:991

2) Test_Template_Tags::test_coauthors_get_avatar_when_guest_author
Failed asserting that 1 matches expected 0.

/Users/nielslange/wpvip/plugins/Co-Authors-Plus/tests/test-template-tags.php:1010

FAILURES!
Tests: 98, Assertions: 362, Failures: 2.

// Running PHPUnit using WordPress 5.7
$ phpunit
Installing...
Installing network...
Running as multisite...
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

  Warning - The configuration file did not pass validation!
  The following problems have been detected:

  Line 13:
  - Element 'testsuite': The attribute 'name' is required but missing.

  Test results may not be as expected.

...........E..................................................... 65 / 98 ( 66%)
.............................E...                                 98 / 98 (100%)

Time: 8.72 seconds, Memory: 36.00 MB

There were 2 errors:

1) Test_CoAuthors_Guest_Authors::test_get_guest_author_thumbnail
Trying to access array offset on value of type bool

/private/tmp/wordpress/wp-content/themes/twentytwentyone/inc/template-functions.php:436
/private/tmp/wordpress/wp-includes/class-wp-hook.php:292
/private/tmp/wordpress/wp-includes/plugin.php:212
/private/tmp/wordpress/wp-includes/media.php:1090
/private/tmp/wordpress/wp-includes/post.php:7404
/Users/nielslange/wpvip/plugins/Co-Authors-Plus/tests/test-coauthors-guest-authors.php:136

2) Test_Template_Tags::test_coauthors_get_avatar_when_guest_author
Trying to access array offset on value of type bool

/private/tmp/wordpress/wp-content/themes/twentytwentyone/inc/template-functions.php:436
/private/tmp/wordpress/wp-includes/class-wp-hook.php:292
/private/tmp/wordpress/wp-includes/plugin.php:212
/private/tmp/wordpress/wp-includes/media.php:1090
/private/tmp/wordpress/wp-includes/post.php:7404
/Users/nielslange/wpvip/plugins/Co-Authors-Plus/tests/test-template-tags.php:1020

ERRORS!
Tests: 98, Assertions: 360, Errors: 2.