Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP unit tests with PHP 8 #1278

Closed
kasparsd opened this issue Aug 31, 2021 · 2 comments · Fixed by #1511
Closed

Fix PHP unit tests with PHP 8 #1278

kasparsd opened this issue Aug 31, 2021 · 2 comments · Fixed by #1511
Labels
compatibility PHP or WordPress version compatibility related issue tooling Development and deployment tooling improvements
Milestone

Comments

@kasparsd
Copy link
Contributor

Feature Request

Make the phpunit tests work with PHP 8. It appears that the php-token-stream library referenced by phpunit isn't compatible with PHP 8:

Stack trace:
#0 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-token-stream/src/Token/Stream.php(118): PHP_Token_Stream->scan('<?php\n/**\n * Al...')
#1 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(764): PHP_Token_Stream->__construct('<?php\n/**\n * Al...')
#2 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(673): SebastianBergmann\CodeCoverage\CodeCoverage->getLinesToBeIgnored('/var/www/html/w...')
#3 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(321): SebastianBergmann\CodeCoverage\CodeCoverage->applyIgnoredLinesFilter(Array)
#4 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(1104): SebastianBergmann\CodeCoverage\CodeCoverage->append(Array, 'UNCOVERED_FILES...')
#5 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(256): SebastianBergmann\CodeCoverage\CodeCoverage->initializeData()
#6 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/Framework/TestResult.php(650): SebastianBergmann\CodeCoverage\CodeCoverage->start(Object(WP_Stream\Test_Alert_Trigger_Action))
#7 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/Framework/TestCase.php(868): PHPUnit_Framework_TestResult->run(Object(WP_Stream\Test_Alert_Trigger_Action))
#8 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(733): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#9 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(733): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#10 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(517): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#11 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/TextUI/Command.php(186): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array, true)
#12 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/src/TextUI/Command.php(116): PHPUnit_TextUI_Command->run(Array, true)
#13 /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/phpunit/phpunit(52): PHPUnit_TextUI_Command::main()
#14 {main}
  thrown in /var/www/html/wp-content/plugins/stream-src/vendor/phpunit/php-token-stream/src/Token/Stream.php on line 189
@kasparsd kasparsd added the compatibility PHP or WordPress version compatibility related issue label Aug 31, 2021
@kasparsd kasparsd added this to the PHP 8 Compatibility milestone Jan 10, 2023
@delawski delawski modified the milestones: PHP 8 Compatibility, 4.0.1 Jul 16, 2024
@delawski
Copy link
Contributor

Let's double check if this is fixed by #1423.

@delawski delawski added the tooling Development and deployment tooling improvements label Jul 16, 2024
@tharsheblows
Copy link
Contributor

@delawski I've tested this by building the image with
docker compose build --build-arg PHP_VERSION=8.2 --build-arg XDEBUG_VERSION=3.3.2
then running the tests.

The output is noisy even after updating phpunit.xml to ignore deprecations in the tests.

All of the tests run bar one but it is, I believe, a test error rather than an error in the plugin code.

There was 1 error:

  1. WP_Stream\Test_WP_Stream_Connector_Media::test_callback_wp_save_image_editor_file
    TypeError: imageinterlace(): Argument User context always (incorrectly) assumes that $current_user is only updating their own profile #1 ($image) must be of type GdImage, null given

/var/www/html/wp/wp-includes/class-wp-image-editor-gd.php:516
/var/www/html/wp/wp-includes/class-wp-image-editor-gd.php:472
/var/www/html/wp/wp-admin/includes/image-edit.php:456
/var/www/html/wp-content/plugins/stream-src/tests/tests/connectors/test-class-connector-media.php:224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility PHP or WordPress version compatibility related issue tooling Development and deployment tooling improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants