/** * test that fields() method cache detects datasource changes * * @return void */ public function testFieldsCacheKeyWithDatasourceChange() { ConnectionManager::create('firstschema', array('datasource' => 'DboTestSource')); ConnectionManager::create('secondschema', array('datasource' => 'DboSecondTestSource')); Cache::delete('method_cache', '_cake_core_'); DboTestSource::$methodCache = array(); $Article = ClassRegistry::init('Article'); $Article->setDataSource('firstschema'); $ds = $Article->getDataSource(); $ds->cacheMethods = true; $first = $ds->fields($Article, null, array('title', 'body', 'published')); $Article->setDataSource('secondschema'); $ds = $Article->getDataSource(); $ds->cacheMethods = true; $second = $ds->fields($Article, null, array('title', 'body', 'published')); $this->assertNotEquals($first, $second); $this->assertEquals(2, count(DboTestSource::$methodCache['fields'])); }
/** * test that fields() is using methodCache() * * @return void */ public function testFieldsUsingMethodCache() { $this->testDb->cacheMethods = false; DboTestSource::$methodCache = array(); $Article = ClassRegistry::init('Article'); $this->testDb->fields($Article, null, array('title', 'body', 'published')); $this->assertTrue(empty(DboTestSource::$methodCache['fields']), 'Cache not empty'); }