Ejemplo n.º 1
0
 /**
  * Creates service container with or without provided configuration file.
  *
  * @param   string  $configFile DependencyInjection extension config file path (in YAML)
  * @param   string  $profile    profile name
  *
  * @return  Symfony\Component\DependencyInjection\ContainerInterface
  */
 protected function createContainer($configFile = null, $profile = null)
 {
     $container = new ContainerBuilder();
     $extension = new BehatExtension();
     $cwd = getcwd();
     if (null === $profile) {
         $profile = 'default';
     }
     if (null === $configFile) {
         if (is_file($cwd . DIRECTORY_SEPARATOR . 'behat.yml')) {
             $configFile = $cwd . DIRECTORY_SEPARATOR . 'behat.yml';
         } elseif (is_file($cwd . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'behat.yml')) {
             $configFile = $cwd . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'behat.yml';
         }
     }
     if (null !== $configFile) {
         $config = $extension->loadFromFile($configFile, $profile, $container);
     } else {
         $config = $extension->load(array(array()), $container);
     }
     $container->compile();
     if (null !== $configFile) {
         $container->get('behat.path_locator')->setPathConstant('BEHAT_CONFIG_PATH', dirname($configFile));
     }
     return $container;
 }