@@ -24,7 +24,7 @@ public function testBundleInterfaceImplementation()
24
24
{
25
25
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\BundleInterface ' );
26
26
27
- $ kernel = $ this ->getKernel (array ($ bundle ));
27
+ $ kernel = $ this ->getKernel (array ($ bundle ), true );
28
28
29
29
$ application = new Application ($ kernel );
30
30
$ application ->doRun (new ArrayInput (array ('list ' )), new NullOutput ());
@@ -35,7 +35,7 @@ public function testBundleCommandsAreRegistered()
35
35
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\Bundle ' );
36
36
$ bundle ->expects ($ this ->once ())->method ('registerCommands ' );
37
37
38
- $ kernel = $ this ->getKernel (array ($ bundle ));
38
+ $ kernel = $ this ->getKernel (array ($ bundle ), true );
39
39
40
40
$ application = new Application ($ kernel );
41
41
$ application ->doRun (new ArrayInput (array ('list ' )), new NullOutput ());
@@ -49,12 +49,7 @@ public function testBundleCommandsAreRetrievable()
49
49
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\Bundle ' );
50
50
$ bundle ->expects ($ this ->once ())->method ('registerCommands ' );
51
51
52
- $ kernel = $ this ->getMock ('Symfony\Component\HttpKernel\KernelInterface ' );
53
- $ kernel
54
- ->expects ($ this ->any ())
55
- ->method ('getBundles ' )
56
- ->will ($ this ->returnValue (array ($ bundle )))
57
- ;
52
+ $ kernel = $ this ->getKernel (array ($ bundle ));
58
53
59
54
$ application = new Application ($ kernel );
60
55
$ application ->all ();
@@ -68,12 +63,7 @@ public function testBundleSingleCommandIsRetrievable()
68
63
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\Bundle ' );
69
64
$ bundle ->expects ($ this ->once ())->method ('registerCommands ' );
70
65
71
- $ kernel = $ this ->getMock ('Symfony\Component\HttpKernel\KernelInterface ' );
72
- $ kernel
73
- ->expects ($ this ->any ())
74
- ->method ('getBundles ' )
75
- ->will ($ this ->returnValue (array ($ bundle )))
76
- ;
66
+ $ kernel = $ this ->getKernel (array ($ bundle ));
77
67
78
68
$ application = new Application ($ kernel );
79
69
@@ -88,12 +78,7 @@ public function testBundleCommandCanBeFound()
88
78
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\Bundle ' );
89
79
$ bundle ->expects ($ this ->once ())->method ('registerCommands ' );
90
80
91
- $ kernel = $ this ->getMock ('Symfony\Component\HttpKernel\KernelInterface ' );
92
- $ kernel
93
- ->expects ($ this ->any ())
94
- ->method ('getBundles ' )
95
- ->will ($ this ->returnValue (array ($ bundle )))
96
- ;
81
+ $ kernel = $ this ->getKernel (array ($ bundle ));
97
82
98
83
$ application = new Application ($ kernel );
99
84
@@ -108,12 +93,7 @@ public function testBundleCommandCanBeFoundByAlias()
108
93
$ bundle = $ this ->getMock ('Symfony\Component\HttpKernel\Bundle\Bundle ' );
109
94
$ bundle ->expects ($ this ->once ())->method ('registerCommands ' );
110
95
111
- $ kernel = $ this ->getMock ('Symfony\Component\HttpKernel\KernelInterface ' );
112
- $ kernel
113
- ->expects ($ this ->any ())
114
- ->method ('getBundles ' )
115
- ->will ($ this ->returnValue (array ($ bundle )))
116
- ;
96
+ $ kernel = $ this ->getKernel (array ($ bundle ));
117
97
118
98
$ application = new Application ($ kernel );
119
99
@@ -130,7 +110,7 @@ public function testBundleCommandsHaveRightContainer()
130
110
$ command ->setCode (function () {});
131
111
$ command ->expects ($ this ->exactly (2 ))->method ('setContainer ' );
132
112
133
- $ application = new Application ($ this ->getKernel (array ()));
113
+ $ application = new Application ($ this ->getKernel (array (), true ));
134
114
$ application ->setAutoExit (false );
135
115
$ application ->setCatchExceptions (false );
136
116
$ application ->add ($ command );
@@ -143,21 +123,23 @@ public function testBundleCommandsHaveRightContainer()
143
123
$ tester ->run (array ('command ' => 'foo ' ));
144
124
}
145
125
146
- private function getKernel (array $ bundles )
126
+ private function getKernel (array $ bundles, $ useDispatcher = false )
147
127
{
148
- $ dispatcher = $ this ->getMock ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' );
149
- $ dispatcher
150
- ->expects ($ this ->atLeastOnce ())
151
- ->method ('dispatch ' )
152
- ;
153
-
154
128
$ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
155
- $ container
156
- ->expects ($ this ->atLeastOnce ())
157
- ->method ('get ' )
158
- ->with ($ this ->equalTo ('event_dispatcher ' ))
159
- ->will ($ this ->returnValue ($ dispatcher ))
160
- ;
129
+
130
+ if ($ useDispatcher ) {
131
+ $ dispatcher = $ this ->getMock ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' );
132
+ $ dispatcher
133
+ ->expects ($ this ->atLeastOnce ())
134
+ ->method ('dispatch ' )
135
+ ;
136
+ $ container
137
+ ->expects ($ this ->atLeastOnce ())
138
+ ->method ('get ' )
139
+ ->with ($ this ->equalTo ('event_dispatcher ' ))
140
+ ->will ($ this ->returnValue ($ dispatcher ));
141
+ }
142
+
161
143
$ container
162
144
->expects ($ this ->once ())
163
145
->method ('hasParameter ' )
0 commit comments