1 | <?php |
||
19 | class GherkinParam extends \Codeception\Extension |
||
20 | { |
||
21 | /** |
||
22 | * @var array List events to listen to |
||
23 | */ |
||
24 | public static $events = [ |
||
25 | //run before any suite |
||
26 | 'suite.before' => 'beforeSuite', |
||
27 | //run before any steps |
||
28 | 'step.before' => 'beforeStep' |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * @var array Current test suite config |
||
33 | */ |
||
34 | private static $suiteConfig; |
||
35 | |||
36 | /** |
||
37 | * @var array RegExp for parsing steps |
||
38 | */ |
||
39 | private static $regEx = [ |
||
40 | 'match' => '/{{\s?[A-z0-9_:-]+\s?}}/', |
||
41 | 'filter' => '/[{}]/', |
||
42 | 'config' => '/(?:^config)?:([A-z0-9_-]+)+(?=:|$)/', |
||
43 | 'array' => '/^(?P<var>[A-z0-9_-]+)(?:\[(?P<key>.+)])$/' |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * Parse param and replace {{.*}} by its Fixtures::get() value if exists |
||
48 | * |
||
49 | * @param string $param |
||
50 | * |
||
51 | * @return \mixed|null Returns parameter's value if exists, else parameter's name |
||
52 | */ |
||
53 | final protected function getValueFromParam(string $param) |
||
77 | |||
78 | /** |
||
79 | * Retrieve param value from current suite config |
||
80 | * |
||
81 | * @param string $param |
||
82 | * |
||
83 | * @return \mixed|null Returns parameter's value if exists, else null |
||
84 | */ |
||
85 | final protected function getValueFromConfig(string $param) |
||
103 | |||
104 | /** |
||
105 | * Retrieve param value from array in Fixtures |
||
106 | * |
||
107 | * @param string $param |
||
108 | * |
||
109 | * @return \mixed|null Returns parameter's value if exists, else null |
||
110 | */ |
||
111 | final protected function getValueFromArray(string $param) |
||
122 | |||
123 | /** |
||
124 | * Capture suite's config before any execution |
||
125 | * |
||
126 | * @param \Codeception\Event\SuiteEvent $e |
||
127 | * @return void |
||
128 | * |
||
129 | * @codeCoverageIgnore |
||
130 | * @ignore Codeception specific |
||
131 | */ |
||
132 | final public function beforeSuite(\Codeception\Event\SuiteEvent $e) |
||
136 | |||
137 | /** |
||
138 | * Parse scenario's step before execution |
||
139 | * |
||
140 | * @param \Codeception\Event\StepEvent $e |
||
141 | * @return void |
||
142 | */ |
||
143 | final public function beforeStep(\Codeception\Event\StepEvent $e) |
||
180 | |||
181 | } |
||
182 |