Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add namespace prefix feature

  • Loading branch information...
commit 24fbe6f7d91c17c3b01be22ede5721001cbbcd2b 1 parent 55ede38
Ludovic Fleury authored April 25, 2012
3  Console/Processor/InitProcessor.php
@@ -64,7 +64,8 @@ protected function initBundleDirectoryStructure(ContainerInterface $container, I
64 64
             );
65 65
         }
66 66
 
67  
-        $featuresPath = $bundlePath.DIRECTORY_SEPARATOR.'Features';
  67
+        $prefix = $container->getParameter('behat.namespace.prefix') ? DIRECTORY_SEPARATOR.(str_replace('\\', DIRECTORY_SEPARATOR, trim($container->get('behat.namespace.prefix'), '\\'))) : null;
  68
+        $featuresPath = $bundlePath.$prefix.DIRECTORY_SEPARATOR.'Features';
68 69
         $locator      = $container->get('behat.path_locator');
69 70
         $basePath     = realpath($locator->getWorkPath()).DIRECTORY_SEPARATOR;
70 71
         $contextPath  = $featuresPath.DIRECTORY_SEPARATOR.'Context';
4  Console/Processor/LocatorProcessor.php
@@ -35,8 +35,10 @@ public function process(ContainerInterface $container, InputInterface $input, Ou
35 35
 
36 36
         if (preg_match('/^\@([^\/\\\\]+)(.*)$/', $input->getArgument('features'), $matches)) {
37 37
             $bundle = $container->get('kernel')->getBundle($matches[1]);
  38
+
  39
+            $prefix = $container->getParameter('behat.namespace.prefix') ? DIRECTORY_SEPARATOR.trim($container->getParameter('behat.namespace.prefix'), '\\')  : null;
38 40
             $input->setArgument(
39  
-                'features', realpath($bundle->getPath()).DIRECTORY_SEPARATOR.'Features'.$matches[2]
  41
+                'features', realpath($bundle->getPath()).$prefix.DIRECTORY_SEPARATOR.'Features'.$matches[2]
40 42
             );
41 43
         }
42 44
 
1  Resources/config/behat_bundle.xml
@@ -3,6 +3,7 @@
3 3
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 4
     xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
5 5
     <parameters>
  6
+        <parameter key="behat.namespace.prefix">null</parameter>
6 7
         <parameter key="behat.context.class">null</parameter>
7 8
         <parameter key="behat.context_dispatcher.class">Behat\BehatBundle\Context\ContextDispatcher</parameter>
8 9
         <parameter key="behat.runner.class">Behat\BehatBundle\Runner</parameter>
6  Runner.php
@@ -52,6 +52,12 @@ public function getContextClassForBundle($bundleNamespace)
52 52
         if (class_exists($bundleNamespace.'\\Features\\Context\\FeatureContext')) {
53 53
             return $bundleNamespace.'\\Features\\Context\\FeatureContext';
54 54
         }
  55
+
  56
+
  57
+        $prefix = $this->getContainer()->getParameter('behat.namespace.prefix') ? '\\'.trim($this->getContainer()->getParameter('behat.namespace.prefix'), '\\') : null ;
  58
+        if (class_exists($bundleNamespace.$prefix.'\\Features\\Context\\FeatureContext')) {
  59
+            return $bundleNamespace.$prefix.'\\Features\\Context\\FeatureContext';
  60
+        }
55 61
     }
56 62
 
57 63
     /**

0 notes on commit 24fbe6f

Please sign in to comment.
Something went wrong with that request. Please try again.