/** * Loads the Propel configuration. * * @param array $config A configuration array * * @return BuilderConfiguration A BuilderConfiguration instance */ public function configLoad($config, BuilderConfiguration $configuration) { if (!$configuration->hasDefinition('propel')) { $loader = new XmlFileLoader(__DIR__ . '/../Resources/config'); $configuration->merge($loader->load($this->resources['propel'])); } if (!$configuration->hasParameter('propel.path')) { if (!isset($config['path'])) { throw new \InvalidArgumentException('The "path" parameter is mandatory.'); } $configuration->setParameter('propel.path', $config['path']); } if (isset($config['path'])) { $configuration->setParameter('propel.path', $config['path']); } if (isset($config['phing_path'])) { $configuration->setParameter('propel.phing_path', $config['phing_path']); } }
$t->is($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase'); try { $configuration->getParameter('baba'); $t->fail('->getParameter() throws an \InvalidArgumentException if the key does not exist'); } catch (\InvalidArgumentException $e) { $t->pass('->getParameter() throws an \InvalidArgumentException if the key does not exist'); } // ->hasParameter() $t->diag('->hasParameter()'); $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); $t->ok($configuration->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); $t->ok($configuration->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); $t->ok(!$configuration->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); // ->addParameters() $t->diag('->addParameters()'); $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); $configuration->addParameters(array('bar' => 'foo')); $t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); $configuration->addParameters(array('Bar' => 'fooz')); $t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); // ->setAlias() ->getAlias() ->hasAlias() ->getAliases() ->addAliases() $t->diag('->setAlias() ->getAlias() ->hasAlias()'); $configuration = new BuilderConfiguration(); $configuration->setAlias('bar', 'foo');
public function testHasParameter() { $configuration = new BuilderConfiguration(array(), array('foo' => 'bar')); $this->assertTrue($configuration->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); $this->assertTrue($configuration->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); $this->assertFalse($configuration->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); }