9
9
use Mvc5 \Plugin \Maybe ;
10
10
use Mvc5 \Plugin \Nothing ;
11
11
use Mvc5 \Plugin \Nullable ;
12
+ use Mvc5 \Plugin \Plug ;
12
13
use Mvc5 \Plugin \Plugin ;
13
14
use Mvc5 \Test \Test \TestCase ;
14
15
@@ -24,46 +25,50 @@ function test()
24
25
25
26
$ this ->assertEquals ([$ maybe , '__invoke ' ], $ maybe ->config ());
26
27
$ this ->assertEquals (['foo ' ], $ maybe ->args ());
28
+ $ this ->assertInstanceOf (Nothing::class, (new Maybe )());
27
29
}
28
30
29
31
/**
30
32
*
31
33
*/
32
- function test_plugin_returns_false ()
34
+ function test_custom_default ()
33
35
{
34
- $ app = new App (['services ' => [
35
- 'foo ' => new Maybe (false )
36
- ]]);
36
+ $ this ->assertEquals ('bar ' , (new App )(new Maybe (null , 'bar ' )));
37
+ }
37
38
38
- $ this ->assertFalse ($ app ['foo ' ]);
39
- $ this ->assertFalse ($ app ->plugin ('foo ' ));
39
+ /**
40
+ *
41
+ */
42
+ function test_default ()
43
+ {
44
+ $ this ->assertInstanceOf (Nothing::class, (new Maybe )());
40
45
}
41
46
42
47
/**
43
48
*
44
49
*/
45
- function test_plugin_returns_null ()
50
+ function test_null ()
46
51
{
47
52
$ app = new App (['services ' => [
48
53
'foo ' => new Maybe (null ),
49
54
'foobar ' => new Nullable (new Plugin ('foo ' ))
50
55
]]);
51
56
52
- $ this ->assertNull ($ app ['foobar ' ]);
53
57
$ this ->assertInstanceOf (Nothing::class, $ app ['foo ' ]);
54
- $ this ->assertInstanceOf (Nothing::class, $ app-> plugin ( ' foo ' ) );
58
+ $ this ->assertNull ( $ app[ ' foobar ' ] );
55
59
}
56
60
57
61
/**
58
62
*
59
63
*/
60
- function test_plugin_returns_something ()
64
+ function test_not_null ()
61
65
{
62
66
$ app = new App (['services ' => [
63
- 'foo ' => new Maybe ('foobar ' )
67
+ 'foo ' => new Maybe ('foobar ' ),
68
+ 'foobar ' => new Nullable (new Plug ('foo ' ))
64
69
]]);
65
70
66
71
$ this ->assertEquals ('foobar ' , $ app ['foo ' ]);
67
- $ this ->assertEquals ('foobar ' , $ app-> plugin ( ' foo ' ) );
72
+ $ this ->assertEquals ('foobar ' , $ app[ ' foobar ' ] );
68
73
}
69
74
}
0 commit comments