Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/cache.php

    r46586 r47122  
    99    function setUp() {
    1010        parent::setUp();
    11         // create two cache objects with a shared cache dir
    12         // this simulates a typical cache situation, two separate requests interacting
     11        // Create two cache objects with a shared cache directory.
     12        // This simulates a typical cache situation, two separate requests interacting.
    1313        $this->cache =& $this->init_cache();
    1414    }
     
    4343        $val = 0;
    4444
    45         // you can store zero in the cache
     45        // You can store zero in the cache.
    4646        $this->cache->add( $key, $val );
    4747        $this->assertEquals( $val, $this->cache->get( $key ) );
     
    5353
    5454        $this->assertTrue( $this->cache->add( $key, $val ) );
    55         // null is converted to empty string
     55        // Null is converted to empty string.
    5656        $this->assertEquals( '', $this->cache->get( $key ) );
    5757    }
     
    6262        $val2 = 'val2';
    6363
    64         // add $key to the cache
     64        // Add $key to the cache.
    6565        $this->assertTrue( $this->cache->add( $key, $val1 ) );
    6666        $this->assertEquals( $val1, $this->cache->get( $key ) );
    67         // $key is in the cache, so reject new calls to add()
     67        // $key is in the cache, so reject new calls to add().
    6868        $this->assertFalse( $this->cache->add( $key, $val2 ) );
    6969        $this->assertEquals( $val1, $this->cache->get( $key ) );
     
    7575        $val2 = 'val2';
    7676
    77         // memcached rejects replace() if the key does not exist
     77        // memcached rejects replace() if the key does not exist.
    7878        $this->assertFalse( $this->cache->replace( $key, $val ) );
    7979        $this->assertFalse( $this->cache->get( $key ) );
     
    8989        $val2 = 'val2';
    9090
    91         // memcached accepts set() if the key does not exist
     91        // memcached accepts set() if the key does not exist.
    9292        $this->assertTrue( $this->cache->set( $key, $val1 ) );
    9393        $this->assertEquals( $val1, $this->cache->get( $key ) );
    94         // Second set() with same key should be allowed
     94        // Second set() with same key should be allowed.
    9595        $this->assertTrue( $this->cache->set( $key, $val2 ) );
    9696        $this->assertEquals( $val2, $this->cache->get( $key ) );
     
    108108
    109109        $this->cache->add( $key, $val );
    110         // item is visible to both cache objects
     110        // Item is visible to both cache objects.
    111111        $this->assertEquals( $val, $this->cache->get( $key ) );
    112112        $this->cache->flush();
     
    115115    }
    116116
    117     // Make sure objects are cloned going to and from the cache
     117    // Make sure objects are cloned going to and from the cache.
    118118    function test_object_refs() {
    119119        $key           = __FUNCTION__ . '_1';
     
    205205        $val = 'val';
    206206
    207         // Verify set
     207        // Verify set.
    208208        $this->assertTrue( $this->cache->set( $key, $val ) );
    209209        $this->assertEquals( $val, $this->cache->get( $key ) );
    210210
    211         // Verify successful delete
     211        // Verify successful delete.
    212212        $this->assertTrue( $this->cache->delete( $key ) );
    213213        $this->assertFalse( $this->cache->get( $key ) );
     
    220220        $val = 'val';
    221221
    222         // Verify set
     222        // Verify set.
    223223        $this->assertTrue( wp_cache_set( $key, $val ) );
    224224        $this->assertEquals( $val, wp_cache_get( $key ) );
    225225
    226         // Verify successful delete
     226        // Verify successful delete.
    227227        $this->assertTrue( wp_cache_delete( $key ) );
    228228        $this->assertFalse( wp_cache_get( $key ) );
    229229
    230230        // wp_cache_delete() does not have a $force method.
    231         // Delete returns (bool) true when key is not set and $force is true
     231        // Delete returns (bool) true when key is not set and $force is true.
    232232        // $this->assertTrue( wp_cache_delete( $key, 'default', true ) );
    233233
     
    255255            $this->assertEquals( $val2, $this->cache->get( $key ) );
    256256        } else {
    257             // Multisite should have separate per-blog caches
     257            // Multisite should have separate per-blog caches.
    258258            $this->assertTrue( $this->cache->set( $key, $val ) );
    259259            $this->assertEquals( $val, $this->cache->get( $key ) );
     
    270270        }
    271271
    272         // Global group
     272        // Global group.
    273273        $this->assertTrue( $this->cache->set( $key, $val, 'global-cache-test' ) );
    274274        $this->assertEquals( $val, $this->cache->get( $key, 'global-cache-test' ) );
     
    288288
    289289        if ( wp_using_ext_object_cache() ) {
    290             // External caches will contain property values that contain non-matching resource IDs
     290            // External caches will contain property values that contain non-matching resource IDs.
    291291            $this->assertInstanceOf( 'WP_Object_Cache', $wp_object_cache );
    292292        } else {
     
    302302        $fake_key = 'my-fake-key';
    303303
    304         // Save the first value to cache and verify
     304        // Save the first value to cache and verify.
    305305        wp_cache_set( $key, $val1 );
    306306        $this->assertEquals( $val1, wp_cache_get( $key ) );
    307307
    308         // Replace the value and verify
     308        // Replace the value and verify.
    309309        wp_cache_replace( $key, $val2 );
    310310        $this->assertEquals( $val2, wp_cache_get( $key ) );
    311311
    312         // Non-existant key should fail
     312        // Non-existant key should fail.
    313313        $this->assertFalse( wp_cache_replace( $fake_key, $val1 ) );
    314314
    315         // Make sure $fake_key is not stored
     315        // Make sure $fake_key is not stored.
    316316        $this->assertFalse( wp_cache_get( $fake_key ) );
    317317    }
Note: See TracChangeset for help on using the changeset viewer.