Permalink
Browse files

Add namespace prefix feature

  • Loading branch information...
ludofleury committed Apr 25, 2012
1 parent 55ede38 commit 24fbe6f7d91c17c3b01be22ede5721001cbbcd2b
@@ -64,7 +64,8 @@ protected function initBundleDirectoryStructure(ContainerInterface $container, I
);
}
- $featuresPath = $bundlePath.DIRECTORY_SEPARATOR.'Features';
+ $prefix = $container->getParameter('behat.namespace.prefix') ? DIRECTORY_SEPARATOR.(str_replace('\\', DIRECTORY_SEPARATOR, trim($container->get('behat.namespace.prefix'), '\\'))) : null;
+ $featuresPath = $bundlePath.$prefix.DIRECTORY_SEPARATOR.'Features';
$locator = $container->get('behat.path_locator');
$basePath = realpath($locator->getWorkPath()).DIRECTORY_SEPARATOR;
$contextPath = $featuresPath.DIRECTORY_SEPARATOR.'Context';
@@ -35,8 +35,10 @@ public function process(ContainerInterface $container, InputInterface $input, Ou
if (preg_match('/^\@([^\/\\\\]+)(.*)$/', $input->getArgument('features'), $matches)) {
$bundle = $container->get('kernel')->getBundle($matches[1]);
+
+ $prefix = $container->getParameter('behat.namespace.prefix') ? DIRECTORY_SEPARATOR.trim($container->getParameter('behat.namespace.prefix'), '\\') : null;
$input->setArgument(
- 'features', realpath($bundle->getPath()).DIRECTORY_SEPARATOR.'Features'.$matches[2]
+ 'features', realpath($bundle->getPath()).$prefix.DIRECTORY_SEPARATOR.'Features'.$matches[2]
);
}
@@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
+ <parameter key="behat.namespace.prefix">null</parameter>
<parameter key="behat.context.class">null</parameter>
<parameter key="behat.context_dispatcher.class">Behat\BehatBundle\Context\ContextDispatcher</parameter>
<parameter key="behat.runner.class">Behat\BehatBundle\Runner</parameter>
View
@@ -52,6 +52,12 @@ public function getContextClassForBundle($bundleNamespace)
if (class_exists($bundleNamespace.'\\Features\\Context\\FeatureContext')) {
return $bundleNamespace.'\\Features\\Context\\FeatureContext';
}
+
+
+ $prefix = $this->getContainer()->getParameter('behat.namespace.prefix') ? '\\'.trim($this->getContainer()->getParameter('behat.namespace.prefix'), '\\') : null ;
+ if (class_exists($bundleNamespace.$prefix.'\\Features\\Context\\FeatureContext')) {
+ return $bundleNamespace.$prefix.'\\Features\\Context\\FeatureContext';
+ }
}
/**

0 comments on commit 24fbe6f

Please sign in to comment.