1 | <?php |
||
15 | abstract class BaseContext implements Context |
||
16 | { |
||
17 | /** @var \RulerZ\RulerZ */ |
||
18 | protected $rulerz; |
||
19 | |||
20 | /** @var array */ |
||
21 | protected $parameters = []; |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $executionContext = []; |
||
25 | |||
26 | /** @var mixed */ |
||
27 | protected $dataset; |
||
28 | |||
29 | /** @var mixed */ |
||
30 | protected $results; |
||
31 | |||
32 | /** |
||
33 | * Returns the compilation target to be tested. |
||
34 | * |
||
35 | * @return \RulerZ\Compiler\CompilationTarget |
||
36 | */ |
||
37 | abstract protected function getCompilationTarget(); |
||
38 | |||
39 | /** |
||
40 | * Returns the default dataset to be filtered. |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | abstract protected function getDefaultDataset(); |
||
45 | |||
46 | public function __construct() |
||
50 | |||
51 | /** |
||
52 | * @BeforeSuite |
||
53 | */ |
||
54 | public static function prepare(BeforeSuiteScope $scope) |
||
58 | |||
59 | /** |
||
60 | * Will be called right after the construction of the context, useful to |
||
61 | * initialize stuff before the tests are launched. |
||
62 | */ |
||
63 | protected function initialize() |
||
66 | |||
67 | /** |
||
68 | * Create a default execution context that will be given to RulerZ when |
||
69 | * filtering a dataset. |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | protected function getDefaultExecutionContext() |
||
77 | |||
78 | /** |
||
79 | * @Given RulerZ is configured |
||
80 | */ |
||
81 | public function rulerzIsConfigured() |
||
89 | |||
90 | /** |
||
91 | * @When I define the parameters: |
||
92 | */ |
||
93 | public function iDefineTheParameters(TableNode $parameters) |
||
107 | |||
108 | /** |
||
109 | * @When I use the default execution context |
||
110 | */ |
||
111 | public function iUseTheDefaultExecutionContext() |
||
115 | |||
116 | /** |
||
117 | * @When I use the default dataset |
||
118 | */ |
||
119 | public function iUseTheDefaultDataset() |
||
123 | |||
124 | /** |
||
125 | * @When I filter the dataset with the rule: |
||
126 | */ |
||
127 | public function iFilterTheDatasetWithTheRule(PyStringNode $rule) |
||
134 | |||
135 | /** |
||
136 | * @Then I should have the following results: |
||
137 | */ |
||
138 | public function iShouldHaveTheFollowingResults(TableNode $table) |
||
158 | |||
159 | /** |
||
160 | * Fetches a field from a result. |
||
161 | * Meant to be overriden by other contexts. |
||
162 | * |
||
163 | * @param mixed $result |
||
164 | * @param string $field |
||
165 | * |
||
166 | * @return mixed |
||
167 | */ |
||
168 | protected function fieldFromResult($result, $field) |
||
174 | } |
||
175 |