/**
  * Tests that schema metadata is cached
  *
  * @return void
  */
 public function testDescribeCache()
 {
     $schema = $this->connection->methodSchemaCollection();
     $method = $this->connection->methodSchemaCollection()->describe('CALC.SUM');
     Cache::delete('test_CALC_SUM', '_cake_method_');
     $this->connection->cacheMetadata(true);
     $schema = $this->connection->methodSchemaCollection();
     $result = $schema->describe('CALC.SUM');
     $this->assertEquals($method, $result);
     $result = Cache::read('test_CALC_SUM', '_cake_method_');
     $this->assertEquals($method, $result);
 }
 /**
  * Get a method instance from the registry.
  *
  * Methods are only created once until the registry is flushed.
  * This means that aliases must be unique across your application.
  * This is important because method associations are resolved at runtime
  * and cyclic references need to be handled correctly.
  *
  * The options that can be passed are the same as in `Method::__construct()`, but the
  * key `className` is also recognized.
  *
  * If $options does not contain `className` CakePHP will attempt to construct the
  * class name based on the alias. If this class does not exist,
  * then the default `CakeDC\OracleDriver\ORM\Method` class will be used. By setting the `className`
  * option you can define the specific class to use. This className can
  * use a plugin short class reference.
  *
  * If you use a `$name` that uses plugin syntax only the name part will be used as
  * key in the registry. This means that if two plugins, or a plugin and app provide
  * the same alias, the registry will only store the first instance.
  *
  * If no `method` option is passed, the method name will be the underscored version
  * of the provided $alias.
  *
  * If no `connection` option is passed the method's defaultConnectionName() method
  * will be called to get the default connection name to use.
  *
  * @param string $alias The alias name you want to get.
  * @param array $options The options you want to build the method with.
  *   If a method has already been loaded the options will be ignored.
  * @return \CakeDC\OracleDriver\ORM\Method
  * @throws \RuntimeException When you try to configure an alias that already exists.
  */
 public function get($alias, array $options = [])
 {
     if (isset($this->_instances[$alias])) {
         if (!empty($options) && $this->_options[$alias] !== $options) {
             throw new RuntimeException(sprintf('You cannot configure "%s", it already exists in the registry.', $alias));
         }
         return $this->_instances[$alias];
     }
     $this->_options[$alias] = $options;
     list(, $classAlias) = pluginSplit($alias);
     $options = ['alias' => $classAlias] + $options;
     if (isset($this->_config[$alias])) {
         $options += $this->_config[$alias];
     }
     if (empty($options['className'])) {
         $options['className'] = Inflector::camelize($alias);
     }
     $className = $this->_getClassName($alias, $options);
     if ($className) {
         $options['className'] = $className;
         $options['method'] = Inflector::underscore($alias);
     } else {
         if (!isset($options['method']) && strpos($options['className'], '\\') === false) {
             list(, $method) = pluginSplit($options['className']);
             $options['method'] = Inflector::underscore($method);
         }
         $options['className'] = 'CakeDC\\OracleDriver\\ORM\\Method';
     }
     if (empty($options['connection'])) {
         $connectionName = $options['className']::defaultConnectionName();
         $options['connection'] = ConnectionManager::get($connectionName);
     }
     if (!$options['connection'] instanceof OracleConnection) {
         $options['connection'] = OracleConnection::build($options['connection']);
     }
     $options['registryAlias'] = $alias;
     $this->_instances[$alias] = $this->_create($options);
     if ($options['className'] === 'CakeDC\\OracleDriver\\ORM\\Method') {
         $this->_fallbacked[$alias] = $this->_instances[$alias];
     }
     return $this->_instances[$alias];
 }