1
+ <?php
2
+
3
+ namespace SimpleBus \AsynchronousBundle \Tests \Unit \DependencyInjection ;
4
+
5
+
6
+ use Matthias \SymfonyDependencyInjectionTest \PhpUnit \AbstractExtensionTestCase ;
7
+ use SimpleBus \AsynchronousBundle \DependencyInjection \SimpleBusAsynchronousExtension ;
8
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
9
+
10
+ class SimpleBusAsynchronousExtensionTest extends AbstractExtensionTestCase
11
+ {
12
+ protected function getContainerExtensions ()
13
+ {
14
+ return array (
15
+ new SimpleBusAsynchronousExtension ('simple_bus_asynchronous ' )
16
+ );
17
+ }
18
+
19
+ protected function getMinimalConfiguration ()
20
+ {
21
+ return ['object_serializer_service_id ' =>'my_serializer ' , 'commands ' =>['publisher_service_id ' =>'pusher ' ], 'events ' =>['publisher_service_id ' =>'pusher ' ]];
22
+ }
23
+
24
+
25
+ /**
26
+ * @test
27
+ */
28
+ public function it_uses_strategy_allways_by_default ()
29
+ {
30
+ $ this ->container ->setParameter ('kernel.bundles ' , ['SimpleBusCommandBusBundle ' =>true , 'SimpleBusEventBusBundle ' =>true ]);
31
+ $ this ->load ();
32
+
33
+ $ this ->assertContainerBuilderHasServiceDefinitionWithTag ('simple_bus.asynchronous.always_publishes_messages_middleware ' , 'event_bus_middleware ' , ['priority ' =>0 ]);
34
+ }
35
+
36
+ /**
37
+ * @test
38
+ */
39
+ public function it_uses_strategy_predefined_when_configured ()
40
+ {
41
+ $ this ->container ->setParameter ('kernel.bundles ' , ['SimpleBusCommandBusBundle ' =>true , 'SimpleBusEventBusBundle ' =>true ]);
42
+ $ this ->load (['events ' =>['strategy ' =>'predefined ' ]]);
43
+
44
+ $ this ->assertContainerBuilderHasServiceDefinitionWithTag ('simple_bus.asynchronous.publishes_predefined_messages_middleware ' , 'event_bus_middleware ' , ['priority ' =>0 ]);
45
+ }
46
+
47
+ /**
48
+ * @test
49
+ * @expectedException \LogicException
50
+ * @expectedExceptionMessageRegExp ".*SimpleBusCommandBusBundle.*"
51
+ */
52
+ public function it_throws_exception_if_command_bus_bundle_is_missing ()
53
+ {
54
+ $ this ->container ->setParameter ('kernel.bundles ' , ['SimpleBusEventBusBundle ' =>true ]);
55
+ $ this ->load (['events ' =>['strategy ' =>'predefined ' ]]);
56
+ }
57
+
58
+ /**
59
+ * @test
60
+ * @expectedException \LogicException
61
+ * @expectedExceptionMessageRegExp ".*SimpleBusEventBusBundle.*"
62
+ */
63
+ public function it_throws_exception_if_event_bus_bundle_is_missing ()
64
+ {
65
+ $ this ->container ->setParameter ('kernel.bundles ' , ['SimpleBusCommandBusBundle ' =>true ]);
66
+ $ this ->load (['events ' =>['strategy ' =>'predefined ' ]]);
67
+ }
68
+ }
0 commit comments