diff --git a/database/migrations/2024_04_16_115559_create_verb_events_table.php b/database/migrations/2024_04_16_115559_create_verb_events_table.php index c3d3b61a..adeb0f0d 100644 --- a/database/migrations/2024_04_16_115559_create_verb_events_table.php +++ b/database/migrations/2024_04_16_115559_create_verb_events_table.php @@ -10,7 +10,7 @@ public function up() { // If they've already migrated under the previous migration name, just skip if (Schema::hasTable($this->tableName())) { - throw new RuntimeException('The create_verbs_* migrations have been renamed. See '); + return; } Schema::create($this->tableName(), function (Blueprint $table) { diff --git a/database/migrations/2024_04_16_115559_create_verb_snapshots_table.php b/database/migrations/2024_04_16_115559_create_verb_snapshots_table.php index 37c4636f..b43299ce 100644 --- a/database/migrations/2024_04_16_115559_create_verb_snapshots_table.php +++ b/database/migrations/2024_04_16_115559_create_verb_snapshots_table.php @@ -1,7 +1,11 @@ tableName())) { - throw new RuntimeException('The create_verbs_* migrations have been renamed. See '); + // If we migrated before Verbs 0.5.0 we need to do a little extra work + $migrating = Schema::hasTable($this->tableName()); - return; + if ($migrating) { + Schema::rename($this->tableName(), '__verbs_snapshots_pre_050'); } Schema::create($this->tableName(), function (Blueprint $table) { @@ -33,11 +37,37 @@ public function up() $table->index(['state_id', 'type']); }); + + if ($migrating) { + DB::table('__verbs_snapshots_pre_050') + ->select('*') + ->chunkById(100, $this->migrateChunk(...)); + } } public function down() { Schema::dropIfExists($this->tableName()); + + if (Schema::hasTable('__verbs_snapshots_pre_050')) { + Schema::rename('__verbs_snapshots_pre_050', $this->tableName()); + } + } + + protected function migrateChunk(Collection $chunk): void + { + $rows = $chunk->map(fn ($row) => [ + 'id' => app(MakesSnowflakes::class)->makeFromTimestamp(Date::parse($row->created_at))->id(), + 'type' => $row->type, + 'state_id' => $row->id, + 'data' => $row->data, + 'last_event_id' => $row->last_event_id, + 'expires_at' => null, + 'created_at' => $row->created_at, + 'updated_at' => $row->updated_at, + ]); + + DB::table($this->tableName())->insert($rows->toArray()); } protected function tableName(): string diff --git a/database/migrations/2024_04_16_115559_create_verb_state_events_table.php b/database/migrations/2024_04_16_115559_create_verb_state_events_table.php index 39cc0c60..ed7c4644 100644 --- a/database/migrations/2024_04_16_115559_create_verb_state_events_table.php +++ b/database/migrations/2024_04_16_115559_create_verb_state_events_table.php @@ -11,7 +11,7 @@ public function up() { // If they've already migrated under the previous migration name, just skip if (Schema::hasTable($this->tableName())) { - throw new RuntimeException('The create_verbs_* migrations have been renamed. See '); + return; } Schema::create($this->tableName(), function (Blueprint $table) { diff --git a/examples/Monopoly/src/Events/Setup/GameStarted.php b/examples/Monopoly/src/Events/Setup/GameStarted.php index 8b6cf46b..2afc3635 100644 --- a/examples/Monopoly/src/Events/Setup/GameStarted.php +++ b/examples/Monopoly/src/Events/Setup/GameStarted.php @@ -25,7 +25,7 @@ public function applyToGame(GameState $game) $game->started = true; $game->started_at = now()->toImmutable(); $game->player_ids = []; - $game->board = new Board(); - $game->bank = new Bank(); + $game->board = new Board; + $game->bank = new Bank; } } diff --git a/examples/Monopoly/src/Game/Spaces/Space.php b/examples/Monopoly/src/Game/Spaces/Space.php index 924db30c..f6d62e3f 100644 --- a/examples/Monopoly/src/Game/Spaces/Space.php +++ b/examples/Monopoly/src/Game/Spaces/Space.php @@ -18,7 +18,7 @@ abstract class Space implements SerializedByVerbs public static function instance(): static { - return self::$instances[static::class] ?? new static(); + return self::$instances[static::class] ?? new static; } public function __construct() diff --git a/examples/Monopoly/tests/MonopolyTest.php b/examples/Monopoly/tests/MonopolyTest.php index 45a3b3e6..aed26fd5 100644 --- a/examples/Monopoly/tests/MonopolyTest.php +++ b/examples/Monopoly/tests/MonopolyTest.php @@ -32,7 +32,7 @@ $player1_id = snowflake_id(); $player2_id = snowflake_id(); - $game_state = verb(new GameStarted())->state(GameState::class); + $game_state = verb(new GameStarted)->state(GameState::class); expect($game_state->started)->toBeTrue() ->and($game_state->board->spaces->count())->toBe(40) diff --git a/src/Event.php b/src/Event.php index 6a60bfff..16129d8d 100644 --- a/src/Event.php +++ b/src/Event.php @@ -43,7 +43,7 @@ public function states(): StateCollection { // TODO: This is a bit hacky, but is probably OK right now - static $map = new WeakMap(); + static $map = new WeakMap; return $map[$this] ??= app(EventStateRegistry::class)->getStates($this); } diff --git a/src/Lifecycle/EventStore.php b/src/Lifecycle/EventStore.php index f18e5639..5a24c5f1 100644 --- a/src/Lifecycle/EventStore.php +++ b/src/Lifecycle/EventStore.php @@ -70,7 +70,7 @@ protected function readEvents( /** @param Event[] $events */ protected function guardAgainstConcurrentWrites(array $events): void { - $max_event_ids = new Collection(); + $max_event_ids = new Collection; $query = VerbStateEvent::query()->toBase(); diff --git a/src/Lifecycle/Guards.php b/src/Lifecycle/Guards.php index a1890d8a..96c2c5ac 100644 --- a/src/Lifecycle/Guards.php +++ b/src/Lifecycle/Guards.php @@ -36,12 +36,12 @@ public function authorize(): static $this->event->failedAuthorization($this->state); } - throw new AuthorizationException(); + throw new AuthorizationException; } public function validate(): static { - $exception = new EventNotValidForCurrentState(); + $exception = new EventNotValidForCurrentState; try { if ($this->passesValidation()) { diff --git a/src/Lifecycle/Hook.php b/src/Lifecycle/Hook.php index 07541f97..ac2515ae 100644 --- a/src/Lifecycle/Hook.php +++ b/src/Lifecycle/Hook.php @@ -48,7 +48,7 @@ public function __construct( public Closure $callback, public array $events = [], public array $states = [], - public SplObjectStorage $phases = new SplObjectStorage(), + public SplObjectStorage $phases = new SplObjectStorage, public ?string $name = null, ) {} diff --git a/src/Lifecycle/MetadataManager.php b/src/Lifecycle/MetadataManager.php index a71d6013..59ad7b23 100644 --- a/src/Lifecycle/MetadataManager.php +++ b/src/Lifecycle/MetadataManager.php @@ -21,8 +21,8 @@ class MetadataManager public function __construct() { - $this->ephemeral = new WeakMap(); - $this->persistent = new WeakMap(); + $this->ephemeral = new WeakMap; + $this->persistent = new WeakMap; } public function createMetadataUsing(?callable $callback = null): void @@ -41,12 +41,12 @@ public function setLastResults(Event $event, Collection $results): static public function getLastResults(Event $event): Collection { - return $this->getEphemeral($event, '_last_results', new Collection()); + return $this->getEphemeral($event, '_last_results', new Collection); } public function getEphemeral(Event|State $target, ?string $key = null, mixed $default = null): mixed { - $ephemeral = data_get($this->ephemeral[$target] ?? [], $key, $not_found = new stdClass()); + $ephemeral = data_get($this->ephemeral[$target] ?? [], $key, $not_found = new stdClass); if ($ephemeral === $not_found) { $this->setEphemeral($target, $key, $default); @@ -88,7 +88,7 @@ public function initialize(Event $event): Metadata protected function makeMetadata(Event $event): Metadata { - $metadata = new Metadata(); + $metadata = new Metadata; foreach ($this->callbacks as $callback) { $result = $callback($metadata, $event); diff --git a/src/Metadata.php b/src/Metadata.php index 5f56bb51..e8257e7d 100644 --- a/src/Metadata.php +++ b/src/Metadata.php @@ -11,7 +11,7 @@ class Metadata implements ArrayAccess public function __construct(array $data = []) { - $this->extra = new Collection(); + $this->extra = new Collection; $this->merge($data); } diff --git a/src/StateFactory.php b/src/StateFactory.php index 938ce852..6023be7d 100644 --- a/src/StateFactory.php +++ b/src/StateFactory.php @@ -39,13 +39,13 @@ public static function new(string $state_class, array $data = []): static /** @param class-string $state_class */ public function __construct( protected string $state_class, - protected Collection $transformations = new Collection(), + protected Collection $transformations = new Collection, protected ?int $count = null, protected int|string|null $id = null, protected bool $singleton = false, protected ?Generator $faker = null, - protected Collection $makeCallbacks = new Collection(), - protected Collection $createCallbacks = new Collection(), + protected Collection $makeCallbacks = new Collection, + protected Collection $createCallbacks = new Collection, ) {} public function definition(): array @@ -114,7 +114,7 @@ public function create(array $data = [], Bits|UuidInterface|AbstractUid|int|stri } if ($this->count < 1) { - return new StateCollection(); + return new StateCollection; } if ($this->count === 1) { diff --git a/src/Support/EventStateRegistry.php b/src/Support/EventStateRegistry.php index b507f719..3bbeefea 100644 --- a/src/Support/EventStateRegistry.php +++ b/src/Support/EventStateRegistry.php @@ -23,8 +23,8 @@ public function __construct( public function getStates(Event $event): StateCollection { - $discovered = new StateCollection(); - $deferred = new StateCollection(); + $discovered = new StateCollection; + $deferred = new StateCollection; foreach ($this->getAttributes($event) as $attribute) { // If there are state dependencies that the attribute relies on that we haven't already diff --git a/src/Support/Normalization/CollectionNormalizer.php b/src/Support/Normalization/CollectionNormalizer.php index b8758f3c..ec4ee066 100644 --- a/src/Support/Normalization/CollectionNormalizer.php +++ b/src/Support/Normalization/CollectionNormalizer.php @@ -27,7 +27,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a $isAssoc = data_get($data, 'associative', false); if ($items === []) { - return new $fqcn(); + return new $fqcn; } $subtype = data_get($data, 'type'); @@ -100,7 +100,7 @@ class_basename($collection), protected function getCollectionMetadata(Collection $collection): array { $only_objects = true; - $types = new Collection(); + $types = new Collection; foreach ($collection as $value) { $only_objects = $only_objects && is_object($value); @@ -121,6 +121,6 @@ protected function getSharedAncestorTypes(Collection $types) ->unique(); return $common->isEmpty() ? $parents : $parents->intersect($common); - }, new Collection()); + }, new Collection); } } diff --git a/src/Support/Reflector.php b/src/Support/Reflector.php index fcd34346..8f65e097 100644 --- a/src/Support/Reflector.php +++ b/src/Support/Reflector.php @@ -70,7 +70,7 @@ public static function getParametersOfType(string $type, ReflectionFunctionAbstr $method = static::reflectFunction($method); if (empty($parameters = $method->getParameters())) { - return new Collection(); + return new Collection; } return collect($parameters) diff --git a/src/Support/Wormhole.php b/src/Support/Wormhole.php index ed74d983..b3cac5d7 100644 --- a/src/Support/Wormhole.php +++ b/src/Support/Wormhole.php @@ -33,12 +33,12 @@ public function realNow(): CarbonInterface public function realMutableNow(): Carbon { - return $this->mutable_now?->copy() ?? Carbon::instance(new DateTime()); + return $this->mutable_now?->copy() ?? Carbon::instance(new DateTime); } public function realImmutableNow(): CarbonImmutable { - return $this->immutable_now ?? CarbonImmutable::instance(new DateTime()); + return $this->immutable_now ?? CarbonImmutable::instance(new DateTime); } public function warp(Event $event, Closure $callback) diff --git a/src/Testing/EventStoreFake.php b/src/Testing/EventStoreFake.php index c16b51fb..508ac711 100644 --- a/src/Testing/EventStoreFake.php +++ b/src/Testing/EventStoreFake.php @@ -26,7 +26,7 @@ class EventStoreFake implements StoresEvents public function __construct( protected MetadataManager $metadata, ) { - $this->events = new Collection(); + $this->events = new Collection; } public function read( @@ -50,7 +50,7 @@ public function read( public function write(array $events): bool { foreach ($events as $event) { - $this->events[$event::class] ??= new Collection(); + $this->events[$event::class] ??= new Collection; $this->events[$event::class]->push($event); } @@ -61,7 +61,7 @@ public function write(array $events): bool public function committed(string $class_name, ?Closure $filter = null): Collection { if (! $this->hasCommitted($class_name)) { - return new Collection(); + return new Collection; } return $this->events[$class_name] diff --git a/src/Testing/SnapshotStoreFake.php b/src/Testing/SnapshotStoreFake.php index a2e6c86a..7667289b 100644 --- a/src/Testing/SnapshotStoreFake.php +++ b/src/Testing/SnapshotStoreFake.php @@ -23,13 +23,13 @@ class SnapshotStoreFake implements StoresSnapshots public function __construct() { - $this->states = new Collection(); + $this->states = new Collection; } public function write(array $states): bool { foreach ($states as $state) { - $this->states[$state::class] ??= new Collection(); + $this->states[$state::class] ??= new Collection; $this->states[$state::class]->put(Id::from($state->id), $state); } @@ -48,7 +48,7 @@ public function loadSingleton(string $type): ?State public function reset(): bool { - $this->states = new Collection(); + $this->states = new Collection; return true; } @@ -88,7 +88,7 @@ protected function assertWrittenTimes(string $class_name, int $times = 1): stati public function written(string $class_name, ?Closure $filter = null): Collection { if (! $this->hasWritten($class_name)) { - return new Collection(); + return new Collection; } return $this->states[$class_name] diff --git a/src/VerbsServiceProvider.php b/src/VerbsServiceProvider.php index a23e71c0..61d0869b 100644 --- a/src/VerbsServiceProvider.php +++ b/src/VerbsServiceProvider.php @@ -103,11 +103,11 @@ public function packageRegistered() $this->app->singleton(PropertyNormalizer::class, function () { $loader = class_exists(AttributeLoader::class) - ? new AttributeLoader() - : new AnnotationLoader(); + ? new AttributeLoader + : new AnnotationLoader; return new PropertyNormalizer( - propertyTypeExtractor: new ReflectionExtractor(), + propertyTypeExtractor: new ReflectionExtractor, classDiscriminatorResolver: new ClassDiscriminatorFromClassMetadata(new ClassMetadataFactory($loader)), ); }); @@ -120,7 +120,7 @@ classDiscriminatorResolver: new ClassDiscriminatorFromClassMetadata(new ClassMet ->map(fn ($class_name) => app($class_name)) ->values() ->all(), - encoders: [new JsonEncoder()], + encoders: [new JsonEncoder], ); }); diff --git a/tests/Feature/SerializationTest.php b/tests/Feature/SerializationTest.php index 807202b2..62363fbc 100644 --- a/tests/Feature/SerializationTest.php +++ b/tests/Feature/SerializationTest.php @@ -70,13 +70,13 @@ it('allows us to store a serializable class as a property', function () { expect(function () { EventWithDto::fire( - dto: new DTO() + dto: new DTO ); })->not->toThrow(TypeError::class); }); it('honors configured context', function () { - $target = new class() + $target = new class { public $is_public = 'public'; diff --git a/tests/Feature/VerbFakesTest.php b/tests/Feature/VerbFakesTest.php index 0b8e4424..86e60706 100644 --- a/tests/Feature/VerbFakesTest.php +++ b/tests/Feature/VerbFakesTest.php @@ -11,11 +11,11 @@ Verbs::assertNothingCommitted(); app(StoresEvents::class)->write([ - $event1 = new VerbFakesTestEvent(), - $event2 = new VerbFakesTestEvent(), - $event3 = new VerbFakesTestEvent(), - $event4 = new VerbFakesTestEvent(), - $event5 = new VerbFakesTestEvent(), + $event1 = new VerbFakesTestEvent, + $event2 = new VerbFakesTestEvent, + $event3 = new VerbFakesTestEvent, + $event4 = new VerbFakesTestEvent, + $event5 = new VerbFakesTestEvent, ]); // assertCommitted() with type-hinted callback diff --git a/tests/Pest.php b/tests/Pest.php index 18e6587c..4fbe4893 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -60,7 +60,7 @@ version_compare(App::version(), '10.38.0', '<') && $db->getQueryGrammar() instanceof SQLiteGrammar ) { - $db->setQueryGrammar(new PatchedSQLiteGrammar()); + $db->setQueryGrammar(new PatchedSQLiteGrammar); } }) ->in(__DIR__, ...$examples); diff --git a/tests/TestCase.php b/tests/TestCase.php index bf6fb35d..1813f4be 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -78,9 +78,9 @@ protected function getExamplePath(?string $path = null): string protected function watchDatabaseQueries(): self { - $formatter = new OutputFormatter(); + $formatter = new OutputFormatter; $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter); - $style = new SymfonyStyle(new ArgvInput(), $output); + $style = new SymfonyStyle(new ArgvInput, $output); DB::listen(function (QueryExecuted $event) use ($style) { $when = now()->toTimeString(); diff --git a/tests/Unit/CollectionNormalizerTest.php b/tests/Unit/CollectionNormalizerTest.php index 59183d9c..4b769faa 100644 --- a/tests/Unit/CollectionNormalizerTest.php +++ b/tests/Unit/CollectionNormalizerTest.php @@ -18,11 +18,11 @@ it('can normalize an empty collection', function () { $serializer = new SymfonySerializer( - normalizers: [$normalizer = new CollectionNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new CollectionNormalizer], + encoders: [new JsonEncoder], ); - $collection = new Collection(); + $collection = new Collection; expect($normalizer->supportsNormalization($collection))->toBeTrue(); @@ -42,11 +42,11 @@ it('can normalize an empty Eloquent collection', function () { $serializer = new SymfonySerializer( - normalizers: [$normalizer = new CollectionNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new CollectionNormalizer], + encoders: [new JsonEncoder], ); - $collection = new EloquentCollection(); + $collection = new EloquentCollection; expect($normalizer->supportsNormalization($collection))->toBeTrue(); @@ -73,8 +73,8 @@ ]; $serializer = new SymfonySerializer( - normalizers: [$normalizer = new CollectionNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new CollectionNormalizer], + encoders: [new JsonEncoder], ); foreach ($collections as $iteration) { @@ -108,8 +108,8 @@ $expected_json = '{"type":"int","items":[[2,2],[1,1],[3,3]],"associative":true}'; $serializer = new SymfonySerializer( - normalizers: [$normalizer = new CollectionNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new CollectionNormalizer], + encoders: [new JsonEncoder], ); // We should be able to normalize @@ -134,12 +134,12 @@ $serializer = new SymfonySerializer( normalizers: [ - $normalizer = new CollectionNormalizer(), - new StateNormalizer(), - new PropertyNormalizer(propertyTypeExtractor: new ReflectionExtractor()), + $normalizer = new CollectionNormalizer, + new StateNormalizer, + new PropertyNormalizer(propertyTypeExtractor: new ReflectionExtractor), ], encoders: [ - new JsonEncoder(), + new JsonEncoder, ], ); @@ -166,13 +166,13 @@ it('can normalize collections of objects that implement SerializedByVerbs', function () { $serializer = new SymfonySerializer( normalizers: [ - $normalizer = new CollectionNormalizer(), - new CarbonNormalizer(), - new SelfSerializingNormalizer(), - new PropertyNormalizer(propertyTypeExtractor: new ReflectionExtractor()), + $normalizer = new CollectionNormalizer, + new CarbonNormalizer, + new SelfSerializingNormalizer, + new PropertyNormalizer(propertyTypeExtractor: new ReflectionExtractor), ], encoders: [ - new JsonEncoder(), + new JsonEncoder, ], ); diff --git a/tests/Unit/ConcurrencyTest.php b/tests/Unit/ConcurrencyTest.php index f0e63918..00dc7fe9 100644 --- a/tests/Unit/ConcurrencyTest.php +++ b/tests/Unit/ConcurrencyTest.php @@ -10,13 +10,13 @@ it('does not throw on sequential events', function () { $store = app(EventStore::class); - $event = new ConcurrencyTestEvent(); + $event = new ConcurrencyTestEvent; $event->id = 1; ConcurrencyTestState::singleton()->last_event_id = 1; $store->write([$event]); - $event2 = new ConcurrencyTestEvent(); + $event2 = new ConcurrencyTestEvent; $event2->id = 2; ConcurrencyTestState::singleton()->last_event_id = 2; @@ -28,13 +28,13 @@ it('throws on non-sequential events', function () { $store = app(EventStore::class); - $event = new ConcurrencyTestEvent(); + $event = new ConcurrencyTestEvent; $event->id = 2; ConcurrencyTestState::singleton()->last_event_id = 2; $store->write([$event]); - $event2 = new ConcurrencyTestEvent(); + $event2 = new ConcurrencyTestEvent; $event2->id = 1; ConcurrencyTestState::singleton()->last_event_id = 1; diff --git a/tests/Unit/ConfigurableTableNamesTest.php b/tests/Unit/ConfigurableTableNamesTest.php index ed0ec8b0..2325bb9f 100644 --- a/tests/Unit/ConfigurableTableNamesTest.php +++ b/tests/Unit/ConfigurableTableNamesTest.php @@ -7,7 +7,7 @@ test('VerbEvent table name can be configured', function () { $expected_table_name = 'verb_events'; - $verb_model = new VerbEvent(); + $verb_model = new VerbEvent; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); @@ -18,7 +18,7 @@ config()->set('verbs.tables.events', $expected_table_name); - $verb_model = new VerbEvent(); + $verb_model = new VerbEvent; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); @@ -27,7 +27,7 @@ test('VerbSnapshot table name can be configured', function () { $expected_table_name = 'verb_snapshots'; - $verb_model = new VerbSnapshot(); + $verb_model = new VerbSnapshot; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); @@ -38,7 +38,7 @@ config(['verbs.tables.snapshots' => $expected_table_name]); - $verb_model = new VerbSnapshot(); + $verb_model = new VerbSnapshot; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); @@ -47,7 +47,7 @@ test('VerbStateEvent table name can be configured', function () { $expected_table_name = 'verb_state_events'; - $verb_model = new VerbStateEvent(); + $verb_model = new VerbStateEvent; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); @@ -58,7 +58,7 @@ config(['verbs.tables.state_events' => $expected_table_name]); - $verb_model = new VerbStateEvent(); + $verb_model = new VerbStateEvent; $actual_table_name = $verb_model->getTable(); expect($expected_table_name)->toBe($actual_table_name); diff --git a/tests/Unit/EventStoreFakeTest.php b/tests/Unit/EventStoreFakeTest.php index 3a85f881..b1e89331 100644 --- a/tests/Unit/EventStoreFakeTest.php +++ b/tests/Unit/EventStoreFakeTest.php @@ -15,11 +15,11 @@ $store->assertNothingCommitted(); $store->write([ - $event1 = new EventStoreFakeTestEvent(), - $event2 = new EventStoreFakeTestEvent(), - $event3 = new EventStoreFakeTestEvent(), - $event4 = new EventStoreFakeTestEvent(), - $event5 = new EventStoreFakeTestEvent(), + $event1 = new EventStoreFakeTestEvent, + $event2 = new EventStoreFakeTestEvent, + $event3 = new EventStoreFakeTestEvent, + $event4 = new EventStoreFakeTestEvent, + $event5 = new EventStoreFakeTestEvent, ]); // committed() and hasCommitted() diff --git a/tests/Unit/ModelNormalizerTest.php b/tests/Unit/ModelNormalizerTest.php index 4ab8309e..b9e3624d 100644 --- a/tests/Unit/ModelNormalizerTest.php +++ b/tests/Unit/ModelNormalizerTest.php @@ -10,17 +10,17 @@ it('throws an exception when trying to serialize a model', function () { $serializer = new SymfonySerializer( - normalizers: [new ModelNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [new ModelNormalizer], + encoders: [new JsonEncoder], ); - $serializer->normalize(new ModelNormalizerTestModel(), 'json'); + $serializer->normalize(new ModelNormalizerTestModel, 'json'); })->throws(DoNotStoreModelsOnEventsOrStates::class); it('denormalizes models', function () { $serializer = new SymfonySerializer( - normalizers: [$normalizer = new ModelNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new ModelNormalizer], + encoders: [new JsonEncoder], ); $identifier = new ModelIdentifier( @@ -49,8 +49,8 @@ class: ModelNormalizerTestModel::class, it('normalizes models when forced to do so', function () { $serializer = new SymfonySerializer( - normalizers: [$normalizer = new ModelNormalizer()], - encoders: [new JsonEncoder()], + normalizers: [$normalizer = new ModelNormalizer], + encoders: [new JsonEncoder], ); ModelNormalizer::dangerouslyAllowModelNormalization(); diff --git a/tests/Unit/StateManagerTest.php b/tests/Unit/StateManagerTest.php index fb15f888..a2d06a39 100644 --- a/tests/Unit/StateManagerTest.php +++ b/tests/Unit/StateManagerTest.php @@ -10,7 +10,7 @@ use Thunk\Verbs\Testing\SnapshotStoreFake; beforeEach(function () { - app()->instance(StoresSnapshots::class, new SnapshotStoreFake()); + app()->instance(StoresSnapshots::class, new SnapshotStoreFake); app()->instance(StoresEvents::class, new EventStoreFake(app(MetadataManager::class))); });