Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-01-29 00:43:23 +00:00
parent bd2cd572aa
commit cfc3b57488
810 changed files with 9893 additions and 8384 deletions
+23 -23
View File
@@ -8,8 +8,8 @@ class Tests_Cache extends WP_UnitTestCase {
function setUp() {
parent::setUp();
// create two cache objects with a shared cache dir
// this simulates a typical cache situation, two separate requests interacting
// Create two cache objects with a shared cache directory.
// This simulates a typical cache situation, two separate requests interacting.
$this->cache =& $this->init_cache();
}
@@ -42,7 +42,7 @@ class Tests_Cache extends WP_UnitTestCase {
$key = __FUNCTION__;
$val = 0;
// you can store zero in the cache
// You can store zero in the cache.
$this->cache->add( $key, $val );
$this->assertEquals( $val, $this->cache->get( $key ) );
}
@@ -52,7 +52,7 @@ class Tests_Cache extends WP_UnitTestCase {
$val = null;
$this->assertTrue( $this->cache->add( $key, $val ) );
// null is converted to empty string
// Null is converted to empty string.
$this->assertEquals( '', $this->cache->get( $key ) );
}
@@ -61,10 +61,10 @@ class Tests_Cache extends WP_UnitTestCase {
$val1 = 'val1';
$val2 = 'val2';
// add $key to the cache
// Add $key to the cache.
$this->assertTrue( $this->cache->add( $key, $val1 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
// $key is in the cache, so reject new calls to add()
// $key is in the cache, so reject new calls to add().
$this->assertFalse( $this->cache->add( $key, $val2 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
}
@@ -74,7 +74,7 @@ class Tests_Cache extends WP_UnitTestCase {
$val = 'val1';
$val2 = 'val2';
// memcached rejects replace() if the key does not exist
// memcached rejects replace() if the key does not exist.
$this->assertFalse( $this->cache->replace( $key, $val ) );
$this->assertFalse( $this->cache->get( $key ) );
$this->assertTrue( $this->cache->add( $key, $val ) );
@@ -88,10 +88,10 @@ class Tests_Cache extends WP_UnitTestCase {
$val1 = 'val1';
$val2 = 'val2';
// memcached accepts set() if the key does not exist
// memcached accepts set() if the key does not exist.
$this->assertTrue( $this->cache->set( $key, $val1 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
// Second set() with same key should be allowed
// Second set() with same key should be allowed.
$this->assertTrue( $this->cache->set( $key, $val2 ) );
$this->assertEquals( $val2, $this->cache->get( $key ) );
}
@@ -107,14 +107,14 @@ class Tests_Cache extends WP_UnitTestCase {
$val = 'val';
$this->cache->add( $key, $val );
// item is visible to both cache objects
// Item is visible to both cache objects.
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->cache->flush();
// If there is no value get returns false.
$this->assertFalse( $this->cache->get( $key ) );
}
// Make sure objects are cloned going to and from the cache
// Make sure objects are cloned going to and from the cache.
function test_object_refs() {
$key = __FUNCTION__ . '_1';
$object_a = new stdClass;
@@ -204,11 +204,11 @@ class Tests_Cache extends WP_UnitTestCase {
$key = __FUNCTION__;
$val = 'val';
// Verify set
// Verify set.
$this->assertTrue( $this->cache->set( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
// Verify successful delete
// Verify successful delete.
$this->assertTrue( $this->cache->delete( $key ) );
$this->assertFalse( $this->cache->get( $key ) );
@@ -219,16 +219,16 @@ class Tests_Cache extends WP_UnitTestCase {
$key = __FUNCTION__;
$val = 'val';
// Verify set
// Verify set.
$this->assertTrue( wp_cache_set( $key, $val ) );
$this->assertEquals( $val, wp_cache_get( $key ) );
// Verify successful delete
// Verify successful delete.
$this->assertTrue( wp_cache_delete( $key ) );
$this->assertFalse( wp_cache_get( $key ) );
// wp_cache_delete() does not have a $force method.
// Delete returns (bool) true when key is not set and $force is true
// Delete returns (bool) true when key is not set and $force is true.
// $this->assertTrue( wp_cache_delete( $key, 'default', true ) );
$this->assertFalse( wp_cache_delete( $key, 'default' ) );
@@ -254,7 +254,7 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->switch_to_blog( get_current_blog_id() );
$this->assertEquals( $val2, $this->cache->get( $key ) );
} else {
// Multisite should have separate per-blog caches
// Multisite should have separate per-blog caches.
$this->assertTrue( $this->cache->set( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->cache->switch_to_blog( 999 );
@@ -269,7 +269,7 @@ class Tests_Cache extends WP_UnitTestCase {
$this->assertEquals( $val, $this->cache->get( $key ) );
}
// Global group
// Global group.
$this->assertTrue( $this->cache->set( $key, $val, 'global-cache-test' ) );
$this->assertEquals( $val, $this->cache->get( $key, 'global-cache-test' ) );
$this->cache->switch_to_blog( 999 );
@@ -287,7 +287,7 @@ class Tests_Cache extends WP_UnitTestCase {
global $wp_object_cache;
if ( wp_using_ext_object_cache() ) {
// External caches will contain property values that contain non-matching resource IDs
// External caches will contain property values that contain non-matching resource IDs.
$this->assertInstanceOf( 'WP_Object_Cache', $wp_object_cache );
} else {
$this->assertEquals( $wp_object_cache, $new_blank_cache_object );
@@ -301,18 +301,18 @@ class Tests_Cache extends WP_UnitTestCase {
$fake_key = 'my-fake-key';
// Save the first value to cache and verify
// Save the first value to cache and verify.
wp_cache_set( $key, $val1 );
$this->assertEquals( $val1, wp_cache_get( $key ) );
// Replace the value and verify
// Replace the value and verify.
wp_cache_replace( $key, $val2 );
$this->assertEquals( $val2, wp_cache_get( $key ) );
// Non-existant key should fail
// Non-existant key should fail.
$this->assertFalse( wp_cache_replace( $fake_key, $val1 ) );
// Make sure $fake_key is not stored
// Make sure $fake_key is not stored.
$this->assertFalse( wp_cache_get( $fake_key ) );
}
}