Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Masiukevich Maksim committed Feb 13, 2021
1 parent 8499009 commit d898302
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Configuration/DefaultEventProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ function (): \Generator

self::assertInstanceOf(SecondEventWithKey::class, $event, get_class($event));
self::assertSame($id->toString(), $event->key);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -158,6 +160,8 @@ function (): \Generator

self::assertInstanceOf(SecondEventWithKey::class, $event);
self::assertSame('qwerty', $event->key);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down Expand Up @@ -365,6 +379,8 @@ function (): \Generator
);

self::assertFalse($stored);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -412,6 +428,8 @@ function (): \Generator
'Identifier class "SomeUnknownClass" specified in the saga "ServiceBus\Sagas\Tests\stubs\CorrectSaga" not found',
$record['message']
);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand Down
26 changes: 26 additions & 0 deletions tests/SagasProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function (): \Generator
$testSaga = new TestSaga(TestSagaId::new(TestSaga::class));

yield $this->sagaProvider->save($testSaga, new TestContext());

Loop::stop();
}
);
}
Expand All @@ -147,6 +149,8 @@ function (): \Generator
$id = TestSagaId::new(TestSaga::class);

yield $this->sagaProvider->start($id, new TestCommand(), new TestContext());

Loop::stop();
}
);
}
Expand All @@ -169,6 +173,8 @@ function (): \Generator
self::assertNotNull($saga);
self::assertInstanceOf(TestSaga::class, $saga);
self::assertSame($id, $saga->id());

Loop::stop();
}
);
}
Expand All @@ -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();
}
);
}
Expand All @@ -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();
}
);
}
Expand All @@ -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();
}
);
}
Expand All @@ -245,6 +257,8 @@ function (): \Generator
$testSaga = new TestSaga(TestSagaId::new(TestSaga::class));

yield $this->sagaProvider->save($testSaga, new TestContext());

Loop::stop();
}
);
}
Expand All @@ -260,6 +274,8 @@ function (): \Generator
self::assertNull(
yield $this->sagaProvider->obtain(TestSagaId::new(TestSaga::class), new TestContext())
);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -291,6 +307,8 @@ function (): \Generator

yield $this->adapter->execute($query->sql(), $query->params());
yield $this->sagaProvider->obtain($id, $context);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -318,6 +336,8 @@ function (): \Generator
$loadedSaga = yield $this->sagaProvider->obtain($id, $context);

self::assertSame($saga->id()->id, $loadedSaga->id()->id);

Loop::stop();
}
);
}
Expand Down Expand Up @@ -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();
}
);
}
Expand All @@ -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();
}
);
}
Expand All @@ -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();
}
);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/Store/SQLSagaStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function (): \Generator
self::assertNotNull($loadedSaga);
self::assertInstanceOf(CorrectSaga::class, $loadedSaga);
self::assertSame($id->id, $loadedSaga->id()->id);

Loop::stop();
}
);
}
Expand All @@ -107,6 +109,8 @@ function (): \Generator
$loadedSaga = yield $this->store->obtain($id);

self::assertNull($loadedSaga);

Loop::stop();
}
);
}
Expand All @@ -120,6 +124,8 @@ public function removeUnExistsSaga(): void
function (): \Generator
{
yield $this->store->remove(TestSagaId::new(CorrectSaga::class));

Loop::stop();
}
);
}
Expand All @@ -139,6 +145,8 @@ function (): \Generator

yield $this->store->save($saga);
yield $this->store->save($saga);

Loop::stop();
}
);
}
Expand All @@ -164,6 +172,8 @@ function (): \Generator
$loadedSaga = yield $this->store->obtain($id);

self::assertSame($loadedSaga->value(), 'qwerty');

Loop::stop();
}
);
}
Expand All @@ -180,6 +190,8 @@ function (): \Generator
$saga = new CorrectSaga($id);

yield $this->store->update($saga);

Loop::stop();
}
);
}
Expand Down

0 comments on commit d898302

Please sign in to comment.