public function testInvalidateCache()
 {
     $Sluggable = new SluggableRoute('/', array(), array('models' => array('RouteTest')));
     $Sluggable->getSlugs('RouteTest');
     $varCache = $Sluggable->RouteTest_slugs;
     $this->assertInternalType('array', $varCache);
     $cached = Cache::read('RouteTest_slugs', 'Slugger');
     $this->assertInternalType('array', $cached);
     $Sluggable->invalidateCache('RouteTest');
     $this->assertFalse(isset($Sluggable->RouteTest_slugs));
     $this->assertFalse(Cache::read('RouteTest_slugs', 'Slugger'));
     $Sluggable->getSlugs('RouteTest');
     $this->RouteTest->id = 1;
     $this->RouteTest->saveField('title', 'A different name!');
     $Sluggable->invalidateCache('RouteTest', 1);
     $result = $Sluggable->RouteTest_slugs;
     $expected = array(1 => 'a-different-name', 2 => 'another-title', 3 => 'i-love-cakephp');
     $this->assertEquals($result, $expected);
     $result = Cache::read('RouteTest_slugs', 'Slugger');
     $expected = array(1 => 'a-different-name', 2 => 'another-title', 3 => 'i-love-cakephp');
     $this->assertEquals($result, $expected);
     $Sluggable->invalidateCache('RouteTest');
     $Sluggable->invalidateCache('RouteTest', 2);
     $this->assertFalse(isset($Sluggable->RouteTest_slugs));
     $this->assertFalse(Cache::read('RouteTest_slugs', 'Slugger'));
 }
Beispiel #2
0
 /**
  * Invalidate cached slugs for a given model or entry
  *
  * @param string $modelName Name of the model to invalidate cache for
  * @param string $id If of the only entry to update
  * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
  * @access public
  */
 public static function invalidateCache($modelName, $id = null)
 {
     return SluggableRoute::invalidateCache($modelName, $id);
 }
Beispiel #3
0
 /**
  * Invalidate cached slugs for a given model or entry
  *
  * @param string $modelName Name of the model to invalidate cache for
  * @param string $id If of the only entry to update
  * @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
  * @access public
  */
 public function invalidateCache($modelName, $id = null)
 {
     return $this->_Sluggable->invalidateCache($modelName, $id);
 }