mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 14:44:37 +00:00
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:
@@ -6,19 +6,19 @@
|
||||
class Tests_Cache extends WP_UnitTestCase {
|
||||
public $cache = null;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
// Create two cache objects with a shared cache directory.
|
||||
// This simulates a typical cache situation, two separate requests interacting.
|
||||
$this->cache =& $this->init_cache();
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
$this->flush_cache();
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function &init_cache() {
|
||||
private function &init_cache() {
|
||||
global $wp_object_cache;
|
||||
$cache_class = get_class( $wp_object_cache );
|
||||
$cache = new $cache_class();
|
||||
@@ -26,11 +26,11 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
function test_miss() {
|
||||
public function test_miss() {
|
||||
$this->assertFalse( $this->cache->get( 'test_miss' ) );
|
||||
}
|
||||
|
||||
function test_add_get() {
|
||||
public function test_add_get() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@@ -38,7 +38,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_add_get_0() {
|
||||
public function test_add_get_0() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20004
|
||||
*/
|
||||
function test_add_get_null() {
|
||||
public function test_add_get_null() {
|
||||
$key = __FUNCTION__;
|
||||
$val = null;
|
||||
|
||||
@@ -62,7 +62,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 20004
|
||||
*/
|
||||
function test_add_get_false() {
|
||||
public function test_add_get_false() {
|
||||
$key = __FUNCTION__;
|
||||
$val = false;
|
||||
|
||||
@@ -71,7 +71,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_add() {
|
||||
public function test_add() {
|
||||
$key = __FUNCTION__;
|
||||
$val1 = 'val1';
|
||||
$val2 = 'val2';
|
||||
@@ -84,7 +84,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val1, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_replace() {
|
||||
public function test_replace() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val1';
|
||||
$val2 = 'val2';
|
||||
@@ -98,7 +98,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_set() {
|
||||
public function test_set() {
|
||||
$key = __FUNCTION__;
|
||||
$val1 = 'val1';
|
||||
$val2 = 'val2';
|
||||
@@ -111,7 +111,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_flush() {
|
||||
public function test_flush() {
|
||||
global $_wp_using_ext_object_cache;
|
||||
|
||||
if ( $_wp_using_ext_object_cache ) {
|
||||
@@ -130,7 +130,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Make sure objects are cloned going to and from the cache.
|
||||
function test_object_refs() {
|
||||
public function test_object_refs() {
|
||||
$key = __FUNCTION__ . '_1';
|
||||
$object_a = new stdClass;
|
||||
$object_a->foo = 'alpha';
|
||||
@@ -152,7 +152,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 'bravo', $object_a->foo );
|
||||
}
|
||||
|
||||
function test_incr() {
|
||||
public function test_incr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( $this->cache->incr( $key ) );
|
||||
@@ -165,7 +165,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 3, $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_incr() {
|
||||
public function test_wp_cache_incr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( wp_cache_incr( $key ) );
|
||||
@@ -178,7 +178,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 3, wp_cache_get( $key ) );
|
||||
}
|
||||
|
||||
function test_decr() {
|
||||
public function test_decr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( $this->cache->decr( $key ) );
|
||||
@@ -198,7 +198,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21327
|
||||
*/
|
||||
function test_wp_cache_decr() {
|
||||
public function test_wp_cache_decr() {
|
||||
$key = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( wp_cache_decr( $key ) );
|
||||
@@ -215,7 +215,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( 0, wp_cache_get( $key ) );
|
||||
}
|
||||
|
||||
function test_delete() {
|
||||
public function test_delete() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@@ -230,7 +230,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertFalse( $this->cache->delete( $key, 'default' ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_delete() {
|
||||
public function test_wp_cache_delete() {
|
||||
$key = __FUNCTION__;
|
||||
$val = 'val';
|
||||
|
||||
@@ -249,7 +249,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_cache_delete( $key, 'default' ) );
|
||||
}
|
||||
|
||||
function test_switch_to_blog() {
|
||||
public function test_switch_to_blog() {
|
||||
if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) {
|
||||
$this->markTestSkipped( 'This test requires a switch_to_blog() method on the cache object.' );
|
||||
}
|
||||
@@ -295,7 +295,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) );
|
||||
}
|
||||
|
||||
function test_wp_cache_init() {
|
||||
public function test_wp_cache_init() {
|
||||
$new_blank_cache_object = new WP_Object_Cache();
|
||||
wp_cache_init();
|
||||
|
||||
@@ -309,7 +309,7 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_wp_cache_replace() {
|
||||
public function test_wp_cache_replace() {
|
||||
$key = 'my-key';
|
||||
$val1 = 'first-val';
|
||||
$val2 = 'second-val';
|
||||
|
||||
Reference in New Issue
Block a user