4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat;
13 use Behat\Behat\Context\ServiceContainer\ContextExtension;
14 use Behat\Behat\Definition\ServiceContainer\DefinitionExtension;
15 use Behat\Behat\EventDispatcher\ServiceContainer\EventDispatcherExtension;
16 use Behat\Behat\Gherkin\ServiceContainer\GherkinExtension;
17 use Behat\Behat\Hook\ServiceContainer\HookExtension;
18 use Behat\Behat\Output\ServiceContainer\Formatter\JUnitFormatterFactory;
19 use Behat\Behat\Output\ServiceContainer\Formatter\PrettyFormatterFactory;
20 use Behat\Behat\Output\ServiceContainer\Formatter\ProgressFormatterFactory;
21 use Behat\Behat\HelperContainer\ServiceContainer\HelperContainerExtension;
22 use Behat\Behat\Snippet\ServiceContainer\SnippetExtension;
23 use Behat\Behat\Tester\ServiceContainer\TesterExtension;
24 use Behat\Behat\Transformation\ServiceContainer\TransformationExtension;
25 use Behat\Behat\Translator\ServiceContainer\GherkinTranslationsExtension;
26 use Behat\Testwork\ApplicationFactory as BaseFactory;
27 use Behat\Testwork\Argument\ServiceContainer\ArgumentExtension;
28 use Behat\Testwork\Autoloader\ServiceContainer\AutoloaderExtension;
29 use Behat\Testwork\Call\ServiceContainer\CallExtension;
30 use Behat\Testwork\Cli\ServiceContainer\CliExtension;
31 use Behat\Testwork\Environment\ServiceContainer\EnvironmentExtension;
32 use Behat\Testwork\Exception\ServiceContainer\ExceptionExtension;
33 use Behat\Testwork\Filesystem\ServiceContainer\FilesystemExtension;
34 use Behat\Testwork\Ordering\ServiceContainer\OrderingExtension;
35 use Behat\Testwork\Output\ServiceContainer\Formatter\FormatterFactory;
36 use Behat\Testwork\Output\ServiceContainer\OutputExtension;
37 use Behat\Testwork\ServiceContainer\ServiceProcessor;
38 use Behat\Testwork\Specification\ServiceContainer\SpecificationExtension;
39 use Behat\Testwork\Suite\ServiceContainer\SuiteExtension;
40 use Behat\Testwork\Translator\ServiceContainer\TranslatorExtension;
43 * Defines the way behat is created.
45 * @author Konstantin Kudryashov <ever.zet@gmail.com>
47 final class ApplicationFactory extends BaseFactory
49 const VERSION = '3.4.1';
54 protected function getName()
62 protected function getVersion()
70 protected function getDefaultExtensions()
72 $processor = new ServiceProcessor();
75 new ArgumentExtension(),
76 new AutoloaderExtension(array('' => '%paths.base%/features/bootstrap')),
77 new SuiteExtension($processor),
78 new OutputExtension('pretty', $this->getDefaultFormatterFactories($processor), $processor),
79 new ExceptionExtension($processor),
80 new GherkinExtension($processor),
81 new CallExtension($processor),
82 new TranslatorExtension(),
83 new GherkinTranslationsExtension(),
84 new TesterExtension($processor),
85 new CliExtension($processor),
86 new EnvironmentExtension($processor),
87 new SpecificationExtension($processor),
88 new FilesystemExtension(),
89 new ContextExtension($processor),
90 new SnippetExtension($processor),
91 new DefinitionExtension($processor),
92 new EventDispatcherExtension($processor),
94 new TransformationExtension($processor),
95 new OrderingExtension($processor),
96 new HelperContainerExtension($processor)
103 protected function getEnvironmentVariableName()
105 return 'BEHAT_PARAMS';
111 protected function getConfigPath()
113 $cwd = rtrim(getcwd(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
114 $configDir = $cwd . 'config' . DIRECTORY_SEPARATOR;
118 $cwd . 'behat.yaml.dist',
119 $cwd . 'behat.yml.dist',
120 $configDir . 'behat.yaml',
121 $configDir . 'behat.yml',
122 $configDir . 'behat.yaml.dist',
123 $configDir . 'behat.yml.dist',
126 foreach ($paths as $path) {
127 if (is_file($path)) {
136 * Returns default formatter factories.
138 * @param ServiceProcessor $processor
140 * @return FormatterFactory[]
142 private function getDefaultFormatterFactories(ServiceProcessor $processor)
145 new PrettyFormatterFactory($processor),
146 new ProgressFormatterFactory($processor),
147 new JUnitFormatterFactory(),