Exemplo n.º 1
0
 /**
  * @see     Behat\Behat\Console\Configuration\ProcessorInterface::process()
  */
 public function process(ContainerInterface $container, InputInterface $input, OutputInterface $output)
 {
     $extension = new BehatExtension();
     $cwd = getcwd();
     $configFile = $input->getOption('config');
     $profile = $input->getOption('profile') ?: 'default';
     $configs = array();
     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';
         }
     }
     // read and normalize raw parameters string from env
     if ($config = getenv('BEHAT_PARAMS')) {
         parse_str($config, $config);
         $configs[] = $this->normalizeRawConfiguration($config);
     }
     // read configuration file
     if (file_exists($configFile)) {
         $configs[] = $extension->readConfigurationFile($configFile, $profile, $container);
     }
     // configure container
     $extension->load($configs, $container);
     $container->addCompilerPass(new GherkinPass());
     $container->addCompilerPass(new ContextReaderPass());
     $container->addCompilerPass(new EventDispatcherPass());
     $container->compile();
     if (file_exists($configFile)) {
         $container->get('behat.path_locator')->setPathConstant('BEHAT_CONFIG_PATH', dirname($configFile));
     }
 }
Exemplo n.º 2
0
 /**
  * Configures container based on providen config file and profile.
  *
  * @param ContainerInterface $container
  * @param InputInterface     $input
  */
 protected function loadConfiguration(ContainerInterface $container, InputInterface $input)
 {
     $file = $input->getParameterOption(array('--config', '-c'));
     $profile = $input->getParameterOption(array('--profile', '-p')) ?: 'default';
     $cwd = getcwd();
     // if config file is not provided
     if (!$file) {
         // then use behat.yml
         if (is_file($cwd . DIRECTORY_SEPARATOR . 'behat.yml')) {
             $file = $cwd . DIRECTORY_SEPARATOR . 'behat.yml';
             // or behat.yml.dist
         } elseif (is_file($cwd . DIRECTORY_SEPARATOR . 'behat.yml.dist')) {
             $file = $cwd . DIRECTORY_SEPARATOR . 'behat.yml.dist';
             // or config/behat.yml
         } elseif (is_file($cwd . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'behat.yml')) {
             $file = $cwd . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'behat.yml';
         }
     }
     // read configuration
     $loader = new Loader($file);
     $configs = $loader->loadConfiguration($profile);
     // locate base path
     $basePath = $cwd;
     if (file_exists($file)) {
         $basePath = realpath(dirname($file));
     }
     // load core extension into temp container
     $extension = new BehatExtension($basePath);
     $extension->load($configs, $container);
     $container->addObjectResource($extension);
 }
 /**
  * Loads core extension into container.
  *
  * @param ContainerBuilder $container
  * @param $array           $configs
  */
 protected function loadCoreExtension(ContainerBuilder $container, array $configs)
 {
     if (null === $this->basePath) {
         throw new \RuntimeException('Suite basepath is not set. Seems you have forgot to load configuration first.');
     }
     $extension = new BehatExtension($this->basePath);
     $extension->load($configs, $container);
     $container->addObjectResource($extension);
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function __construct()
 {
     parent::__construct();
     $this->configuration = new Configuration();
 }
Exemplo n.º 5
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;
 }