Skip to content

Commit 4813ef8

Browse files
rodrigoprimojrfnl
authored andcommitted
Tests: use standardized fixture methods
As support for PHPUnit < 8.0 will now be dropped, we no longer need to use the `@before`/`@after`[Class] annotations for fixture methods and can revert back to using the standard PHPUnit `setUp|tearDown[BeforeClass]()` fixture methods (with a `void` return type).
1 parent baae3fd commit 4813ef8

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

WordPress/Tests/DB/RestrictedClassesUnitTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ final class RestrictedClassesUnitTest extends AbstractSniffUnitTest {
3232
* Note: as that class extends the abstract FunctionRestrictions class, that's
3333
* where we are passing the parameters to.
3434
*
35-
* @before
36-
*
3735
* @return void
3836
*/
39-
protected function enhanceGroups() {
37+
protected function setUp(): void {
38+
parent::setUp();
4039
AbstractFunctionRestrictionsSniff::$unittest_groups = array(
4140
'test' => array(
4241
'type' => 'error',
@@ -52,11 +51,9 @@ protected function enhanceGroups() {
5251
/**
5352
* Reset the $groups property.
5453
*
55-
* @after
56-
*
5754
* @return void
5855
*/
59-
protected function resetGroups() {
56+
protected function tearDown(): void {
6057
AbstractFunctionRestrictionsSniff::$unittest_groups = array();
6158
parent::tearDown();
6259
}

WordPress/Tests/DB/RestrictedFunctionsUnitTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ final class RestrictedFunctionsUnitTest extends AbstractSniffUnitTest {
2727
* Add a number of extra restricted functions to unit test the abstract
2828
* AbstractFunctionRestrictionsSniff class.
2929
*
30-
* @before
31-
*
3230
* @return void
3331
*/
34-
protected function enhanceGroups() {
32+
protected function setUp(): void {
3533
parent::setUp();
36-
3734
AbstractFunctionRestrictionsSniff::$unittest_groups = array(
3835
'test-empty-functions-array' => array(
3936
'type' => 'error',
@@ -52,11 +49,9 @@ protected function enhanceGroups() {
5249
/**
5350
* Reset the $groups property.
5451
*
55-
* @after
56-
*
5752
* @return void
5853
*/
59-
protected function resetGroups() {
54+
protected function tearDown(): void {
6055
AbstractFunctionRestrictionsSniff::$unittest_groups = array();
6156
parent::tearDown();
6257
}

0 commit comments

Comments
 (0)