Skip to content

Commit 39a08da

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: fixed obsolete getMock() usage fixed obsolete getMock() usage [WebProfilerBundle] Display multiple HTTP headers in WDT do not remove the Twig ExceptionController service removed obsolete condition do not try to register incomplete definitions
2 parents 703511d + 2c28845 commit 39a08da

24 files changed

+54
-64
lines changed

Tests/Bundle/BundleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testGetContainerExtension()
3232
public function testRegisterCommands()
3333
{
3434
$cmd = new FooCommand();
35-
$app = $this->getMock('Symfony\Component\Console\Application');
35+
$app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
3636
$app->expects($this->once())->method('add')->with($this->equalTo($cmd));
3737

3838
$bundle = new ExtensionPresentBundle();
@@ -58,7 +58,7 @@ public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAs
5858
$container = new ContainerBuilder();
5959
$container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand');
6060

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

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

@@ -219,7 +219,7 @@ public function testGetVariadicArguments()
219219

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

225225
$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/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/DependencyInjection/LazyLoadingFragmentHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ class LazyLoadingFragmentHandlerTest extends \PHPUnit_Framework_TestCase
1919
{
2020
public function test()
2121
{
22-
$renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface');
22+
$renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
2323
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
2424
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
2525

26-
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
26+
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
2727
$requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
2828

29-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
29+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
3030
$container->expects($this->once())->method('get')->will($this->returnValue($renderer));
3131

3232
$handler = new LazyLoadingFragmentHandler($container, $requestStack, false);

Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
1717
{
1818
public function testAutoloadMainExtension()
1919
{
20-
$container = $this->getMock(
21-
'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
22-
array(
23-
'getExtensionConfig',
24-
'loadFromExtension',
25-
'getParameterBag',
26-
'getDefinitions',
27-
'getAliases',
28-
'getExtensions',
29-
)
30-
);
31-
$params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag');
20+
$container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('getExtensionConfig', 'loadFromExtension', 'getParameterBag', 'getDefinitions', 'getAliases', 'getExtensions'))->getMock();
21+
$params = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag')->getMock();
3222

3323
$container->expects($this->at(0))
3424
->method('getExtensionConfig')

Tests/EventListener/AddRequestFormatsListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testSetAdditionalFormats()
6464

6565
protected function getRequestMock()
6666
{
67-
return $this->getMock('Symfony\Component\HttpFoundation\Request');
67+
return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
6868
}
6969

7070
protected function getGetResponseEventMock(Request $request)

Tests/EventListener/DebugHandlersListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase
3636
{
3737
public function testConfigure()
3838
{
39-
$logger = $this->getMock('Psr\Log\LoggerInterface');
39+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
4040
$userHandler = function () {};
4141
$listener = new DebugHandlersListener($userHandler, $logger);
4242
$xHandler = new ExceptionHandler();
@@ -70,7 +70,7 @@ public function testConfigureForHttpKernelWithNoTerminateWithException()
7070
$listener = new DebugHandlersListener(null);
7171
$eHandler = new ErrorHandler();
7272
$event = new KernelEvent(
73-
$this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
73+
$this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
7474
Request::create('/'),
7575
HttpKernelInterface::MASTER_REQUEST
7676
);
@@ -94,7 +94,7 @@ public function testConsoleEvent()
9494
{
9595
$dispatcher = new EventDispatcher();
9696
$listener = new DebugHandlersListener(null);
97-
$app = $this->getMock('Symfony\Component\Console\Application');
97+
$app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
9898
$app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
9999
$command = new Command(__FUNCTION__);
100100
$command->setApplication($app);

0 commit comments

Comments
 (0)