Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-11-04 15:22:47 +00:00
parent 80380cd374
commit 40ac5de838
327 changed files with 3656 additions and 3969 deletions
+5 -5
View File
@@ -1,28 +1,28 @@
<?php
class TestFactoryFor extends WP_UnitTestCase {
function set_up() {
public function set_up() {
parent::set_up();
$this->category_factory = new WP_UnitTest_Factory_For_Term( null, 'category' );
}
function test_create_creates_a_category() {
public function test_create_creates_a_category() {
$id = $this->category_factory->create();
$this->assertTrue( (bool) get_term_by( 'id', $id, 'category' ) );
}
function test_get_object_by_id_gets_an_object() {
public function test_get_object_by_id_gets_an_object() {
$id = $this->category_factory->create();
$this->assertTrue( (bool) $this->category_factory->get_object_by_id( $id ) );
}
function test_get_object_by_id_gets_an_object_with_the_same_name() {
public function test_get_object_by_id_gets_an_object_with_the_same_name() {
$id = $this->category_factory->create( array( 'name' => 'Boo' ) );
$object = $this->category_factory->get_object_by_id( $id );
$this->assertSame( 'Boo', $object->name );
}
function test_the_taxonomy_argument_overrules_the_factory_taxonomy() {
public function test_the_taxonomy_argument_overrules_the_factory_taxonomy() {
$term_factory = new WP_UnitTest_Factory_For_term( null, 'category' );
$id = $term_factory->create( array( 'taxonomy' => 'post_tag' ) );
$term = get_term( $id, 'post_tag' );
+4 -4
View File
@@ -7,7 +7,7 @@ class Tests_TestHelpers extends WP_UnitTestCase {
/**
* @ticket 30522
*/
function data_assertSameSets() {
public function data_assertSameSets() {
return array(
array(
array( 1, 2, 3 ), // Test expected.
@@ -51,7 +51,7 @@ class Tests_TestHelpers extends WP_UnitTestCase {
* @dataProvider data_assertSameSets
* @ticket 30522
*/
function test_assertSameSets( $expected, $actual, $exception ) {
public function test_assertSameSets( $expected, $actual, $exception ) {
if ( $exception ) {
try {
$this->assertSameSets( $expected, $actual );
@@ -68,7 +68,7 @@ class Tests_TestHelpers extends WP_UnitTestCase {
/**
* @ticket 30522
*/
function data_assertSameSetsWithIndex() {
public function data_assertSameSetsWithIndex() {
return array(
array(
array( 1, 2, 3 ), // Test expected.
@@ -207,7 +207,7 @@ class Tests_TestHelpers extends WP_UnitTestCase {
* @dataProvider data_assertSameSetsWithIndex
* @ticket 30522
*/
function test_assertSameSetsWithIndex( $expected, $actual, $exception ) {
public function test_assertSameSetsWithIndex( $expected, $actual, $exception ) {
if ( $exception ) {
try {
$this->assertSameSetsWithIndex( $expected, $actual );