From e7275ae3a849312b68ae5c21100017a011b2e45c Mon Sep 17 00:00:00 2001 From: David Badura Date: Tue, 6 Feb 2024 19:04:26 +0100 Subject: [PATCH] fix tests --- tests/Unit/Outbox/DoctrineOutboxStoreTest.php | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/tests/Unit/Outbox/DoctrineOutboxStoreTest.php b/tests/Unit/Outbox/DoctrineOutboxStoreTest.php index 83d7429f8..edf1155d1 100644 --- a/tests/Unit/Outbox/DoctrineOutboxStoreTest.php +++ b/tests/Unit/Outbox/DoctrineOutboxStoreTest.php @@ -8,9 +8,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Query\QueryBuilder; -use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Types; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\EventBus\Serializer\MessageSerializer; @@ -212,7 +210,6 @@ public function testRetrieveOutboxMessages(): void public function testConfigureSchema(): void { $connection = $this->prophesize(Connection::class); - $serializer = $this->prophesize(MessageSerializer::class); $doctrineOutboxStore = new DoctrineOutboxStore( @@ -220,30 +217,21 @@ public function testConfigureSchema(): void $serializer->reveal(), ); - $table = $this->prophesize(Table::class); - $column = $this->prophesize(Column::class); - $table->addColumn('id', Types::INTEGER)->shouldBeCalledOnce() - ->willReturn( - $column - ->setNotnull(true)->shouldBeCalledOnce() - ->getObjectProphecy()->setAutoincrement(true)->shouldBeCalledOnce()->willReturn($column->reveal()) - ->getObjectProphecy()->reveal(), - ); - - $column = $this->prophesize(Column::class); - $table->addColumn('message', Types::TEXT)->shouldBeCalledOnce() - ->willReturn( - $column - ->setNotnull(true)->shouldBeCalledOnce() - ->getObjectProphecy()->setLength(16_000)->shouldBeCalledOnce()->willReturn($column->reveal()) - ->getObjectProphecy()->reveal(), - ); - - $table->setPrimaryKey(['id'])->shouldBeCalledOnce(); - - $schema = $this->prophesize(Schema::class); - $schema->createTable('outbox')->shouldBeCalledOnce()->willReturn($table->reveal()); - - $doctrineOutboxStore->configureSchema($schema->reveal(), $connection->reveal()); + $expectedSchema = new Schema(); + $table = $expectedSchema->createTable('outbox'); + + $table->addColumn('id', Types::INTEGER) + ->setNotnull(true) + ->setAutoincrement(true); + $table->addColumn('message', Types::STRING) + ->setNotnull(true) + ->setLength(16_000); + + $table->setPrimaryKey(['id']); + + $schema = new Schema(); + $doctrineOutboxStore->configureSchema($schema, $connection->reveal()); + + $this->assertEquals($expectedSchema, $schema); } }