Skip to content

Commit 2186868

Browse files
committed
fixed obsolete getMock() usage
1 parent 3059571 commit 2186868

31 files changed

+80
-99
lines changed

Tests/Bundle/BundleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase
2222
public function testRegisterCommands()
2323
{
2424
$cmd = new FooCommand();
25-
$app = $this->getMock('Symfony\Component\Console\Application');
25+
$app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
2626
$app->expects($this->once())->method('add')->with($this->equalTo($cmd));
2727

2828
$bundle = new ExtensionPresentBundle();
@@ -48,7 +48,7 @@ public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAs
4848
$container = new ContainerBuilder();
4949
$container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand');
5050

51-
$application = $this->getMock('Symfony\Component\Console\Application');
51+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
5252
// add() is never called when the found command classes are already registered as services
5353
$application->expects($this->never())->method('add');
5454

Tests/CacheClearer/ChainCacheClearerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function testInjectClearerUsingAdd()
5252

5353
protected function getMockClearer()
5454
{
55-
return $this->getMock('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface');
55+
return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
5656
}
5757
}

Tests/Config/FileLocatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase
1717
{
1818
public function testLocate()
1919
{
20-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
20+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
2121
$kernel
2222
->expects($this->atLeastOnce())
2323
->method('locateResource')
@@ -35,7 +35,7 @@ public function testLocate()
3535

3636
public function testLocateWithGlobalResourcePath()
3737
{
38-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
38+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
3939
$kernel
4040
->expects($this->atLeastOnce())
4141
->method('locateResource')

Tests/Controller/ControllerResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
2121
{
2222
public function testGetControllerWithoutControllerParameter()
2323
{
24-
$logger = $this->getMock('Psr\Log\LoggerInterface');
24+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
2525
$logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.');
2626
$resolver = $this->createControllerResolver($logger);
2727

@@ -215,7 +215,7 @@ public function testGetVariadicArguments()
215215

216216
public function testCreateControllerCanReturnAnyCallable()
217217
{
218-
$mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
218+
$mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(array('createController'))->getMock();
219219
$mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'));
220220

221221
$request = Request::create('/');

Tests/DataCollector/LoggerDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
2222
{
23-
$logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
23+
$logger = $this->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')->getMock();
2424
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
2525
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
2626

Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected function createResponse()
185185
*/
186186
protected function injectController($collector, $controller, $request)
187187
{
188-
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
188+
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
189189
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver);
190190
$event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
191191
$collector->onKernelController($event);

Tests/DataCollector/TimeDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testCollect()
4141
$c->collect($request, new Response());
4242
$this->assertEquals(0, $c->getStartTime());
4343

44-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
44+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
4545
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
4646

4747
$c = new TimeDataCollector($kernel);

Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testListenerCanRemoveItselfWhenExecuted()
108108

109109
protected function getHttpKernel($dispatcher, $controller)
110110
{
111-
$resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface');
111+
$resolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock();
112112
$resolver->expects($this->once())->method('getController')->will($this->returnValue($controller));
113113
$resolver->expects($this->once())->method('getArguments')->will($this->returnValue(array()));
114114

Tests/DependencyInjection/ContainerAwareHttpKernelTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testHandle($type)
3434
return $expected;
3535
};
3636

37-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
37+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
3838
$this
3939
->expectsEnterScopeOnce($container)
4040
->expectsLeaveScopeOnce($container)
@@ -63,11 +63,11 @@ public function testVerifyRequestStackPushPopDuringHandle($type)
6363
return $expected;
6464
};
6565

66-
$stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
66+
$stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock();
6767
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
6868
$stack->expects($this->at(1))->method('pop');
6969

70-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
70+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
7171
$dispatcher = new EventDispatcher();
7272
$resolver = $this->getResolverMockFor($controller, $request);
7373
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
@@ -86,7 +86,7 @@ public function testHandleRestoresThePreviousRequestOnException($type)
8686
throw $expected;
8787
};
8888

89-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
89+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
9090
$this
9191
->expectsEnterScopeOnce($container)
9292
->expectsLeaveScopeOnce($container)
@@ -95,7 +95,7 @@ public function testHandleRestoresThePreviousRequestOnException($type)
9595
;
9696

9797
$dispatcher = new EventDispatcher();
98-
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
98+
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
9999
$resolver = $this->getResolverMockFor($controller, $request);
100100
$stack = new RequestStack();
101101
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
@@ -120,7 +120,7 @@ public function getProviderTypes()
120120

121121
private function getResolverMockFor($controller, $request)
122122
{
123-
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
123+
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
124124
$resolver->expects($this->once())
125125
->method('getController')
126126
->with($request)

Tests/DependencyInjection/FragmentRendererPassTest.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public function testLegacyFragmentRedererWithoutAlias()
2828
'my_content_renderer' => array(array()),
2929
);
3030

31-
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
31+
$renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
3232
$renderer
3333
->expects($this->once())
3434
->method('addMethodCall')
3535
->with('addRenderer', array(new Reference('my_content_renderer')))
3636
;
3737

38-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
38+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
3939
$definition->expects($this->atLeastOnce())
4040
->method('getClass')
4141
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
@@ -45,10 +45,7 @@ public function testLegacyFragmentRedererWithoutAlias()
4545
->will($this->returnValue(true))
4646
;
4747

48-
$builder = $this->getMock(
49-
'Symfony\Component\DependencyInjection\ContainerBuilder',
50-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
51-
);
48+
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
5249
$builder->expects($this->any())
5350
->method('hasDefinition')
5451
->will($this->returnValue(true));
@@ -79,12 +76,9 @@ public function testContentRendererWithoutInterface()
7976
'my_content_renderer' => array(array('alias' => 'foo')),
8077
);
8178

82-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
79+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
8380

84-
$builder = $this->getMock(
85-
'Symfony\Component\DependencyInjection\ContainerBuilder',
86-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
87-
);
81+
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
8882
$builder->expects($this->any())
8983
->method('hasDefinition')
9084
->will($this->returnValue(true));
@@ -108,14 +102,14 @@ public function testValidContentRenderer()
108102
'my_content_renderer' => array(array('alias' => 'foo')),
109103
);
110104

111-
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
105+
$renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
112106
$renderer
113107
->expects($this->once())
114108
->method('addMethodCall')
115109
->with('addRendererService', array('foo', 'my_content_renderer'))
116110
;
117111

118-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
112+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
119113
$definition->expects($this->atLeastOnce())
120114
->method('getClass')
121115
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
@@ -125,10 +119,7 @@ public function testValidContentRenderer()
125119
->will($this->returnValue(true))
126120
;
127121

128-
$builder = $this->getMock(
129-
'Symfony\Component\DependencyInjection\ContainerBuilder',
130-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
131-
);
122+
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
132123
$builder->expects($this->any())
133124
->method('hasDefinition')
134125
->will($this->returnValue(true));

0 commit comments

Comments
 (0)