@@ -25,28 +25,29 @@ public function testShouldBeFinal()
25
25
$ this ->assertClassFinal (BuildConsumptionExtensionsPass::class);
26
26
}
27
27
28
- public function testCouldBeConstructedWithName ()
28
+ public function testCouldBeConstructedWithoutArguments ()
29
29
{
30
- $ pass = new BuildConsumptionExtensionsPass ('aName ' );
31
-
32
- $ this ->assertAttributeSame ('aName ' , 'name ' , $ pass );
30
+ new BuildConsumptionExtensionsPass ();
33
31
}
34
32
35
- public function testThrowIfNameEmptyOnConstruct ()
33
+ public function testThrowIfEnqueueTransportsParameterNotSet ()
36
34
{
37
- $ this ->expectException (\InvalidArgumentException::class);
38
- $ this ->expectExceptionMessage ('The name could not be empty. ' );
39
- new BuildConsumptionExtensionsPass ('' );
35
+ $ pass = new BuildConsumptionExtensionsPass ();
36
+
37
+ $ this ->expectException (\LogicException::class);
38
+ $ this ->expectExceptionMessage ('The "enqueue.transports" parameter must be set. ' );
39
+ $ pass ->process (new ContainerBuilder ());
40
40
}
41
41
42
- public function testShouldDoNothingIfExtensionsServiceIsNotRegistered ()
42
+ public function testThrowsIfNoConsumptionExtensionsServiceFoundForConfiguredTransport ()
43
43
{
44
44
$ container = new ContainerBuilder ();
45
+ $ container ->setParameter ('enqueue.transports ' , ['foo ' , 'bar ' ]);
45
46
46
- //guard
47
- $ this ->assertFalse ($ container ->hasDefinition ('enqueue.transport.aName.consumption_extensions ' ));
47
+ $ pass = new BuildConsumptionExtensionsPass ();
48
48
49
- $ pass = new BuildConsumptionExtensionsPass ('aName ' );
49
+ $ this ->expectException (\LogicException::class);
50
+ $ this ->expectExceptionMessage ('Service "enqueue.transport.foo.consumption_extensions" not found ' );
50
51
$ pass ->process ($ container );
51
52
}
52
53
@@ -56,6 +57,7 @@ public function testShouldRegisterTransportExtension()
56
57
$ extensions ->addArgument ([]);
57
58
58
59
$ container = new ContainerBuilder ();
60
+ $ container ->setParameter ('enqueue.transports ' , ['aName ' ]);
59
61
$ container ->setDefinition ('enqueue.transport.aName.consumption_extensions ' , $ extensions );
60
62
61
63
$ container ->register ('aFooExtension ' , ExtensionInterface::class)
@@ -65,7 +67,7 @@ public function testShouldRegisterTransportExtension()
65
67
->addTag ('enqueue.transport.consumption_extension ' , ['transport ' => 'aName ' ])
66
68
;
67
69
68
- $ pass = new BuildConsumptionExtensionsPass (' aName ' );
70
+ $ pass = new BuildConsumptionExtensionsPass ();
69
71
$ pass ->process ($ container );
70
72
71
73
$ this ->assertInternalType ('array ' , $ extensions ->getArgument (0 ));
@@ -81,6 +83,7 @@ public function testShouldIgnoreOtherTransportExtensions()
81
83
$ extensions ->addArgument ([]);
82
84
83
85
$ container = new ContainerBuilder ();
86
+ $ container ->setParameter ('enqueue.transports ' , ['aName ' ]);
84
87
$ container ->setDefinition ('enqueue.transport.aName.consumption_extensions ' , $ extensions );
85
88
86
89
$ container ->register ('aFooExtension ' , ExtensionInterface::class)
@@ -90,7 +93,7 @@ public function testShouldIgnoreOtherTransportExtensions()
90
93
->addTag ('enqueue.transport.consumption_extension ' , ['transport ' => 'anotherName ' ])
91
94
;
92
95
93
- $ pass = new BuildConsumptionExtensionsPass (' aName ' );
96
+ $ pass = new BuildConsumptionExtensionsPass ();
94
97
$ pass ->process ($ container );
95
98
96
99
$ this ->assertInternalType ('array ' , $ extensions ->getArgument (0 ));
@@ -105,6 +108,7 @@ public function testShouldAddExtensionIfTransportAll()
105
108
$ extensions ->addArgument ([]);
106
109
107
110
$ container = new ContainerBuilder ();
111
+ $ container ->setParameter ('enqueue.transports ' , ['aName ' ]);
108
112
$ container ->setDefinition ('enqueue.transport.aName.consumption_extensions ' , $ extensions );
109
113
110
114
$ container ->register ('aFooExtension ' , ExtensionInterface::class)
@@ -114,7 +118,7 @@ public function testShouldAddExtensionIfTransportAll()
114
118
->addTag ('enqueue.transport.consumption_extension ' , ['transport ' => 'anotherName ' ])
115
119
;
116
120
117
- $ pass = new BuildConsumptionExtensionsPass (' aName ' );
121
+ $ pass = new BuildConsumptionExtensionsPass ();
118
122
$ pass ->process ($ container );
119
123
120
124
$ this ->assertInternalType ('array ' , $ extensions ->getArgument (0 ));
@@ -129,6 +133,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport()
129
133
$ extensions ->addArgument ([]);
130
134
131
135
$ container = new ContainerBuilder ();
136
+ $ container ->setParameter ('enqueue.transports ' , ['default ' ]);
132
137
$ container ->setDefinition ('enqueue.transport.default.consumption_extensions ' , $ extensions );
133
138
134
139
$ container ->register ('aFooExtension ' , ExtensionInterface::class)
@@ -138,7 +143,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport()
138
143
->addTag ('enqueue.transport.consumption_extension ' )
139
144
;
140
145
141
- $ pass = new BuildConsumptionExtensionsPass (' default ' );
146
+ $ pass = new BuildConsumptionExtensionsPass ();
142
147
$ pass ->process ($ container );
143
148
144
149
$ this ->assertInternalType ('array ' , $ extensions ->getArgument (0 ));
@@ -151,6 +156,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport()
151
156
public function testShouldOrderExtensionsByPriority ()
152
157
{
153
158
$ container = new ContainerBuilder ();
159
+ $ container ->setParameter ('enqueue.transports ' , ['default ' ]);
154
160
155
161
$ extensions = new Definition ();
156
162
$ extensions ->addArgument ([]);
@@ -168,7 +174,7 @@ public function testShouldOrderExtensionsByPriority()
168
174
$ extension ->addTag ('enqueue.transport.consumption_extension ' , ['priority ' => 2 ]);
169
175
$ container ->setDefinition ('baz_extension ' , $ extension );
170
176
171
- $ pass = new BuildConsumptionExtensionsPass (' default ' );
177
+ $ pass = new BuildConsumptionExtensionsPass ();
172
178
$ pass ->process ($ container );
173
179
174
180
$ orderedExtensions = $ extensions ->getArgument (0 );
@@ -182,6 +188,7 @@ public function testShouldOrderExtensionsByPriority()
182
188
public function testShouldAssumePriorityZeroIfPriorityIsNotSet ()
183
189
{
184
190
$ container = new ContainerBuilder ();
191
+ $ container ->setParameter ('enqueue.transports ' , ['default ' ]);
185
192
186
193
$ extensions = new Definition ();
187
194
$ extensions ->addArgument ([]);
@@ -199,7 +206,7 @@ public function testShouldAssumePriorityZeroIfPriorityIsNotSet()
199
206
$ extension ->addTag ('enqueue.transport.consumption_extension ' , ['priority ' => -1 ]);
200
207
$ container ->setDefinition ('baz_extension ' , $ extension );
201
208
202
- $ pass = new BuildConsumptionExtensionsPass (' default ' );
209
+ $ pass = new BuildConsumptionExtensionsPass ();
203
210
$ pass ->process ($ container );
204
211
205
212
$ orderedExtensions = $ extensions ->getArgument (0 );
@@ -219,6 +226,7 @@ public function testShouldMergeWithAddedPreviously()
219
226
]);
220
227
221
228
$ container = new ContainerBuilder ();
229
+ $ container ->setParameter ('enqueue.transports ' , ['aName ' ]);
222
230
$ container ->setDefinition ('enqueue.transport.aName.consumption_extensions ' , $ extensions );
223
231
224
232
$ container ->register ('aFooExtension ' , ExtensionInterface::class)
@@ -228,7 +236,7 @@ public function testShouldMergeWithAddedPreviously()
228
236
->addTag ('enqueue.transport.consumption_extension ' )
229
237
;
230
238
231
- $ pass = new BuildConsumptionExtensionsPass (' aName ' );
239
+ $ pass = new BuildConsumptionExtensionsPass ();
232
240
$ pass ->process ($ container );
233
241
234
242
$ this ->assertInternalType ('array ' , $ extensions ->getArgument (0 ));
0 commit comments