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

testCacheReadAndWrite() public method

    public function testCacheReadAndWrite()
    {
        $config = array('default' => array('adapter' => 'Memory', 'filters' => array()));
        Cache::config($config);
        $result = Cache::config();
        $expected = $config;
        $this->assertEqual($expected, $result);
        $result = Cache::read('non_existing', 'key_value');
        $this->assertFalse($result);
        $result = Cache::write('default', 'keyed', 'some data', '+1 minute');
        $this->assertTrue($result);
        $result = Cache::read('default', 'keyed');
        $expected = 'some data';
        $this->assertEqual($expected, $result);
        $result = Cache::write('default', 'another', array('data' => 'take two'), '+1 minute');
        $this->assertTrue($result);
        $result = Cache::read('default', 'another');
        $expected = array('data' => 'take two');
        $this->assertEqual($expected, $result);
        $result = Cache::write('default', 'another', (object) array('data' => 'take two'), '+1 minute');
        $this->assertTrue($result);
        $result = Cache::read('default', 'another');
        $expected = (object) array('data' => 'take two');
        $this->assertEqual($expected, $result);
    }