/**
  * Checks if the cache is to be used by checking the class'
  * Cake\Core\InstanceConfigTrait::config method and; if it is unset (NULL),
  * then the configuration key will be read. If it is still unset, the "debug"
  * Configure path will be checked (TRUE in production mode).
  *
  * @return bool
  */
 protected function useCache()
 {
     $useCache = $this->config('cache');
     if (null === $useCache) {
         $configureKey = ConfigureKey::fqn($this) . '.cache';
         $useCache = Configure::read($configureKey);
     }
     $result = null === $useCache ? false === Configure::read('debug') : (bool) $useCache;
     return $result;
 }
 protected function clear($alias, array $params = [])
 {
     $params += ['config' => true, 'cache' => true];
     if (true === $params['config']) {
         $key = $this->Items->behaviors()->get($alias)->cacheKey();
         Cache::delete($key);
     }
     if (true === $params['cache']) {
         $behavior = $this->Items->behaviors()->get($alias);
         $key = ConfigureKey::fqn($behavior);
         Configure::write($key, null);
     }
 }
 /**
  * Tests for the ConfigureKey::fqn method.
  *
  * @return void
  * @covers Database\Utility\CodeLogic\ConfigureKey::fqn
  */
 public function testFqn()
 {
     $items = TableRegistry::get('Items');
     $items->addBehavior('DatabaseAutovalidate', ['className' => 'Database.Autovalidate']);
     $items->addBehavior('DatabaseFormattable', ['className' => 'Database.Formattable']);
     $items->addBehavior('Timestamp', ['className' => 'Timestamp']);
     $result = ConfigureKey::fqn($items->behaviors()->get('DatabaseAutovalidate'));
     $this->assertEquals('plugin.Database.AutovalidateBehavior', $result);
     $result = ConfigureKey::fqn($items->behaviors()->get('DatabaseFormattable'));
     $this->assertEquals('plugin.Database.FormattableBehavior', $result);
     $result = ConfigureKey::fqn($items->behaviors()->get('Timestamp'));
     $this->assertEquals('Cake.TimestampBehavior', $result);
 }