Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setUpAsync() and tearDownAsync() (#17)
- Loading branch information
Showing
5 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Amp\PHPUnit\Test; | ||
|
||
use Amp\Failure; | ||
use Amp\PHPUnit\AsyncTestCase; | ||
use Amp\PHPUnit\TestException; | ||
use Amp\Promise; | ||
use Amp\Success; | ||
|
||
class AsyncTestCaseWithSetUpAndTearDownTest extends AsyncTestCase | ||
{ | ||
protected function setUpAsync(): Promise | ||
{ | ||
if ($this->getName() === 'testFailingSetUpAsync') { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage('setUpAsync() failed'); | ||
|
||
return new Failure(new TestException); | ||
} | ||
|
||
return new Success; | ||
} | ||
|
||
protected function tearDownAsync(): Promise | ||
{ | ||
if ($this->getName() === 'testFailingTearDownAsync') { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage('tearDownAsync() failed'); | ||
|
||
return new Failure(new TestException); | ||
} | ||
|
||
return new Success; | ||
} | ||
|
||
public function testExpectedException(): void | ||
{ | ||
$this->expectException(\Exception::class); | ||
$this->expectExceptionMessage('Test exception'); | ||
|
||
throw new \Exception('Test exception'); | ||
} | ||
|
||
public function testFailingTearDownAsync() | ||
{ | ||
// Expected exception set in tearDownAsync(). | ||
} | ||
|
||
public function testFailingSetUpAsync() | ||
{ | ||
// Expected exception set in setUpAsync(). | ||
} | ||
} |