@@ -119,162 +119,6 @@ function testUnload() {
119
119
$ this ->assertEquals (array ('Security ' ), $ result , 'enabled components is wrong ' );
120
120
}
121
121
122
- /**
123
- * creates mock classes for testing
124
- *
125
- * @return void
126
- */
127
- protected function _makeMockClasses () {
128
- if (!class_exists ('TriggerMockCookieComponent ' )) {
129
- $ this ->getMock ('CookieComponent ' , array (), array (), 'TriggerMockCookieComponent ' , false );
130
- $ this ->getMock ('SecurityComponent ' , array (), array (), 'TriggerMockSecurityComponent ' , false );
131
- }
132
- }
133
-
134
- /**
135
- * test triggering callbacks.
136
- *
137
- * @return void
138
- */
139
- function testTrigger () {
140
- $ controller = null ;
141
- $ this ->_makeMockClasses ();
142
- $ this ->Components ->load ('TriggerMockCookie ' );
143
- $ this ->Components ->load ('TriggerMockSecurity ' );
144
-
145
- $ this ->Components ->TriggerMockCookie ->expects ($ this ->once ())->method ('startup ' )
146
- ->with (null );
147
- $ this ->Components ->TriggerMockSecurity ->expects ($ this ->once ())->method ('startup ' )
148
- ->with (null );
149
-
150
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockCookie ;
151
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockSecurity ;
152
-
153
- $ this ->assertNull ($ this ->Components ->trigger ('startup ' , array (&$ controller )));
154
- }
155
-
156
- /**
157
- * test that the initalize callback is triggered on all components even those that are disabled.
158
- *
159
- * @return void
160
- */
161
- function testTriggerWithTriggerDisabledObjects () {
162
- $ controller = 'Not a controller ' ;
163
-
164
- $ this ->_makeMockClasses ();
165
- $ this ->Components ->load ('TriggerMockCookie ' , array (), false );
166
- $ this ->Components ->load ('TriggerMockSecurity ' );
167
-
168
- $ this ->Components ->TriggerMockCookie ->expects ($ this ->once ())->method ('initialize ' )
169
- ->with ($ controller );
170
- $ this ->Components ->TriggerMockSecurity ->expects ($ this ->once ())->method ('initialize ' )
171
- ->with ($ controller );
172
-
173
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockCookie ;
174
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockSecurity ;
175
-
176
- $ result = $ this ->Components ->trigger ('initialize ' , array (&$ controller ), array ('triggerDisabled ' => true ));
177
- $ this ->assertNull ($ result );
178
- }
179
-
180
- /**
181
- * test trigger and disabled helpers.
182
- *
183
- * @return void
184
- */
185
- function testTriggerWithDisabledComponents () {
186
- $ controller = null ;
187
- $ this ->_makeMockClasses ();
188
- $ this ->Components ->load ('TriggerMockCookie ' );
189
- $ this ->Components ->load ('TriggerMockSecurity ' );
190
-
191
- $ this ->Components ->TriggerMockCookie ->expects ($ this ->once ())->method ('startup ' )
192
- ->with ($ controller );
193
- $ this ->Components ->TriggerMockSecurity ->expects ($ this ->never ())->method ('startup ' );
194
-
195
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockCookie ;
196
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockSecurity ;
197
-
198
- $ this ->Components ->disable ('TriggerMockSecurity ' );
199
-
200
- $ this ->assertNull ($ this ->Components ->trigger ('startup ' , array (&$ controller )));
201
- }
202
-
203
- /**
204
- * test that the collectReturn option works.
205
- *
206
- * @return void
207
- */
208
- function testTriggerWithCollectReturn () {
209
- $ controller = null ;
210
- $ this ->_makeMockClasses ();
211
- $ this ->Components ->load ('TriggerMockCookie ' );
212
- $ this ->Components ->load ('TriggerMockSecurity ' );
213
-
214
- $ this ->Components ->TriggerMockCookie ->expects ($ this ->once ())->method ('startup ' )
215
- ->will ($ this ->returnValue (array ('one ' , 'two ' )));
216
- $ this ->Components ->TriggerMockSecurity ->expects ($ this ->once ())->method ('startup ' )
217
- ->will ($ this ->returnValue (array ('three ' , 'four ' )));
218
-
219
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockCookie ;
220
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockSecurity ;
221
-
222
- $ result = $ this ->Components ->trigger ('startup ' , array (&$ controller ), array ('collectReturn ' => true ));
223
- $ expected = array (
224
- array ('one ' , 'two ' ),
225
- array ('three ' , 'four ' )
226
- );
227
- $ this ->assertEquals ($ expected , $ result );
228
- }
229
-
230
- /**
231
- * test that trigger with break & breakOn works.
232
- *
233
- * @return void
234
- */
235
- function testTriggerWithBreak () {
236
- $ controller = null ;
237
- $ this ->_makeMockClasses ();
238
- $ this ->Components ->load ('TriggerMockCookie ' );
239
- $ this ->Components ->load ('TriggerMockSecurity ' );
240
-
241
- $ this ->Components ->TriggerMockCookie ->expects ($ this ->once ())->method ('startup ' )
242
- ->will ($ this ->returnValue (false ));
243
- $ this ->Components ->TriggerMockSecurity ->expects ($ this ->never ())->method ('startup ' );
244
-
245
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockCookie ;
246
- $ this ->mockObjects [] = $ this ->Components ->TriggerMockSecurity ;
247
-
248
- $ result = $ this ->Components ->trigger (
249
- 'startup ' ,
250
- array (&$ controller ),
251
- array ('break ' => true , 'breakOn ' => false )
252
- );
253
- $ this ->assertFalse ($ result );
254
- }
255
-
256
- /**
257
- * test normalizeObjectArray
258
- *
259
- * @return void
260
- */
261
- function testnormalizeObjectArray () {
262
- $ components = array (
263
- 'Html ' ,
264
- 'Foo.Bar ' => array ('one ' , 'two ' ),
265
- 'Something ' ,
266
- 'Banana.Apple ' => array ('foo ' => 'bar ' )
267
- );
268
- $ result = ComponentCollection::normalizeObjectArray ($ components );
269
- $ expected = array (
270
- 'Html ' => array ('class ' => 'Html ' , 'settings ' => array ()),
271
- 'Bar ' => array ('class ' => 'Foo.Bar ' , 'settings ' => array ('one ' , 'two ' )),
272
- 'Something ' => array ('class ' => 'Something ' , 'settings ' => array ()),
273
- 'Apple ' => array ('class ' => 'Banana.Apple ' , 'settings ' => array ('foo ' => 'bar ' )),
274
- );
275
- $ this ->assertEquals ($ expected , $ result );
276
- }
277
-
278
122
/**
279
123
* test getting the controller out of the collection
280
124
*
0 commit comments