Skip to content

Commit

Permalink
Accept Standard Before/After Behat tags
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Mar 19, 2024
1 parent 23ee080 commit 6b37c7e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
40 changes: 40 additions & 0 deletions moodle/Tests/Util/DocblocksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,46 @@ function exampleFunction(string $param): void {}',
function exampleFunction(string $param): void {}',
true,
],
'Behat test file: Valid' => [
'lib/tests/behat/behat_example.php',
'<?php
class behat_example {
/**
* @BeforeScenario
* @AfterScenario
* @BeforeFeature
* @AfterFeature
* @BeforeStep
* @AfterStep
* @Given
* @When
* @Then
* @Given
*/
function exampleFunction(string $param): void {}
}',
true,
],
'Unit test file: Contains Behat' => [
'lib/tests/test_behat.php',
'<?php
class test_behat {
/**
* @BeforeScenario
* @AfterScenario
* @BeforeFeature
* @AfterFeature
* @BeforeStep
* @AfterStep
* @Given
* @When
* @Then
* @Given
*/
function exampleFunction(string $param): void {}
}',
false,
],
];
}

Expand Down
13 changes: 13 additions & 0 deletions moodle/Util/Docblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ abstract class Docblocks
'Given' => true,
'Then' => true,
'When' => true,
'BeforeFeature' => true,
'BeforeScenario' => true,
'BeforeStep' => true,
'AfterFeature' => true,
'AfterScenario' => true,
'AfterStep' => true,

// PHPUnit tags.
'codeCoverageIgnore' => true,
Expand Down Expand Up @@ -118,6 +124,13 @@ abstract class Docblocks
'Given' => ['#.*/tests/behat/.*#'],
'Then' => ['#.*/tests/behat/.*#'],
'When' => ['#.*/tests/behat/.*#'],
'BeforeFeature' => ['#.*/tests/behat/.*#'],
'BeforeScenario' => ['#.*/tests/behat/.*#'],
'BeforeStep' => ['#.*/tests/behat/.*#'],
'AfterFeature' => ['#.*/tests/behat/.*#'],
'AfterScenario' => ['#.*/tests/behat/.*#'],
'AfterStep' => ['#.*/tests/behat/.*#'],

'covers' => ['#.*/tests/.*_test.php#'],
'coversDefaultClass' => ['#.*/tests/.*_test.php#'],
'coversNothing' => ['#.*/tests/.*_test.php#'],
Expand Down

0 comments on commit 6b37c7e

Please sign in to comment.