Skip to content

Commit 6ea81a8

Browse files
committed
fixed obsolete getMock() usage
1 parent 6770545 commit 6ea81a8

25 files changed

+115
-145
lines changed

Tests/Command/RouterDebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private function getContainer()
6363
{
6464
$routeCollection = new RouteCollection();
6565
$routeCollection->add('foo', new Route('foo'));
66-
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
66+
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
6767
$router
6868
->expects($this->any())
6969
->method('getRouteCollection')
@@ -74,7 +74,7 @@ private function getContainer()
7474
->disableOriginalConstructor()
7575
->getMock();
7676

77-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
77+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
7878
$container
7979
->expects($this->once())
8080
->method('has')

Tests/Command/RouterMatchCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function getContainer()
6262
$routeCollection = new RouteCollection();
6363
$routeCollection->add('foo', new Route('foo'));
6464
$requestContext = new RequestContext();
65-
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
65+
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
6666
$router
6767
->expects($this->any())
6868
->method('getRouteCollection')
@@ -78,7 +78,7 @@ private function getContainer()
7878
->disableOriginalConstructor()
7979
->getMock();
8080

81-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
81+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
8282
$container
8383
->expects($this->once())
8484
->method('has')

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testDebugDefaultDirectory()
6464

6565
public function testDebugCustomDirectory()
6666
{
67-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
67+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
6868
$kernel->expects($this->once())
6969
->method('getBundle')
7070
->with($this->equalTo($this->translationDir))
@@ -82,7 +82,7 @@ public function testDebugCustomDirectory()
8282
*/
8383
public function testDebugInvalidDirectory()
8484
{
85-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
85+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
8686
$kernel->expects($this->once())
8787
->method('getBundle')
8888
->with($this->equalTo('dir'))
@@ -130,7 +130,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
130130
->method('getFallbackLocales')
131131
->will($this->returnValue(array('en')));
132132

133-
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
133+
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
134134
$extractor
135135
->expects($this->any())
136136
->method('extract')
@@ -140,7 +140,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
140140
})
141141
);
142142

143-
$loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
143+
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
144144
$loader
145145
->expects($this->any())
146146
->method('loadMessages')
@@ -151,7 +151,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
151151
);
152152

153153
if (null === $kernel) {
154-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
154+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
155155
$kernel
156156
->expects($this->any())
157157
->method('getBundle')
@@ -166,7 +166,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
166166
->method('getRootDir')
167167
->will($this->returnValue($this->translationDir));
168168

169-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
169+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
170170
$container
171171
->expects($this->any())
172172
->method('get')
@@ -182,7 +182,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
182182

183183
private function getBundle($path)
184184
{
185-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
185+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
186186
$bundle
187187
->expects($this->any())
188188
->method('getPath')

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
6868
->method('getFallbackLocales')
6969
->will($this->returnValue(array('en')));
7070

71-
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
71+
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
7272
$extractor
7373
->expects($this->any())
7474
->method('extract')
@@ -78,7 +78,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
7878
})
7979
);
8080

81-
$loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
81+
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
8282
$loader
8383
->expects($this->any())
8484
->method('loadMessages')
@@ -88,7 +88,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
8888
})
8989
);
9090

91-
$writer = $this->getMock('Symfony\Component\Translation\Writer\TranslationWriter');
91+
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
9292
$writer
9393
->expects($this->any())
9494
->method('getFormats')
@@ -97,7 +97,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
9797
);
9898

9999
if (null === $kernel) {
100-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
100+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
101101
$kernel
102102
->expects($this->any())
103103
->method('getBundle')
@@ -112,7 +112,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
112112
->method('getRootDir')
113113
->will($this->returnValue($this->translationDir));
114114

115-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
115+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
116116
$container
117117
->expects($this->any())
118118
->method('get')
@@ -129,7 +129,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
129129

130130
private function getBundle($path)
131131
{
132-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
132+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
133133
$bundle
134134
->expects($this->any())
135135
->method('getPath')

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ApplicationTest extends TestCase
2222
{
2323
public function testBundleInterfaceImplementation()
2424
{
25-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
25+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
2626

2727
$kernel = $this->getKernel(array($bundle), true);
2828

@@ -117,10 +117,10 @@ public function testBundleCommandsHaveRightContainer()
117117

118118
private function getKernel(array $bundles, $useDispatcher = false)
119119
{
120-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
120+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
121121

122122
if ($useDispatcher) {
123-
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
123+
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
124124
$dispatcher
125125
->expects($this->atLeastOnce())
126126
->method('dispatch')
@@ -145,7 +145,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
145145
->will($this->returnValue(array()))
146146
;
147147

148-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
148+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
149149
$kernel
150150
->expects($this->any())
151151
->method('getBundles')
@@ -162,7 +162,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
162162

163163
private function createBundleMock(array $commands)
164164
{
165-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
165+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
166166
$bundle
167167
->expects($this->once())
168168
->method('registerCommands')

Tests/Controller/ControllerNameParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function createParser()
147147
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
148148
);
149149

150-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
150+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
151151
$kernel
152152
->expects($this->any())
153153
->method('getBundle')
@@ -178,7 +178,7 @@ private function createParser()
178178

179179
private function getBundle($namespace, $name)
180180
{
181-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
181+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
182182
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
183183
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
184184

Tests/Controller/ControllerResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ protected function createControllerResolver(LoggerInterface $logger = null, Cont
175175

176176
protected function createMockParser()
177177
{
178-
return $this->getMock('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', array(), array(), '', false);
178+
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock();
179179
}
180180

181181
protected function createMockContainer()
182182
{
183-
return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
183+
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
184184
}
185185
}
186186

0 commit comments

Comments
 (0)