WordPress.org

Make WordPress Core

Changeset 418 in tests


Ignore:
Timestamp:
08/22/11 17:40:04 (3 years ago)
Author:
ryan
Message:

incr() and decr() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_cache.php

    r416 r418  
    116116        $this->assertEquals( 'bravo', $object_a->foo ); 
    117117    } 
     118 
     119    function test_incr() { 
     120        $key = rand_str(); 
     121 
     122        $this->assertFalse( $this->cache->incr( $key ) ); 
     123 
     124        $this->cache->set( $key, 0 ); 
     125        $this->cache->incr( $key ); 
     126        $this->assertEquals( 1, $this->cache->get( $key ) ); 
     127 
     128        $this->cache->incr( $key, 2 ); 
     129        $this->assertEquals( 3, $this->cache->get( $key ) ); 
     130    } 
     131 
     132    function test_decr() { 
     133        $key = rand_str(); 
     134 
     135        $this->assertFalse( $this->cache->decr( $key ) ); 
     136 
     137        $this->cache->set( $key, 0 ); 
     138        $this->cache->decr( $key ); 
     139        $this->assertEquals( 0, $this->cache->get( $key ) ); 
     140 
     141        $this->cache->set( $key, 3 ); 
     142        $this->cache->decr( $key ); 
     143        $this->assertEquals( 2, $this->cache->get( $key ) ); 
     144 
     145        $this->cache->decr( $key, 2 ); 
     146        $this->assertEquals( 0, $this->cache->get( $key ) ); 
     147    } 
    118148} 
    119149 
Note: See TracChangeset for help on using the changeset viewer.