-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathEventArgumentResolverTest.php
More file actions
73 lines (61 loc) · 2.24 KB
/
Copy pathEventArgumentResolverTest.php
File metadata and controls
73 lines (61 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\EventArgumentResolver;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileVisited;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\TypeInfo\Type;
#[CoversClass(EventArgumentResolver::class)]
final class EventArgumentResolverTest extends TestCase
{
public function testSupport(): void
{
$resolver = new EventArgumentResolver();
self::assertTrue(
$resolver->support(
new ArgumentMetadata('foo', Type::object(ProfileCreated::class)),
ProfileCreated::class,
),
);
self::assertFalse(
$resolver->support(
new ArgumentMetadata('foo', Type::object(ProfileVisited::class)),
ProfileCreated::class,
),
);
}
public function testSupportUnionType(): void
{
$resolver = new EventArgumentResolver();
self::assertTrue(
$resolver->support(
new ArgumentMetadata('foo', Type::union(Type::object(ProfileCreated::class), Type::object(ProfileVisited::class))),
ProfileCreated::class,
),
);
self::assertTrue(
$resolver->support(
new ArgumentMetadata('foo', Type::union(Type::object(ProfileCreated::class), Type::object(ProfileVisited::class))),
ProfileVisited::class,
),
);
}
public function testResolve(): void
{
$event = new ProfileVisited(ProfileId::fromString('1'));
$resolver = new EventArgumentResolver();
$message = new Message($event);
self::assertSame(
$event,
$resolver->resolve(
new ArgumentMetadata('foo', Type::object(ProfileVisited::class)),
$message,
),
);
}
}