WordPress.org

Make WordPress Core

Changeset 416 in tests


Ignore:
Timestamp:
08/17/11 23:31:11 (4 years ago)
Author:
ryan
Message:

Make sure objects are cloned going to and from the cache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_cache.php

    r366 r416  
    9393        $this->assertFalse($this->cache->get($key)); 
    9494    } 
     95 
     96    // Make sure objects are cloned going to and from the cache 
     97    function test_object_refs() { 
     98        $key = rand_str(); 
     99        $object_a = new stdClass; 
     100        $object_a->foo = 'alpha'; 
     101        $this->cache->set( $key, $object_a ); 
     102        $object_a->foo = 'bravo'; 
     103        $object_b = $this->cache->get( $key ); 
     104        $this->assertEquals( 'alpha', $object_b->foo ); 
     105        $object_b->foo = 'charlie'; 
     106        $this->assertEquals( 'bravo', $object_a->foo ); 
     107 
     108        $key = rand_str(); 
     109        $object_a = new stdClass; 
     110        $object_a->foo = 'alpha'; 
     111        $this->cache->add( $key, $object_a ); 
     112        $object_a->foo = 'bravo'; 
     113        $object_b = $this->cache->get( $key ); 
     114        $this->assertEquals( 'alpha', $object_b->foo ); 
     115        $object_b->foo = 'charlie'; 
     116        $this->assertEquals( 'bravo', $object_a->foo ); 
     117    } 
    95118} 
    96119 
Note: See TracChangeset for help on using the changeset viewer.