Skip to content

Commit

Permalink
Add holdBeforeTest and holdAfterTest
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGuilloux committed Jan 29, 2021
1 parent f938789 commit 19e8995
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 12 additions & 2 deletions TestTrait/BeforeAndAfterTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
*/
trait BeforeAndAfterTestTrait
{
/** @var bool */
protected static $holdBeforeTest = false;

/** @var bool */
protected static $holdAfterTest = false;

public function setUp(): void
{
parent::setUp();

$this->beforeTest();
if (!static::$holdBeforeTest) {
$this->beforeTest();
}
}

protected function beforeTest(): void
Expand All @@ -25,7 +33,9 @@ protected function beforeTest(): void

public function tearDown(): void
{
$this->afterTest();
if (!static::$holdAfterTest) {
$this->afterTest();
}

parent::tearDown();
}
Expand Down
1 change: 1 addition & 0 deletions Tests/TestTrait/BeforeAndAfterTestTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ public function testAfterTestExecution(): void
self::assertTrue($testCase->afterTestExecuted);
}
}

10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
"require": {
"php": ">=7.3",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0"
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"doctrine/annotations": "^1.11@dev",
"doctrine/orm": "^2.0|^3.0",
"doctrine/orm": "^2.0 || ^3.0",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^8.0",
"richcongress/static-analysis": "dev-master",
"roave/security-advisories": "dev-master",
"symfony/dependency-injection": "^4.0 || ^5.0",
"symfony/security": "^4.0|^5.0",
"symfony/translation": "^4.0|^5.0",
"symfony/validator": "^4.0|^5.0"
"symfony/security": "^4.0 || ^5.0",
"symfony/translation": "^4.0 || ^5.0",
"symfony/validator": "^4.0 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 19e8995

Please sign in to comment.