feat(describe): continues work around hooks

This commit is contained in:
Nuno Maduro
2023-05-26 19:29:46 +01:00
parent 465c65243d
commit 3e8616ec64
11 changed files with 132 additions and 172 deletions

View File

@ -28,7 +28,7 @@ final class AfterEachRepository
if (array_key_exists($filename, $this->state)) {
$fromAfterEachTestCase = $this->state[$filename];
$afterEachTestCase = ChainableClosure::from($fromAfterEachTestCase, $afterEachTestCase)
$afterEachTestCase = ChainableClosure::fromSameObject($fromAfterEachTestCase, $afterEachTestCase)
->bindTo($afterEachCall, $afterEachCall::class);
}
@ -44,7 +44,7 @@ final class AfterEachRepository
{
$afterEach = $this->state[$filename] ?? NullClosure::create();
return ChainableClosure::from(function (): void {
return ChainableClosure::fromSameObject(function (): void {
if (class_exists(Mockery::class)) {
if ($container = Mockery::getContainer()) {
/* @phpstan-ignore-next-line */

View File

@ -27,8 +27,8 @@ final class BeforeEachRepository
if (array_key_exists($filename, $this->state)) {
[$fromBeforeEachTestCall, $fromBeforeEachTestCase] = $this->state[$filename];
$beforeEachTestCall = ChainableClosure::from($fromBeforeEachTestCall, $beforeEachTestCall)->bindTo($beforeEachCall, $beforeEachCall::class);
$beforeEachTestCase = ChainableClosure::from($fromBeforeEachTestCase, $beforeEachTestCase)->bindTo($beforeEachCall, $beforeEachCall::class);
$beforeEachTestCall = ChainableClosure::fromDifferentObjects($fromBeforeEachTestCall, $beforeEachTestCall);
$beforeEachTestCase = ChainableClosure::fromSameObject($fromBeforeEachTestCase, $beforeEachTestCase)->bindTo($beforeEachCall, $beforeEachCall::class);
}
assert($beforeEachTestCall instanceof Closure);