@@ -81,4 +81,99 @@ public function testFactoryConfiguresPluginManagerUnderServiceManagerV2($pluginT
81
81
$ filters = $ factory ->createService ($ container ->reveal ());
82
82
$ this ->assertSame ($ plugin , $ filters ->get ('test ' ));
83
83
}
84
+
85
+ public function testConfiguresInputFilterServicesWhenFound ()
86
+ {
87
+ $ inputFilter = $ this ->prophesize (InputFilterInterface::class)->reveal ();
88
+ $ config = [
89
+ 'input_filters ' => [
90
+ 'aliases ' => [
91
+ 'test ' => 'test-too ' ,
92
+ ],
93
+ 'factories ' => [
94
+ 'test-too ' => function ($ container ) use ($ inputFilter ) {
95
+ return $ inputFilter ;
96
+ },
97
+ ],
98
+ ],
99
+ ];
100
+
101
+ $ container = $ this ->prophesize (ServiceLocatorInterface::class);
102
+ $ container ->willImplement (ContainerInterface::class);
103
+
104
+ $ container ->has ('ServiceListener ' )->willReturn (false );
105
+ $ container ->has ('config ' )->willReturn (true );
106
+ $ container ->get ('config ' )->willReturn ($ config );
107
+
108
+ $ factory = new InputFilterPluginManagerFactory ();
109
+ $ inputFilters = $ factory ($ container ->reveal (), 'InputFilterManager ' );
110
+
111
+ $ this ->assertInstanceOf (InputFilterPluginManager::class, $ inputFilters );
112
+ $ this ->assertTrue ($ inputFilters ->has ('test ' ));
113
+ $ this ->assertSame ($ inputFilter , $ inputFilters ->get ('test ' ));
114
+ $ this ->assertTrue ($ inputFilters ->has ('test-too ' ));
115
+ $ this ->assertSame ($ inputFilter , $ inputFilters ->get ('test-too ' ));
116
+ }
117
+
118
+ public function testDoesNotConfigureInputFilterServicesWhenServiceListenerPresent ()
119
+ {
120
+ $ inputFilter = $ this ->prophesize (InputFilterInterface::class)->reveal ();
121
+ $ config = [
122
+ 'input_filters ' => [
123
+ 'aliases ' => [
124
+ 'test ' => 'test-too ' ,
125
+ ],
126
+ 'factories ' => [
127
+ 'test-too ' => function ($ container ) use ($ inputFilter ) {
128
+ return $ inputFilter ;
129
+ },
130
+ ],
131
+ ],
132
+ ];
133
+
134
+ $ container = $ this ->prophesize (ServiceLocatorInterface::class);
135
+ $ container ->willImplement (ContainerInterface::class);
136
+
137
+ $ container ->has ('ServiceListener ' )->willReturn (true );
138
+ $ container ->has ('config ' )->shouldNotBeCalled ();
139
+ $ container ->get ('config ' )->shouldNotBeCalled ();
140
+
141
+ $ factory = new InputFilterPluginManagerFactory ();
142
+ $ inputFilters = $ factory ($ container ->reveal (), 'InputFilterManager ' );
143
+
144
+ $ this ->assertInstanceOf (InputFilterPluginManager::class, $ inputFilters );
145
+ $ this ->assertFalse ($ inputFilters ->has ('test ' ));
146
+ $ this ->assertFalse ($ inputFilters ->has ('test-too ' ));
147
+ }
148
+
149
+ public function testDoesNotConfigureInputFilterServicesWhenConfigServiceNotPresent ()
150
+ {
151
+ $ container = $ this ->prophesize (ServiceLocatorInterface::class);
152
+ $ container ->willImplement (ContainerInterface::class);
153
+
154
+ $ container ->has ('ServiceListener ' )->willReturn (false );
155
+ $ container ->has ('config ' )->willReturn (false );
156
+ $ container ->get ('config ' )->shouldNotBeCalled ();
157
+
158
+ $ factory = new InputFilterPluginManagerFactory ();
159
+ $ inputFilters = $ factory ($ container ->reveal (), 'InputFilterManager ' );
160
+
161
+ $ this ->assertInstanceOf (InputFilterPluginManager::class, $ inputFilters );
162
+ }
163
+
164
+ public function testDoesNotConfigureInputFilterServicesWhenConfigServiceDoesNotContainInputFiltersConfig ()
165
+ {
166
+ $ container = $ this ->prophesize (ServiceLocatorInterface::class);
167
+ $ container ->willImplement (ContainerInterface::class);
168
+
169
+ $ container ->has ('ServiceListener ' )->willReturn (false );
170
+ $ container ->has ('config ' )->willReturn (true );
171
+ $ container ->get ('config ' )->willReturn (['foo ' => 'bar ' ]);
172
+
173
+ $ factory = new InputFilterPluginManagerFactory ();
174
+ $ inputFilters = $ factory ($ container ->reveal (), 'InputFilterManager ' );
175
+
176
+ $ this ->assertInstanceOf (InputFilterPluginManager::class, $ inputFilters );
177
+ $ this ->assertFalse ($ inputFilters ->has ('foo ' ));
178
+ }
84
179
}
0 commit comments