In PHP 8.2 dynamic property declaring is deprecated (doc).
When Mocking classes that are unavailable (ex. WP, WP_Post) PHP 8.2 will throw a "Creation of dynamic property...is deprecated" error, causing tests to fail.
There were 2 errors:
1) WP_Mock\Tests\Unit\WP_Mock\Traits\MockWordPressObjectsTraitTest::testCanMockWordPressPost
Creation of dynamic property Mockery_2__WP_Post::$ID is deprecated
/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:45
/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:43
/Users/rneudorf/Projects/godaddy/wp_mock/tests/Unit/WP_Mock/Traits/MockWordPressObjectsTraitTest.php:50
2) WP_Mock\Tests\Unit\WP_Mock\Traits\MockWordPressObjectsTraitTest::testCanMockWordPressInstance
Creation of dynamic property Mockery_3__WP::$query_vars is deprecated
/Users/rneudorf/Projects/godaddy/wp_mock/php/WP_Mock/Traits/MockWordPressObjectsTrait.php:61
/Users/rneudorf/Projects/godaddy/wp_mock/tests/Unit/WP_Mock/Traits/MockWordPressObjectsTraitTest.php:73
Bug report
In PHP 8.2 dynamic property declaring is deprecated (doc).
When Mocking classes that are unavailable (ex.
WP, WP_Post
) PHP 8.2 will throw a "Creation of dynamic property...is deprecated" error, causing tests to fail.Related
wp-test-utils
introduced a helper method: https://github.com/Yoast/wp-test-utils/pull/40Replication steps
Run
vendor/bin/phpunit
under PHP 8.2.The following tests fail:
Expected behavior
All tests pass.