Skip to content

Commit 6b37c7e

Browse files
committed
Accept Standard Before/After Behat tags
1 parent 23ee080 commit 6b37c7e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

moodle/Tests/Util/DocblocksTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,46 @@ function exampleFunction(string $param): void {}',
196196
function exampleFunction(string $param): void {}',
197197
true,
198198
],
199+
'Behat test file: Valid' => [
200+
'lib/tests/behat/behat_example.php',
201+
'<?php
202+
class behat_example {
203+
/**
204+
* @BeforeScenario
205+
* @AfterScenario
206+
* @BeforeFeature
207+
* @AfterFeature
208+
* @BeforeStep
209+
* @AfterStep
210+
* @Given
211+
* @When
212+
* @Then
213+
* @Given
214+
*/
215+
function exampleFunction(string $param): void {}
216+
}',
217+
true,
218+
],
219+
'Unit test file: Contains Behat' => [
220+
'lib/tests/test_behat.php',
221+
'<?php
222+
class test_behat {
223+
/**
224+
* @BeforeScenario
225+
* @AfterScenario
226+
* @BeforeFeature
227+
* @AfterFeature
228+
* @BeforeStep
229+
* @AfterStep
230+
* @Given
231+
* @When
232+
* @Then
233+
* @Given
234+
*/
235+
function exampleFunction(string $param): void {}
236+
}',
237+
false,
238+
],
199239
];
200240
}
201241

moodle/Util/Docblocks.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ abstract class Docblocks
3737
'Given' => true,
3838
'Then' => true,
3939
'When' => true,
40+
'BeforeFeature' => true,
41+
'BeforeScenario' => true,
42+
'BeforeStep' => true,
43+
'AfterFeature' => true,
44+
'AfterScenario' => true,
45+
'AfterStep' => true,
4046

4147
// PHPUnit tags.
4248
'codeCoverageIgnore' => true,
@@ -118,6 +124,13 @@ abstract class Docblocks
118124
'Given' => ['#.*/tests/behat/.*#'],
119125
'Then' => ['#.*/tests/behat/.*#'],
120126
'When' => ['#.*/tests/behat/.*#'],
127+
'BeforeFeature' => ['#.*/tests/behat/.*#'],
128+
'BeforeScenario' => ['#.*/tests/behat/.*#'],
129+
'BeforeStep' => ['#.*/tests/behat/.*#'],
130+
'AfterFeature' => ['#.*/tests/behat/.*#'],
131+
'AfterScenario' => ['#.*/tests/behat/.*#'],
132+
'AfterStep' => ['#.*/tests/behat/.*#'],
133+
121134
'covers' => ['#.*/tests/.*_test.php#'],
122135
'coversDefaultClass' => ['#.*/tests/.*_test.php#'],
123136
'coversNothing' => ['#.*/tests/.*_test.php#'],

0 commit comments

Comments
 (0)