-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathLookupResolverTest.php
More file actions
66 lines (53 loc) · 2.08 KB
/
Copy pathLookupResolverTest.php
File metadata and controls
66 lines (53 loc) · 2.08 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
<?php
declare(strict_types=1);
namespace Patchlevel\EventSourcing\Tests\Unit\Subscription\Subscriber\ArgumentResolver;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Metadata\Event\EventRegistry;
use Patchlevel\EventSourcing\Metadata\Subscriber\ArgumentMetadata;
use Patchlevel\EventSourcing\Store\Header\IndexHeader;
use Patchlevel\EventSourcing\Store\Store;
use Patchlevel\EventSourcing\Subscription\Lookup\Lookup;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\LookupResolver;
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(LookupResolver::class)]
final class LookupResolverTest extends TestCase
{
public function testSupport(): void
{
$store = $this->createMock(Store::class);
$eventRegistry = new EventRegistry([]);
$resolver = new LookupResolver($store, $eventRegistry);
self::assertTrue(
$resolver->support(
new ArgumentMetadata('lookup', Type::object(Lookup::class)),
ProfileCreated::class,
),
);
self::assertFalse(
$resolver->support(
new ArgumentMetadata('foo', Type::object(ProfileCreated::class)),
ProfileCreated::class,
),
);
}
public function testResolve(): void
{
$event = new ProfileVisited(ProfileId::fromString('1'));
$store = $this->createMock(Store::class);
$eventRegistry = new EventRegistry([]);
$resolver = new LookupResolver($store, $eventRegistry);
$message = (new Message($event))->withHeader(
new IndexHeader(1),
);
$lookup = $resolver->resolve(
new ArgumentMetadata('foo', Type::object(Lookup::class)),
$message,
);
self::assertInstanceOf(Lookup::class, $lookup);
}
}