Skip to content

Commit

Permalink
Merge 9553c56 into bc4c6fd
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic authored Mar 29, 2020
2 parents bc4c6fd + 9553c56 commit 3dd381a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/AsyncTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Amp\PHPUnit;

use Amp\Loop;
use Amp\Success;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
use function Amp\call;
Expand Down Expand Up @@ -55,11 +56,13 @@ final public function runAsyncTest(...$args)
$start = \microtime(true);

Loop::run(function () use (&$returnValue, &$exception, &$invoked, $args) {
yield $this->setUpAsync();
$promise = call([$this, $this->realTestName], ...$args);
$promise->onResolve(function ($error, $value) use (&$invoked, &$exception, &$returnValue) {
$invoked = true;
$exception = $error;
$returnValue = $value;
yield $this->tearDownAsync();
});
});

Expand Down Expand Up @@ -146,4 +149,14 @@ final protected function createCallback(int $invocationCount, callable $returnCa

return $mock;
}

protected function setUpAsync(): Promise
{
return new Success();
}

protected function tearDownAsync(): Promise
{
return new Success();
}
}

0 comments on commit 3dd381a

Please sign in to comment.