public function it_creates_a_array_parameter_and_merges_existing_data(Parameter $parameterConf, \Pimple $container) { $parameterConf->getParameterName()->willReturn('db.options'); $parameterConf->getParameterValue()->willReturn(array('host' => 'example.org')); $parameterConf->getMergeStrategy(Argument::type('array'))->willReturn('array_replace_recursive'); $parameterConf->mergeExisting()->willReturn(true); $container->offsetExists('db.options')->willReturn(true); $container->offsetGet('db.options')->willReturn(array('host' => 'localhost', 'user' => 'root', 'password' => 'test')); $container->offsetSet('db.options', array('host' => 'example.org', 'user' => 'root', 'password' => 'test'))->shouldBeCalled(); $container = $this->create($parameterConf, $container); }
/** * @param \Pimple $app * * @throws \Doctrine\DBAL\DBALException * * @api * * @quality:method [B] */ public function setup(\Pimple $app) { if (!$app->offsetExists('config') || !isset($app->offsetGet('config')['doctrine'])) { return; } $config = $app->offsetGet('config'); ConfigResolver::resolve((array) $config['doctrine:dbal']); $app['connections'] = $app::share(function () use($config) { $connections = new \Pimple(); foreach ((array) $config['doctrine:dbal:connections'] as $id => $params) { $connections->offsetSet($id, DriverManager::getConnection($params)); } return $connections; }); $app['connection'] = $app::share(function (\Pimple $app) use($config) { $ids = $app['connections']->keys(); $default = $config['doctrine:dbal:default_connection'] ?: current($ids); return $app['connections'][$default]; }); }
/** * @param Pimple $pimple */ function it_adds_parameters_on_pimple($pimple, $loader) { $pimple->offsetSet('hello', 'world')->shouldBeCalled(); $loader->load('config.json')->willReturn(array('hello' => 'world')); $this->configure($pimple, 'config.json'); }
/** * {@inheritdoc} */ public function offsetSet($id, $value) { $this->container->offsetSet($id, $value); }
/** * Sets a parameter. * * @param string $name The parameter name * @param mixed $value The parameter value * * @api */ public function setParameter($name, $value) { $config = $this->pimple->offsetGet('config'); $config[$name] = $value; $this->pimple->offsetSet('config', $config); }