Skip to content

Commit f2f6c98

Browse files
committed
use trait
1 parent 5769a97 commit f2f6c98

9 files changed

+33
-21
lines changed

Diff for: tests/bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ function _manually_load_plugin() {
4343
require "{$_tests_dir}/includes/bootstrap.php";
4444

4545
// Load base provider test class.
46-
require_once __DIR__ . '/phpunit/class-task-provider-test-abstract.php';
46+
require_once __DIR__ . '/phpunit/class-task-provider-test-trait.php';

Diff for: tests/phpunit/class-task-provider-test-abstract.php renamed to tests/phpunit/class-task-provider-test-trait.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
/**
1414
* Task provider test case.
1515
*/
16-
abstract class Task_Provider_Test_Abstract extends \WP_UnitTestCase {
17-
18-
/**
19-
* The task provider ID.
20-
*
21-
* @var string
22-
*/
23-
protected $task_provider_id;
16+
trait Task_Provider_Test_Trait {
2417

2518
/**
2619
* The task provider instance.
@@ -41,7 +34,7 @@ abstract class Task_Provider_Test_Abstract extends \WP_UnitTestCase {
4134
*
4235
* @return void
4336
*/
44-
public static function setUpBeforeClass(): void {
37+
public static function setUpBeforeClass(): void { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
4538
// Set the current user to the admin user.
4639
wp_set_current_user( 1 );
4740
}
@@ -51,7 +44,7 @@ public static function setUpBeforeClass(): void {
5144
*
5245
* @return void
5346
*/
54-
public static function tearDownAfterClass(): void {
47+
public static function tearDownAfterClass(): void { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
5548
// Reset the current user.
5649
wp_set_current_user( 0 );
5750
}

Diff for: tests/phpunit/test-class-core-blogdescription.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Core blogdescription test case.
1212
*/
13-
class Core_Blogdescription_Test extends Task_Provider_Test_Abstract {
13+
class Core_Blogdescription_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait;
1416

1517
/**
1618
* The task provider ID.

Diff for: tests/phpunit/test-class-core-permalink-structure.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
/**
1111
* Core permalink structure test case.
1212
*/
13-
class Core_Permalink_Structure_Test extends Task_Provider_Test_Abstract {
13+
class Core_Permalink_Structure_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait {
16+
setUpBeforeClass as public parentSetUpBeforeClass;
17+
tearDownAfterClass as public parentTearDownAfterClass;
18+
}
1419

1520
/**
1621
* The task provider ID.
@@ -25,7 +30,7 @@ class Core_Permalink_Structure_Test extends Task_Provider_Test_Abstract {
2530
* @return void
2631
*/
2732
public static function setUpBeforeClass(): void {
28-
parent::setUpBeforeClass();
33+
self::parentSetUpBeforeClass();
2934

3035
\update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
3136
}
@@ -36,7 +41,7 @@ public static function setUpBeforeClass(): void {
3641
* @return void
3742
*/
3843
public static function tearDownAfterClass(): void {
39-
parent::tearDownAfterClass();
44+
self::parentTearDownAfterClass();
4045

4146
\update_option( 'permalink_structure', '' );
4247
}

Diff for: tests/phpunit/test-class-core-siteicon.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Core siteicon test case.
1212
*/
13-
class Core_Siteicon_Test extends Task_Provider_Test_Abstract {
13+
class Core_Siteicon_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait;
1416

1517
/**
1618
* The task provider ID.

Diff for: tests/phpunit/test-class-disable-comments.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Settings saved test case.
1212
*/
13-
class Disable_Comments_Test extends Task_Provider_Test_Abstract {
13+
class Disable_Comments_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait;
1416

1517
/**
1618
* The task provider ID.

Diff for: tests/phpunit/test-class-rename-uncategorized-category.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Rename Uncategorized Category test case.
1212
*/
13-
class Rename_Uncategorized_Category_Test extends Task_Provider_Test_Abstract {
13+
class Rename_Uncategorized_Category_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait;
1416

1517
/**
1618
* The task provider ID.

Diff for: tests/phpunit/test-class-search-engine-visibility.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
/**
1111
* Settings saved test case.
1212
*/
13-
class Search_Engine_Visibility_Test extends Task_Provider_Test_Abstract {
13+
class Search_Engine_Visibility_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait {
16+
setUpBeforeClass as public parentSetUpBeforeClass;
17+
}
1418

1519
/**
1620
* The task provider ID.
@@ -25,7 +29,7 @@ class Search_Engine_Visibility_Test extends Task_Provider_Test_Abstract {
2529
* @return void
2630
*/
2731
public static function setUpBeforeClass(): void {
28-
parent::setUpBeforeClass();
32+
self::parentSetUpBeforeClass();
2933

3034
\update_option( 'blog_public', 0 );
3135
}

Diff for: tests/phpunit/test-class-settings-saved.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Settings saved test case.
1212
*/
13-
class Settings_Saved_Test extends Task_Provider_Test_Abstract {
13+
class Settings_Saved_Test extends \WP_UnitTestCase {
14+
15+
use Task_Provider_Test_Trait;
1416

1517
/**
1618
* The task provider ID.

0 commit comments

Comments
 (0)