CacheBehaviorTestCase::testAuto PHP Метод

testAuto() публичный Метод

public testAuto ( )
    function testAuto()
    {
        $this->CacheData->Behaviors->attach('Cacher.Cache', array('auto' => false));
        $results = $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%cache%')));
        $results = Set::extract('/CacheData/name', $results);
        $expected = array('A Cached Thing', 'Cache behavior');
        $this->assertEquals($results, $expected);
        // test that it's not pulling from the cache
        $this->CacheData->delete(1);
        $results = $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%cache%')));
        $results = Set::extract('/CacheData/name', $results);
        $expected = array('Cache behavior');
        $this->assertEquals($results, $expected);
        $this->CacheData->Behaviors->attach('Cacher.Cache', array('auto' => true));
        // create cached value
        $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%behav%')));
        // test that it's not pulling from the cache
        $this->CacheData->delete(2);
        $results = $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%behav%'), 'cacher' => false));
        $results = Set::extract('/CacheData/name', $results);
        $expected = array();
        $this->assertEquals($results, $expected);
    }