Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Feb 6, 2024
1 parent 3b27e06 commit 1fffb79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
xsi:noNamespaceSchemaLocation="/vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<testsuites>
<testsuite name="unit">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function testDeserialize(): void
], $message->headers());
}

public function testDeserializeEncodeFailed(): void
public function testDeserializeDecodeFailed(): void
{
$this->expectException(DeserializeFailed::class);

$nativeSerializer = new PhpNativeMessageSerializer();

$nativeSerializer->deserialize('FOO');
$nativeSerializer->deserialize('!@#%$^&*()');
}

public function testDeserializeNotAMessage(): void
Expand Down
44 changes: 16 additions & 28 deletions tests/Unit/Outbox/DoctrineOutboxStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -212,38 +210,28 @@ public function testRetrieveOutboxMessages(): void
public function testConfigureSchema(): void
{
$connection = $this->prophesize(Connection::class);

$serializer = $this->prophesize(MessageSerializer::class);

$doctrineOutboxStore = new DoctrineOutboxStore(
$connection->reveal(),
$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);
}
}

0 comments on commit 1fffb79

Please sign in to comment.