Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename schema configurator into doctrine schema configurator #520

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ So that we can actually write the data to a database,
we need the associated schema and databases.

```php
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;

$schemaDirector = new DoctrineSchemaDirector(
$connection,
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$eventStore,
$projectionStore
])
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/projection.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ Using `ChainSchemaConfigurator` we can add multiple schema configurators.
In our case they need the `SchemaConfigurator` from the event store and projection store.

```php
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;

$schemaDirector = new DoctrineSchemaDirector(
$connection
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$eventStore,
$projectionStore
]),
Expand Down
4 changes: 2 additions & 2 deletions src/Outbox/DoctrineOutboxStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
use Patchlevel\EventSourcing\EventBus\HeaderNotFound;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\EventBus\Serializer\MessageSerializer;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Store\WrongQueryResult;

use function array_map;
use function is_int;
use function is_string;

final class DoctrineOutboxStore implements OutboxStore, SchemaConfigurator
final class DoctrineOutboxStore implements OutboxStore, DoctrineSchemaConfigurator
{
public const HEADER_OUTBOX_IDENTIFIER = 'outboxIdentifier';

Expand Down
4 changes: 2 additions & 2 deletions src/Projection/Projection/Store/DoctrineStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Patchlevel\EventSourcing\Projection\Projection\ProjectionNotFound;
use Patchlevel\EventSourcing\Projection\Projection\ProjectionStatus;
use Patchlevel\EventSourcing\Projection\Projection\RunMode;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use Psr\Clock\ClockInterface;

use function array_map;
Expand All @@ -44,7 +44,7 @@
* last_saved_at: string,
* }
*/
final class DoctrineStore implements LockableProjectionStore, SchemaConfigurator
final class DoctrineStore implements LockableProjectionStore, DoctrineSchemaConfigurator
{
public function __construct(
private readonly Connection $connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;

final class ChainSchemaConfigurator implements SchemaConfigurator
final class ChainDoctrineSchemaConfigurator implements DoctrineSchemaConfigurator
{
/** @param iterable<SchemaConfigurator> $schemaConfigurator */
/** @param iterable<DoctrineSchemaConfigurator> $schemaConfigurator */
public function __construct(
private readonly iterable $schemaConfigurator,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;

interface SchemaConfigurator
interface DoctrineSchemaConfigurator
{
public function configureSchema(Schema $schema, Connection $connection): void;
}
2 changes: 1 addition & 1 deletion src/Schema/DoctrineSchemaDirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class DoctrineSchemaDirector implements DryRunSchemaDirector, DoctrineSche
{
public function __construct(
private readonly Connection $connection,
private readonly SchemaConfigurator $schemaConfigurator,
private readonly DoctrineSchemaConfigurator $schemaConfigurator,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Schema/DoctrineSchemaSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class DoctrineSchemaSubscriber implements EventSubscriber
{
public function __construct(
private readonly SchemaConfigurator $schemaConfigurator,
private readonly DoctrineSchemaConfigurator $schemaConfigurator,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Store/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Doctrine\DBAL\Types\Types;
use Patchlevel\EventSourcing\EventBus\HeaderNotFound;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Serializer\EventSerializer;

use function array_fill;
Expand All @@ -24,7 +24,7 @@
use function is_string;
use function sprintf;

final class DoctrineDbalStore implements Store, ArchivableStore, SchemaConfigurator
final class DoctrineDbalStore implements Store, ArchivableStore, DoctrineSchemaConfigurator
{
/**
* PostgreSQL has a limit of 65535 parameters in a single query.
Expand Down
4 changes: 2 additions & 2 deletions tests/Benchmark/ProjectionistBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Patchlevel\EventSourcing\Projection\Projectionist\Projectionist;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Repository\Repository;
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
Expand Down Expand Up @@ -55,7 +55,7 @@ public function setUp(): void

$schemaDirector = new DoctrineSchemaDirector(
$connection,
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$this->store,
$projectionStore,
]),
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Outbox/OutboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Patchlevel\EventSourcing\Outbox\OutboxEventBus;
use Patchlevel\EventSourcing\Outbox\StoreOutboxProcessor;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function testSuccessful(): void

$schemaDirector = new DoctrineSchemaDirector(
$this->connection,
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$store,
$outboxStore,
]),
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Projectionist/ProjectionistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Patchlevel\EventSourcing\Projection\Projectionist\ProjectionistCriteria;
use Patchlevel\EventSourcing\Projection\RetryStrategy\ClockBasedRetryStrategy;
use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager;
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testHappyPath(): void

$schemaDirector = new DoctrineSchemaDirector(
$this->connection,
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$store,
$projectionStore,
]),
Expand Down Expand Up @@ -167,7 +167,7 @@ public function testErrorHandling(): void

$schemaDirector = new DoctrineSchemaDirector(
$this->connection,
new ChainSchemaConfigurator([
new ChainDoctrineSchemaConfigurator([
$store,
$projectionStore,
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/** @covers \Patchlevel\EventSourcing\Schema\ChainSchemaConfigurator */
final class ChainSchemaConfiguratorTest extends TestCase
/** @covers \Patchlevel\EventSourcing\Schema\ChainDoctrineSchemaConfigurator */
final class ChainDoctrineSchemaConfiguratorTest extends TestCase
{
use ProphecyTrait;

Expand All @@ -21,12 +21,12 @@ public function testChain(): void
$schema = $this->prophesize(Schema::class)->reveal();
$connection = $this->prophesize(Connection::class)->reveal();

$configurator1 = $this->prophesize(SchemaConfigurator::class);
$configurator1 = $this->prophesize(DoctrineSchemaConfigurator::class);
$configurator1->configureSchema($schema, $connection)->shouldBeCalledOnce();
$configurator2 = $this->prophesize(SchemaConfigurator::class);
$configurator2 = $this->prophesize(DoctrineSchemaConfigurator::class);
$configurator2->configureSchema($schema, $connection)->shouldBeCalledOnce();

$chain = new ChainSchemaConfigurator([
$chain = new ChainDoctrineSchemaConfigurator([
$configurator1->reveal(),
$configurator2->reveal(),
]);
Expand Down
14 changes: 7 additions & 7 deletions tests/Unit/Schema/DoctrineSchemaDirectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaConfig;
use Doctrine\DBAL\Schema\SchemaDiff;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
Expand All @@ -36,7 +36,7 @@ public function testCreate(): void
$connection->getDatabasePlatform()->willReturn($platform->reveal());
$connection->executeStatement('this is sql!')->shouldBeCalledOnce();

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::type(Schema::class), $connection->reveal())->shouldBeCalledOnce();

$doctrineSchemaManager = new DoctrineSchemaDirector(
Expand All @@ -60,7 +60,7 @@ public function testDryRunCreate(): void
$connection->createSchemaManager()->willReturn($schemaManager->reveal());
$connection->getDatabasePlatform()->willReturn($platform->reveal());

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::type(Schema::class), $connection->reveal())->shouldBeCalledOnce();

$doctrineSchemaManager = new DoctrineSchemaDirector(
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testUpdate(): void
$connection->executeStatement('x')->shouldBeCalledOnce();
$connection->executeStatement('y')->shouldBeCalledOnce();

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::type(Schema::class), $connection->reveal())->shouldBeCalledOnce();

$doctrineSchemaManager = new DoctrineSchemaDirector(
Expand Down Expand Up @@ -128,7 +128,7 @@ public function testDryRunUpdate(): void
$connection->createSchemaManager()->willReturn($schemaManager->reveal());
$connection->getDatabasePlatform()->willReturn($platform->reveal());

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::type(Schema::class), $connection->reveal())->shouldBeCalledOnce();

$doctrineSchemaManager = new DoctrineSchemaDirector(
Expand Down Expand Up @@ -157,7 +157,7 @@ public function testDrop(): void
$connection->executeStatement('DROP TABLE foo;')->shouldBeCalled();
$connection->executeStatement('DROP TABLE bar;')->shouldNotBeCalled();

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::that(static function (Schema $schema) {
$schema->createTable('foo');
$schema->createTable('bar');
Expand Down Expand Up @@ -186,7 +186,7 @@ public function testDryRunDrop(): void
$schemaManager->introspectSchema()->willReturn($currentSchema->reveal());
$connection->createSchemaManager()->willReturn($schemaManager->reveal());

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema(Argument::that(static function (Schema $schema) {
$schema->createTable('foo');
$schema->createTable('bar');
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Schema/DoctrineSchemaSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaConfigurator;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaSubscriber;
use Patchlevel\EventSourcing\Schema\SchemaConfigurator;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

Expand All @@ -25,7 +25,7 @@ public function testPostGenerateSchema(): void
$em->getConnection()->willReturn($connection);
$expectedSchema = new Schema();

$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);
$schemaConfigurator->configureSchema($expectedSchema, $connection)->shouldBeCalled();

$event = new GenerateSchemaEventArgs($em->reveal(), $expectedSchema);
Expand All @@ -36,7 +36,7 @@ public function testPostGenerateSchema(): void

public function testGetSubscribedEvents(): void
{
$schemaConfigurator = $this->prophesize(SchemaConfigurator::class);
$schemaConfigurator = $this->prophesize(DoctrineSchemaConfigurator::class);

$doctrineSchemaSubscriber = new DoctrineSchemaSubscriber($schemaConfigurator->reveal());
$events = $doctrineSchemaSubscriber->getSubscribedEvents();
Expand Down
Loading