Skip to content

Commit 6ac2173

Browse files
committed
Add table options for subscription store, also add tests folder for phpstan to analyse
1 parent 11fe1cf commit 6ac2173

10 files changed

Lines changed: 80 additions & 3 deletions

File tree

docs/pages/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ patchlevel_event_sourcing:
340340
store:
341341
type: 'custom' # default is 'dbal'
342342
service: 'my_subscription_store'
343+
options:
344+
table_name: 'my_subscription_store'
343345
```
344346
!!! tip
345347

docs/pages/installation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ patchlevel_event_sourcing:
3737
connection:
3838
url: '%env(EVENTSTORE_URL)%'
3939
provide_dedicated_connection: true
40+
store:
41+
type: dbal_stream
42+
merge_orm_schema: true
43+
command_bus:
44+
service: messenger.bus.default
45+
query_bus:
46+
service: messenger.bus.default
47+
cryptography: ~
4048

4149
when@dev:
4250
patchlevel_event_sourcing:
@@ -50,6 +58,8 @@ when@dev:
5058
when@test:
5159
patchlevel_event_sourcing:
5260
subscription:
61+
store:
62+
type: 'static_in_memory'
5363
catch_up: true
5464
throw_on_error: true
5565
run_after_aggregate_save: true

docs/pages/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Usage
22

33
Here you will find some examples of how to use the bundle.
4-
But we provide only examples for specific symfo
4+
But we provide only examples for specific symfony features.
55

66
!!! info
77

phpstan-baseline.neon

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,51 @@ parameters:
55
identifier: argument.type
66
count: 1
77
path: src/DependencyInjection/QueryHandlerCompilerPass.php
8+
9+
-
10+
message: '#^Property Patchlevel\\EventSourcingBundle\\Tests\\Fixtures\\Profile\:\:\$id is never read, only written\.$#'
11+
identifier: property.onlyWritten
12+
count: 1
13+
path: tests/Fixtures/Profile.php
14+
15+
-
16+
message: '#^Property Patchlevel\\EventSourcingBundle\\Tests\\Fixtures\\SnapshotableProfile\:\:\$id is unused\.$#'
17+
identifier: property.unused
18+
count: 1
19+
path: tests/Fixtures/SnapshotableProfile.php
20+
21+
-
22+
message: '#^Call to an undefined method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:getAutoconfiguredAttributes\(\)\.$#'
23+
identifier: method.notFound
24+
count: 1
25+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php
26+
27+
-
28+
message: '#^Cannot access offset ''Patchlevel\\\\EventSourcing\\\\Attribute\\\\Aggregate''\|''Patchlevel\\\\EventSourcing\\\\Attribute\\\\Event'' on mixed\.$#'
29+
identifier: offsetAccess.nonOffsetAccessible
30+
count: 1
31+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php
32+
33+
-
34+
message: '#^Cannot access offset ''bus'' on mixed\.$#'
35+
identifier: offsetAccess.nonOffsetAccessible
36+
count: 3
37+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php
38+
39+
-
40+
message: '#^Cannot access offset ''handles'' on mixed\.$#'
41+
identifier: offsetAccess.nonOffsetAccessible
42+
count: 3
43+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php
44+
45+
-
46+
message: '#^Cannot access offset ''method'' on mixed\.$#'
47+
identifier: offsetAccess.nonOffsetAccessible
48+
count: 2
49+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php
50+
51+
-
52+
message: '#^Trying to invoke mixed but it''s not a callable\.$#'
53+
identifier: callable.nonCallable
54+
count: 1
55+
path: tests/Unit/PatchlevelEventSourcingBundleTest.php

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ parameters:
66
level: max
77
paths:
88
- src
9+
- tests

src/DependencyInjection/Configuration.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
* },
2323
* query_bus: array{enabled: bool, service: string},
2424
* subscription: array{
25-
* store: array{type: string, service: string|null},
25+
* store: array{
26+
* type: string,
27+
* service: string|null,
28+
* options: array{table_name: string}
29+
* },
2630
* retry_strategy?: array{base_delay: int, delay_factor: int, max_attempts: int},
2731
* retry_strategies: array<string, array{type: string, service: string, options: array<string, mixed>}>,
2832
* default_retry_strategy: string,
@@ -197,6 +201,12 @@ public function getConfigTreeBuilder(): TreeBuilder
197201
->defaultValue('dbal')
198202
->end()
199203
->scalarNode('service')->defaultNull()->end()
204+
->arrayNode('options')
205+
->addDefaultsIfNotSet()
206+
->children()
207+
->scalarNode('table_name')->defaultValue('subscriptions')->end()
208+
->end()
209+
->end()
200210
->end()
201211
->end()
202212

src/DependencyInjection/PatchlevelEventSourcingExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ static function (ChildDefinition $definition): void {
488488
$container->register(DoctrineSubscriptionStore::class)
489489
->setArguments([
490490
new Reference('event_sourcing.dbal_connection'),
491+
new Reference('event_sourcing.clock'),
492+
$config['subscription']['store']['options']['table_name'],
491493
])
492494
->addTag('event_sourcing.doctrine_schema_configurator');
493495

tests/Fixtures/Profile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Profile extends BasicAggregateRoot
1616
#[Id]
1717
private CustomId $id;
1818

19+
/** @param Repository<self> $profileRepository */
1920
#[Handle]
2021
public static function create(
2122
CreateProfile $command,

tests/Unit/DataCollector/EventSourcingCollectorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function testCollectData(): void
6868
self::assertEquals(ProfileCreated::class, $message['event_class']);
6969
self::assertEquals('profile.created', $message['event_name']);
7070
self::assertInstanceOf(Data::class, $message['event']);
71-
self::assertIsArray($message['headers']);
7271
self::assertCount(1, $message['headers']);
7372
self::assertInstanceOf(Data::class, $message['headers'][0]);
7473
}

tests/Unit/PatchlevelEventSourcingBundleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
use Patchlevel\EventSourcing\Subscription\Store\SubscriptionStore;
8484
use Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessorRepository;
8585
use Patchlevel\EventSourcingBundle\Command\StoreMigrateCommand;
86+
use Patchlevel\EventSourcingBundle\DependencyInjection\Configuration;
8687
use Patchlevel\EventSourcingBundle\DependencyInjection\PatchlevelEventSourcingExtension;
8788
use Patchlevel\EventSourcingBundle\EventBus\SymfonyEventBus;
8889
use Patchlevel\EventSourcingBundle\PatchlevelEventSourcingBundle;
@@ -1551,6 +1552,9 @@ public function testNamedRepository(): void
15511552
self::assertSame($profileRepository, $namedArgumentProfileRepository);
15521553
}
15531554

1555+
/**
1556+
* @param array{patchlevel_event_sourcing: array<string, mixed>} $config
1557+
*/
15541558
private function compileContainer(ContainerBuilder $container, array $config): void
15551559
{
15561560
$bundle = new PatchlevelEventSourcingBundle();

0 commit comments

Comments
 (0)