bobbingwide / wordpress-develop-tests

WordPress develop tests
https://develop.wp-a2z.org/oik-plugins/wordpress-develop-tests/
GNU General Public License v2.0
9 stars 4 forks source link

Support PHPUnit 8 #7

Open bobbingwide opened 5 years ago

bobbingwide commented 5 years ago

The current version of PHPUnit is now 8. We need to upgrade some code in order to support this version of PHPUnit. I believe this problem has already been resolved in WordPress. See https://core.trac.wordpress.org/ticket/43218

See also #5 and #6

bobbingwide commented 5 years ago

See https://thephp.cc/news/2019/02/help-my-tests-stopped-working

bobbingwide commented 5 years ago

Looks like we also need to change oik-batch since this implements our own version of WP_UnitTestCase which extends PHPUnit_Framework_TestCase that's been updated. It was updated in PHPUnit 7, but I've skipped a version. Keep going until you don't get messages like this.

Fatal error: Declaration of WP_UnitTestCase::tearDownAfterClass() 
must be compatible with PHPUnit\Framework\TestCase::tearDownAfterClass(): void 
in C:\apache\htdocs\wordpress\wp-content\plugins\oik-batch\tests\testcase.php on line 768
bobbingwide commented 5 years ago

It seems that there are are methods in phpunit\includes files that may need updating. Alternatively, we might be able to survive without loading the files in oik-batch's test\bootstrap.php

Fatal error: Declaration of WP_Test_REST_Controller_Testcase::setUp() 
must be compatible with WP_UnitTestCase::setUp(): void 
in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-develop-tests\phpunit\includes\testcase-rest-controller.php on line 52
bobbingwide commented 5 years ago

I commented out 5 of the files that produced the above message. Then I found I needed to change other oik-batch files that used setUp, tearDown, setUpBeforeClass, tearDownAfterClass etc..