@@ -31,11 +31,28 @@ public function testItShouldCreateNewInstancesOfEventDispatcher(): void
31
31
{
32
32
$ this ->givenAConfigProvider ();
33
33
$ this ->havingAContainerWithConfig ();
34
+ $ this ->havingListenersConfiguredToReceiveAnEvent ();
34
35
$ this ->whenEventDispatcherFactoryIsInvoked ();
35
36
$ this ->thenItReturnsInstanceOfEventDispatcher ();
36
37
$ this ->andThenDispatcherShouldDispatchAnEvent ();
37
38
}
38
39
40
+ public function testItShouldCreateNewInstancesOfEventDispatcherAlsoWithIncompleteConfiguration (): void
41
+ {
42
+ $ this ->givenAnIncompleteConfigProvider ();
43
+ $ this ->havingAContainerWithConfig ();
44
+ $ this ->whenEventDispatcherFactoryIsInvoked ();
45
+ $ this ->thenItReturnsInstanceOfEventDispatcher ();
46
+ }
47
+
48
+ public function testItShouldCreateNewInstancesOfEventDispatcherAlsoWithMoreIncompleteConfiguration (): void
49
+ {
50
+ $ this ->givenAMoreIncompleteConfigProvider ();
51
+ $ this ->havingAContainerWithConfig ();
52
+ $ this ->whenEventDispatcherFactoryIsInvoked ();
53
+ $ this ->thenItReturnsInstanceOfEventDispatcher ();
54
+ }
55
+
39
56
private function givenAConfigProvider (): void
40
57
{
41
58
$ config = new ConfigProvider ();
@@ -51,6 +68,28 @@ private function givenAConfigProvider(): void
51
68
]);
52
69
}
53
70
71
+ private function givenAnIncompleteConfigProvider (): void
72
+ {
73
+ $ config = new ConfigProvider ();
74
+ $ this ->config = array_merge ($ config ->__invoke (), [
75
+ 'app-events ' => [
76
+ 'event-listeners ' => [
77
+ TestEvent::class => null
78
+ ]
79
+ ]
80
+ ]);
81
+ }
82
+
83
+ private function givenAMoreIncompleteConfigProvider (): void
84
+ {
85
+ $ config = new ConfigProvider ();
86
+ $ this ->config = array_merge ($ config ->__invoke (), [
87
+ 'app-events ' => [
88
+ 'event-listeners ' => null
89
+ ]
90
+ ]);
91
+ }
92
+
54
93
private function havingAContainerWithConfig (): void
55
94
{
56
95
$ this ->container = $ this ->createMock (ContainerInterface::class);
@@ -59,6 +98,10 @@ private function havingAContainerWithConfig(): void
59
98
->method ('get ' )
60
99
->with ('config ' )
61
100
->willReturn ($ this ->config );
101
+ }
102
+
103
+ private function havingListenersConfiguredToReceiveAnEvent (): void
104
+ {
62
105
$ this ->container
63
106
->expects ($ this ->at (1 ))
64
107
->method ('get ' )
0 commit comments