From d8983025908d8739450455645e6fcbb9a0efe5c3 Mon Sep 17 00:00:00 2001 From: Masiukevich Maksim Date: Sat, 13 Feb 2021 15:36:44 +0100 Subject: [PATCH] fix tests --- .../DefaultEventProcessorTest.php | 20 ++++++++++++++ tests/SagasProviderTest.php | 26 +++++++++++++++++++ tests/Store/SQLSagaStoreTest.php | 12 +++++++++ 3 files changed, 58 insertions(+) diff --git a/tests/Configuration/DefaultEventProcessorTest.php b/tests/Configuration/DefaultEventProcessorTest.php index 2b22dee..2f2c293 100644 --- a/tests/Configuration/DefaultEventProcessorTest.php +++ b/tests/Configuration/DefaultEventProcessorTest.php @@ -124,6 +124,8 @@ function (): \Generator self::assertInstanceOf(SecondEventWithKey::class, $event, get_class($event)); self::assertSame($id->toString(), $event->key); + + Loop::stop(); } ); } @@ -158,6 +160,8 @@ function (): \Generator self::assertInstanceOf(SecondEventWithKey::class, $event); self::assertSame('qwerty', $event->key); + + Loop::stop(); } ); } @@ -191,6 +195,8 @@ function (): \Generator 'The value of the "saga-correlation-id" header key can\'t be empty, since it is the saga id', $records[0]['context']['throwableMessage'] ); + + Loop::stop(); } ); } @@ -224,6 +230,8 @@ function (): \Generator 'Attempt to apply event to non-existent saga (ID: 1b6d89ec-cf60-4e48-a253-fd57f844c07d)', $records[0]['context']['throwableMessage'] ); + + Loop::stop(); } ); } @@ -259,6 +267,8 @@ function (): \Generator 'A property that contains an identifier ("requestId") was not found in class "ServiceBus\\Sagas\\Tests\\stubs\\EmptyEvent"', $records[0]['context']['throwableMessage'] ); + + Loop::stop(); } ); } @@ -294,6 +304,8 @@ function (): \Generator 'The value of the "key" property of the "ServiceBus\\Sagas\\Tests\\stubs\\EventWithKey" event can\'t be empty, since it is the saga id', $records[0]['context']['throwableMessage'] ); + + Loop::stop(); } ); } @@ -331,6 +343,8 @@ function (): \Generator 'Attempt to apply event to completed saga (ID: 1b6d89ec-cf60-4e48-a253-fd57f844c07d)', $records[0]['context']['throwableMessage'] ); + + Loop::stop(); } ); } @@ -365,6 +379,8 @@ function (): \Generator ); self::assertFalse($stored); + + Loop::stop(); } ); } @@ -412,6 +428,8 @@ function (): \Generator 'Identifier class "SomeUnknownClass" specified in the saga "ServiceBus\Sagas\Tests\stubs\CorrectSaga" not found', $record['message'] ); + + Loop::stop(); } ); } @@ -459,6 +477,8 @@ function (): \Generator 'Saga identifier mus be type of "ServiceBus\Sagas\SagaId". "ServiceBus\Sagas\Tests\stubs\IncorrectSagaIdType" type specified', $record['message'] ); + + Loop::stop(); } ); } diff --git a/tests/SagasProviderTest.php b/tests/SagasProviderTest.php index 789b9f3..2dc06ea 100644 --- a/tests/SagasProviderTest.php +++ b/tests/SagasProviderTest.php @@ -130,6 +130,8 @@ function (): \Generator $testSaga = new TestSaga(TestSagaId::new(TestSaga::class)); yield $this->sagaProvider->save($testSaga, new TestContext()); + + Loop::stop(); } ); } @@ -147,6 +149,8 @@ function (): \Generator $id = TestSagaId::new(TestSaga::class); yield $this->sagaProvider->start($id, new TestCommand(), new TestContext()); + + Loop::stop(); } ); } @@ -169,6 +173,8 @@ function (): \Generator self::assertNotNull($saga); self::assertInstanceOf(TestSaga::class, $saga); self::assertSame($id, $saga->id()); + + Loop::stop(); } ); } @@ -189,6 +195,8 @@ function (): \Generator yield $this->sagaProvider->start($id, new TestCommand(), new TestContext()); yield $this->sagaProvider->start($id, new TestCommand(), new TestContext()); + + Loop::stop(); } ); } @@ -208,6 +216,8 @@ function (): \Generator $this->containerBuilder->get(Router::class); yield $this->sagaProvider->start(TestSagaId::new(TestSaga::class), new TestCommand(), new TestContext()); + + Loop::stop(); } ); } @@ -226,6 +236,8 @@ function (): \Generator yield $this->adapter->execute('DROP TABLE sagas_store'); yield $this->sagaProvider->obtain(TestSagaId::new(TestSaga::class), new TestContext()); + + Loop::stop(); } ); } @@ -245,6 +257,8 @@ function (): \Generator $testSaga = new TestSaga(TestSagaId::new(TestSaga::class)); yield $this->sagaProvider->save($testSaga, new TestContext()); + + Loop::stop(); } ); } @@ -260,6 +274,8 @@ function (): \Generator self::assertNull( yield $this->sagaProvider->obtain(TestSagaId::new(TestSaga::class), new TestContext()) ); + + Loop::stop(); } ); } @@ -291,6 +307,8 @@ function (): \Generator yield $this->adapter->execute($query->sql(), $query->params()); yield $this->sagaProvider->obtain($id, $context); + + Loop::stop(); } ); } @@ -318,6 +336,8 @@ function (): \Generator $loadedSaga = yield $this->sagaProvider->obtain($id, $context); self::assertSame($saga->id()->id, $loadedSaga->id()->id); + + Loop::stop(); } ); } @@ -365,6 +385,8 @@ function (): \Generator $newExpireDate->format('Y-m-d H:i:s'), $loadedSaga->expireDate()->format('Y-m-d H:i:s') ); + + Loop::stop(); } ); } @@ -388,6 +410,8 @@ function (): \Generator yield $this->sagaProvider->start($id, new TestCommand(), $context); yield $this->sagaProvider->reopen($id, $context, datetimeInstantiator('+1 day'), 'testing'); + + Loop::stop(); } ); } @@ -410,6 +434,8 @@ function (): \Generator $id = new TestSagaId('ccfd1b8e-be8b-4f69-b1ca-c92a14379558', TestSaga::class); yield $this->sagaProvider->reopen($id, $context, datetimeInstantiator('+1 day'), 'testing'); + + Loop::stop(); } ); } diff --git a/tests/Store/SQLSagaStoreTest.php b/tests/Store/SQLSagaStoreTest.php index f3e6034..94387e7 100644 --- a/tests/Store/SQLSagaStoreTest.php +++ b/tests/Store/SQLSagaStoreTest.php @@ -85,6 +85,8 @@ function (): \Generator self::assertNotNull($loadedSaga); self::assertInstanceOf(CorrectSaga::class, $loadedSaga); self::assertSame($id->id, $loadedSaga->id()->id); + + Loop::stop(); } ); } @@ -107,6 +109,8 @@ function (): \Generator $loadedSaga = yield $this->store->obtain($id); self::assertNull($loadedSaga); + + Loop::stop(); } ); } @@ -120,6 +124,8 @@ public function removeUnExistsSaga(): void function (): \Generator { yield $this->store->remove(TestSagaId::new(CorrectSaga::class)); + + Loop::stop(); } ); } @@ -139,6 +145,8 @@ function (): \Generator yield $this->store->save($saga); yield $this->store->save($saga); + + Loop::stop(); } ); } @@ -164,6 +172,8 @@ function (): \Generator $loadedSaga = yield $this->store->obtain($id); self::assertSame($loadedSaga->value(), 'qwerty'); + + Loop::stop(); } ); } @@ -180,6 +190,8 @@ function (): \Generator $saga = new CorrectSaga($id); yield $this->store->update($saga); + + Loop::stop(); } ); }