7
7
8
8
use Mvc5 \App ;
9
9
use Mvc5 \Config ;
10
- use Mvc5 \Plugin \Maybe ;
11
- use Mvc5 \Plugin \Nothing ;
12
- use Mvc5 \Plugin \Nullable ;
13
- use Mvc5 \Plugin \Plugin ;
14
- use Mvc5 \Plugin \Shared ;
15
10
use Mvc5 \Test \Test \TestCase ;
16
11
17
12
class ContainerTest
@@ -193,19 +188,6 @@ function test_next_iterator()
193
188
$ this ->assertEquals ('bat ' , $ app ->current ());
194
189
}
195
190
196
- /**
197
- *
198
- */
199
- function test_nothing_isset ()
200
- {
201
- $ app = new App ;
202
-
203
- $ app ['foo ' ] = new Nothing ;
204
-
205
- $ this ->assertTrue (isset ($ app ['foo ' ]));
206
- $ this ->assertNull (Maybe::nullable ($ app ['foo ' ]));
207
- }
208
-
209
191
/**
210
192
*
211
193
*/
@@ -222,120 +204,17 @@ function test_null_not_isset()
222
204
/**
223
205
*
224
206
*/
225
- function test_shared_method_returns_nothing ()
226
- {
227
- $ count = 0 ;
228
-
229
- $ app = new App ;
230
-
231
- $ foo = $ app ->shared ('foo ' , function () use (&$ count ) {
232
- ++$ count ;
233
- return new Nothing ;
234
- });
235
-
236
- $ this ->assertInstanceOf (Nothing::class, $ foo );
237
- $ this ->assertNull (Maybe::nullable ($ app ->get ('foo ' )));
238
- $ this ->assertNull (Maybe::nullable ($ app ->shared ('foo ' )));
239
- $ this ->assertEquals (1 , $ count );
240
- }
241
-
242
- /**
243
- *
244
- */
245
- function test_shared_method_returns_null ()
207
+ function test_null_unset ()
246
208
{
247
209
$ app = new App ;
248
210
249
- $ this ->assertNull ($ app ->shared ('foo ' , function () {
250
- return null ;
251
- }));
211
+ $ app ['foo ' ] = 'foobar ' ;
252
212
253
- $ this ->assertFalse ($ app ->has ('foo ' ));
254
- }
213
+ $ this ->assertEquals ('foobar ' , $ app ['foo ' ]);
255
214
256
- /**
257
- *
258
- */
259
- function test_shared_maybe_plugin_returns_nothing ()
260
- {
261
- $ count = 0 ;
262
-
263
- $ app = new App (['services ' => [
264
- 'foo ' => new Maybe (function () use (&$ count ) {
265
- ++$ count ;
266
- return new Nothing ;
267
- }),
268
- 'foobar ' => new Nullable (new Shared ('foo ' ))
269
- ]]);
270
-
271
- $ this ->assertNull ($ app ->plugin ('foobar ' ));
272
- $ this ->assertNull ($ app ->shared ('foobar ' ));
273
- $ this ->assertNull ($ app ->get ('foobar ' ));
274
- $ this ->assertNull ($ app ['foobar ' ]);
275
- $ this ->assertEquals (1 , $ count );
276
- }
277
-
278
- /**
279
- *
280
- */
281
- function test_shared_maybe_plugin_returns_null ()
282
- {
283
- $ count = 0 ;
284
-
285
- $ app = new App (['services ' => [
286
- 'foo ' => new Maybe (function () use (&$ count ) {
287
- ++$ count ;
288
- return null ;
289
- }),
290
- 'foobar ' => new Nullable (new Shared ('foo ' ))
291
- ]]);
292
-
293
- $ this ->assertNull ($ app ->plugin ('foobar ' ));
294
- $ this ->assertNull ($ app ->shared ('foobar ' ));
295
- $ this ->assertNull ($ app ->get ('foobar ' ));
296
- $ this ->assertNull ($ app ['foobar ' ]);
297
- $ this ->assertEquals (1 , $ count );
298
- }
299
-
300
- /**
301
- *
302
- */
303
- function test_shared_plugin_returns_nothing ()
304
- {
305
- $ count = 0 ;
306
-
307
- $ app = new App (['services ' => [
308
- 'foo ' => new Shared ('foo ' , function () use (&$ count ) {
309
- ++$ count ;
310
- return new Nothing ;
311
- }),
312
- 'foobar ' => new Nullable (new Plugin ('foo ' ))
313
- ]]);
314
-
315
- $ this ->assertNull ($ app ->plugin ('foobar ' ));
316
- $ this ->assertNull ($ app ->shared ('foobar ' ));
317
- $ this ->assertNull (Maybe::nullable ($ app ->get ('foo ' )));
318
- $ this ->assertEquals (1 , $ count );
319
- }
320
-
321
- /**
322
- *
323
- */
324
- function test_shared_plugin_returns_null ()
325
- {
326
- $ count = 0 ;
327
-
328
- $ app = new App (['services ' => [
329
- 'foo ' => new Shared ('foo ' , function () use (&$ count ) {
330
- ++$ count ;
331
- return null ;
332
- })
333
- ]]);
215
+ $ app ['foo ' ] = null ;
334
216
335
- $ this ->assertNull ($ app ->plugin ('foo ' ));
336
- $ this ->assertNull ($ app ->shared ('foo ' ));
337
- $ this ->assertNull ($ app ->get ('foo ' ));
338
- $ this ->assertEquals (3 , $ count );
217
+ $ this ->assertNull ($ app ['foo ' ]);
339
218
}
340
219
341
220
/**
0 commit comments