diff --git a/src/MapAggregateTypeResolver.php b/src/MapAggregateTypeResolver.php index 4396fca9..f36492eb 100644 --- a/src/MapAggregateTypeResolver.php +++ b/src/MapAggregateTypeResolver.php @@ -4,8 +4,6 @@ namespace Lendable\Aggregate; -use Assert\Assertion; - /** * @phpstan-template TAggregateRoot of object * @@ -18,8 +16,6 @@ final class MapAggregateTypeResolver implements AggregateTypeResolver */ public function __construct(private readonly array $map) { - Assertion::allClassExists(\array_keys($map), 'All map keys must be class names that exist, %s does not exist.'); - Assertion::allIsInstanceOf($map, AggregateType::class, 'All map values must be instances of '.AggregateType::class.', %s is not.'); } public function resolve(object $aggregate): AggregateType diff --git a/tests/unit/MapAggregateTypeResolverTest.php b/tests/unit/MapAggregateTypeResolverTest.php index a79e2f0a..685b61a0 100644 --- a/tests/unit/MapAggregateTypeResolverTest.php +++ b/tests/unit/MapAggregateTypeResolverTest.php @@ -22,29 +22,6 @@ public function it_can_resolve_an_aggregate_type_for_a_mapped_aggregate_root(): $this->assertSame('foo', $fixture->resolve(new \stdClass())->toString()); } - #[Test] - public function throws_if_a_mapped_class_does_not_exist(): void - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('All map keys must be class names that exist, FooBarBaz does not exist.'); - - // @phpstan-ignore-next-line intentional undefined class. - new MapAggregateTypeResolver([\FooBarBaz::class => AggregateType::fromString('FooBarBaz')]); - } - - #[Test] - public function throws_if_a_mapped_value_is_not_an_aggregate_type(): void - { - $badValue = new class () { - }; - - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(\sprintf('All map values must be instances of %s, %s is not', AggregateType::class, $badValue::class)); - - // @phpstan-ignore-next-line intentionally non-compliant value passed. - new MapAggregateTypeResolver([\stdClass::class => $badValue]); - } - #[Test] public function throws_if_cannot_resolve_an_aggregate_as_not_mapped(): void {