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

testCacheReadWithConditions() public method

    public function testCacheReadWithConditions()
    {
        $config = array('default' => array('adapter' => 'Memory', 'filters' => array()));
        Cache::config($config);
        $result = Cache::config();
        $expected = $config;
        $this->assertEqual($expected, $result);
        $result = Cache::read('default', 'some_key', array('conditions' => function () {
            return false;
        }));
        $this->assertFalse($result);
        $conditions = function () use(&$config) {
            return isset($config['default']);
        };
        Cache::write('default', 'some_key', 'some value', '+1 minute');
        $result = Cache::read('default', 'some_key', compact('conditions'));
        $this->assertNotEmpty($result);
        $this->assertFalse(Cache::read('non_existing', 'key_value', compact('conditions')));
    }