Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / ApplicationFactory.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat;
12
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;
41
42 /**
43  * Defines the way behat is created.
44  *
45  * @author Konstantin Kudryashov <ever.zet@gmail.com>
46  */
47 final class ApplicationFactory extends BaseFactory
48 {
49     const VERSION = '3.4.1';
50
51     /**
52      * {@inheritdoc}
53      */
54     protected function getName()
55     {
56         return 'behat';
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     protected function getVersion()
63     {
64         return self::VERSION;
65     }
66
67     /**
68      * {@inheritdoc}
69      */
70     protected function getDefaultExtensions()
71     {
72         $processor = new ServiceProcessor();
73
74         return array(
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),
93             new HookExtension(),
94             new TransformationExtension($processor),
95             new OrderingExtension($processor),
96             new HelperContainerExtension($processor)
97         );
98     }
99
100     /**
101      * {@inheritdoc}
102      */
103     protected function getEnvironmentVariableName()
104     {
105         return 'BEHAT_PARAMS';
106     }
107
108     /**
109      * {@inheritdoc}
110      */
111     protected function getConfigPath()
112     {
113         $cwd = rtrim(getcwd(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
114         $configDir = $cwd . 'config' . DIRECTORY_SEPARATOR;
115         $paths = array(
116             $cwd . 'behat.yaml',
117             $cwd . 'behat.yml',
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',
124         );
125
126         foreach ($paths as $path) {
127             if (is_file($path)) {
128                 return $path;
129             }
130         }
131
132         return null;
133     }
134
135     /**
136      * Returns default formatter factories.
137      *
138      * @param ServiceProcessor $processor
139      *
140      * @return FormatterFactory[]
141      */
142     private function getDefaultFormatterFactories(ServiceProcessor $processor)
143     {
144         return array(
145             new PrettyFormatterFactory($processor),
146             new ProgressFormatterFactory($processor),
147             new JUnitFormatterFactory(),
148         );
149     }
150 }