Skip to content

Commit

Permalink
added support for constants in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed Apr 2, 2011
1 parent daea2b1 commit 8a8a9ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/Behat/Behat/Console/Command/BehatCommand.php
Expand Up @@ -448,7 +448,7 @@ protected function printAvailableSteps(InputInterface $input, ContainerInterface
*/
protected function locateFeaturesPaths(InputInterface $input, ContainerInterface $container)
{
$basePath = 'BEHAT_WORK_PATH' . DIRECTORY_SEPARATOR . 'features';
$basePath = '%BEHAT_WORK_PATH%' . DIRECTORY_SEPARATOR . 'features';
$featuresPath = $container->getParameter('behat.paths.features');
$lineFilter = '';

Expand Down Expand Up @@ -779,9 +779,16 @@ protected function runFeatures($featuresPaths, ContainerInterface $container)
*/
protected function preparePath($path, $allowRelativePaths = false)
{
foreach ($this->pathTokens as $name => $value) {
$path = str_replace($name, $value, $path);
}
$pathTokens = $this->pathTokens;
$path = preg_replace_callback('/%([^%]+)%/', function($matches) use($pathTokens) {
$name = $matches[1];
if (defined($name)) {
return constant($name);
} elseif (isset($pathTokens[$name])) {
return $pathTokens[$name];
}
return $matches[0];
}, $path);

$path = str_replace('/', DIRECTORY_SEPARATOR, str_replace('\\', '/', $path));

Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Behat/DependencyInjection/Configuration.php
Expand Up @@ -37,7 +37,7 @@ public function getConfigTree()
arrayNode('paths')->
children()->
scalarNode('features')->
defaultValue('%behat.paths.base%')->
defaultValue('%%BEHAT_BASE_PATH%%')->
end()->
scalarNode('support')->
defaultValue('%behat.paths.features%/support')->
Expand Down
2 changes: 1 addition & 1 deletion src/Behat/Behat/DependencyInjection/config/behat.xml
Expand Up @@ -8,7 +8,7 @@
<parameter key="gherkin.paths.i18n">%gherkin.paths.lib%/i18n</parameter>
<parameter key="behat.paths.i18n">%behat.paths.lib%/i18n</parameter>

<parameter key="behat.paths.features">BEHAT_BASE_PATH</parameter>
<parameter key="behat.paths.features">%%BEHAT_BASE_PATH%%</parameter>
<parameter key="behat.paths.support">%behat.paths.features%/support</parameter>

<parameter key="behat.paths.steps" type="collection">
Expand Down

0 comments on commit 8a8a9ab

Please sign in to comment.