@@ -29,29 +29,36 @@ public function testShouldBeFinal()
29
29
$ this ->assertClassFinal (BuildTopicSubscriberRoutesPass::class);
30
30
}
31
31
32
- public function testCouldBeConstructedWithName ()
32
+ public function testCouldBeConstructedWithoutArguments ()
33
33
{
34
- $ pass = new BuildTopicSubscriberRoutesPass ('aName ' );
35
-
36
- $ this ->assertAttributeSame ('aName ' , 'name ' , $ pass );
34
+ new BuildTopicSubscriberRoutesPass ();
37
35
}
38
36
39
- public function testThrowIfNameEmptyOnConstruct ()
37
+ public function testThrowIfEnqueueClientsParameterNotSet ()
40
38
{
41
- $ this ->expectException (\InvalidArgumentException::class);
42
- $ this ->expectExceptionMessage ('The name could not be empty. ' );
43
- new BuildTopicSubscriberRoutesPass ('' );
39
+ $ pass = new BuildTopicSubscriberRoutesPass ();
40
+
41
+ $ this ->expectException (\LogicException::class);
42
+ $ this ->expectExceptionMessage ('The "enqueue.clients" parameter must be set. ' );
43
+ $ pass ->process (new ContainerBuilder ());
44
44
}
45
45
46
- public function testShouldDoNothingIfRouteCollectionServiceIsNotRegistered ()
46
+ public function testThrowsIfNoRouteCollectionServiceFoundForConfiguredTransport ()
47
47
{
48
- $ pass = new BuildTopicSubscriberRoutesPass ('aName ' );
49
- $ pass ->process (new ContainerBuilder ());
48
+ $ container = new ContainerBuilder ();
49
+ $ container ->setParameter ('enqueue.clients ' , ['foo ' , 'bar ' ]);
50
+
51
+ $ pass = new BuildTopicSubscriberRoutesPass ();
52
+
53
+ $ this ->expectException (\LogicException::class);
54
+ $ this ->expectExceptionMessage ('Service "enqueue.client.foo.route_collection" not found ' );
55
+ $ pass ->process ($ container );
50
56
}
51
57
52
58
public function testThrowIfTaggedProcessorIsBuiltByFactory ()
53
59
{
54
60
$ container = new ContainerBuilder ();
61
+ $ container ->setParameter ('enqueue.clients ' , ['aName ' ]);
55
62
$ container ->register ('enqueue.client.aName.route_collection ' , RouteCollection::class)
56
63
->addArgument ([])
57
64
;
@@ -60,7 +67,7 @@ public function testThrowIfTaggedProcessorIsBuiltByFactory()
60
67
->addTag ('enqueue.topic_subscriber ' )
61
68
;
62
69
63
- $ pass = new BuildTopicSubscriberRoutesPass (' aName ' );
70
+ $ pass = new BuildTopicSubscriberRoutesPass ();
64
71
65
72
$ this ->expectException (\LogicException::class);
66
73
$ this ->expectExceptionMessage ('The topic subscriber tag could not be applied to a service created by factory. ' );
@@ -73,6 +80,7 @@ public function testShouldRegisterProcessorWithMatchedName()
73
80
$ routeCollection ->addArgument ([]);
74
81
75
82
$ container = new ContainerBuilder ();
83
+ $ container ->setParameter ('enqueue.clients ' , ['foo ' ]);
76
84
$ container ->setDefinition ('enqueue.client.foo.route_collection ' , $ routeCollection );
77
85
$ container ->register ('aFooProcessor ' , get_class ($ this ->createTopicSubscriberProcessor ()))
78
86
->addTag ('enqueue.topic_subscriber ' , ['client ' => 'foo ' ])
@@ -81,7 +89,7 @@ public function testShouldRegisterProcessorWithMatchedName()
81
89
->addTag ('enqueue.topic_subscriber ' , ['client ' => 'bar ' ])
82
90
;
83
91
84
- $ pass = new BuildTopicSubscriberRoutesPass (' foo ' );
92
+ $ pass = new BuildTopicSubscriberRoutesPass ();
85
93
86
94
$ pass ->process ($ container );
87
95
@@ -95,6 +103,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient()
95
103
$ routeCollection ->addArgument ([]);
96
104
97
105
$ container = new ContainerBuilder ();
106
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
98
107
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
99
108
$ container ->register ('aFooProcessor ' , get_class ($ this ->createTopicSubscriberProcessor ()))
100
109
->addTag ('enqueue.topic_subscriber ' )
@@ -103,7 +112,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient()
103
112
->addTag ('enqueue.topic_subscriber ' , ['client ' => 'bar ' ])
104
113
;
105
114
106
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
115
+ $ pass = new BuildTopicSubscriberRoutesPass ();
107
116
108
117
$ pass ->process ($ container );
109
118
@@ -117,6 +126,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll()
117
126
$ routeCollection ->addArgument ([]);
118
127
119
128
$ container = new ContainerBuilder ();
129
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
120
130
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
121
131
$ container ->register ('aFooProcessor ' , get_class ($ this ->createTopicSubscriberProcessor ()))
122
132
->addTag ('enqueue.topic_subscriber ' , ['client ' => 'all ' ])
@@ -125,7 +135,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll()
125
135
->addTag ('enqueue.topic_subscriber ' , ['client ' => 'bar ' ])
126
136
;
127
137
128
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
138
+ $ pass = new BuildTopicSubscriberRoutesPass ();
129
139
130
140
$ pass ->process ($ container );
131
141
@@ -141,12 +151,13 @@ public function testShouldRegisterProcessorIfTopicsIsString()
141
151
$ processor = $ this ->createTopicSubscriberProcessor ('fooTopic ' );
142
152
143
153
$ container = new ContainerBuilder ();
154
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
144
155
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
145
156
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
146
157
->addTag ('enqueue.topic_subscriber ' )
147
158
;
148
159
149
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
160
+ $ pass = new BuildTopicSubscriberRoutesPass ();
150
161
$ pass ->process ($ container );
151
162
152
163
$ this ->assertInternalType ('array ' , $ routeCollection ->getArgument (0 ));
@@ -173,12 +184,13 @@ public function testThrowIfTopicSubscriberReturnsNothing()
173
184
$ processor = $ this ->createTopicSubscriberProcessor (null );
174
185
175
186
$ container = new ContainerBuilder ();
187
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
176
188
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
177
189
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
178
190
->addTag ('enqueue.topic_subscriber ' )
179
191
;
180
192
181
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
193
+ $ pass = new BuildTopicSubscriberRoutesPass ();
182
194
183
195
$ this ->expectException (\LogicException::class);
184
196
$ this ->expectExceptionMessage ('Topic subscriber must return something. ' );
@@ -193,12 +205,13 @@ public function testShouldRegisterProcessorIfTopicsAreStrings()
193
205
$ processor = $ this ->createTopicSubscriberProcessor (['fooTopic ' , 'barTopic ' ]);
194
206
195
207
$ container = new ContainerBuilder ();
208
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
196
209
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
197
210
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
198
211
->addTag ('enqueue.topic_subscriber ' )
199
212
;
200
213
201
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
214
+ $ pass = new BuildTopicSubscriberRoutesPass ();
202
215
$ pass ->process ($ container );
203
216
204
217
$ this ->assertInternalType ('array ' , $ routeCollection ->getArgument (0 ));
@@ -234,12 +247,13 @@ public function testShouldRegisterProcessorIfTopicsAreParamArrays()
234
247
]);
235
248
236
249
$ container = new ContainerBuilder ();
250
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
237
251
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
238
252
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
239
253
->addTag ('enqueue.topic_subscriber ' )
240
254
;
241
255
242
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
256
+ $ pass = new BuildTopicSubscriberRoutesPass ();
243
257
$ pass ->process ($ container );
244
258
245
259
$ this ->assertInternalType ('array ' , $ routeCollection ->getArgument (0 ));
@@ -274,12 +288,13 @@ public function testThrowIfTopicSubscriberParamsInvalid()
274
288
$ processor = $ this ->createTopicSubscriberProcessor (['fooBar ' , true ]);
275
289
276
290
$ container = new ContainerBuilder ();
291
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
277
292
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
278
293
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
279
294
->addTag ('enqueue.topic_subscriber ' )
280
295
;
281
296
282
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
297
+ $ pass = new BuildTopicSubscriberRoutesPass ();
283
298
284
299
$ this ->expectException (\LogicException::class);
285
300
$ this ->expectExceptionMessage ('Topic subscriber configuration is invalid ' );
@@ -297,12 +312,13 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection()
297
312
$ processor = $ this ->createTopicSubscriberProcessor (['fooTopic ' ]);
298
313
299
314
$ container = new ContainerBuilder ();
315
+ $ container ->setParameter ('enqueue.clients ' , ['default ' ]);
300
316
$ container ->setDefinition ('enqueue.client.default.route_collection ' , $ routeCollection );
301
317
$ container ->register ('aFooProcessor ' , get_class ($ processor ))
302
318
->addTag ('enqueue.topic_subscriber ' )
303
319
;
304
320
305
- $ pass = new BuildTopicSubscriberRoutesPass (' default ' );
321
+ $ pass = new BuildTopicSubscriberRoutesPass ();
306
322
$ pass ->process ($ container );
307
323
308
324
$ this ->assertInternalType ('array ' , $ routeCollection ->getArgument (0 ));
0 commit comments