lithium\tests\cases\storage\CacheTest::testCacheReadThroughWrite PHP Method

testCacheReadThroughWrite() public method

    public function testCacheReadThroughWrite()
    {
        $config = array('default' => array('adapter' => 'Memory', 'filters' => array()));
        Cache::config($config);
        $result = Cache::config();
        $expected = $config;
        $this->assertEqual($expected, $result);
        $write = function () {
            return array('+1 minute' => 'read-through write');
        };
        $this->assertNull(Cache::read('default', 'read_through'));
        $result = Cache::read('default', 'read_through', compact('write'));
        $this->assertIdentical('read-through write', $result);
        $result = Cache::read('default', 'read_through');
        $this->assertIdentical('read-through write', $result);
        $write = array('+1 minute' => 'string read-through write');
        $result = Cache::read('default', 'string_read_through', compact('write'));
        $this->assertIdentical('string read-through write', $result);
        $result = Cache::read('default', 'string_read_through');
        $this->assertIdentical('string read-through write', $result);
        $this->assertNull(Cache::read('default', 'string_read_through_2'));
        $result = Cache::read('default', 'string_read_through_2', array('write' => array('+1 minute' => function () {
            return 'read-through write 2';
        })));
        $this->assertIdentical('read-through write 2', $result);
    }