From 1ddc07ba9d6265fa058717c3fe3d142e39ea2fc0 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 22 Nov 2016 11:59:19 +0100 Subject: [PATCH] Remove usage of deprecated PHUnit mocking APIs --- Tests/Command/DumpCommandTest.php | 12 ++++++------ Tests/Controller/AsseticControllerTest.php | 14 +++++++------- Tests/DependencyInjection/AsseticExtensionTest.php | 2 +- Tests/Factory/AssetFactoryTest.php | 10 +++++----- .../Resource/CoalescingDirectoryResourceTest.php | 12 ++++++------ Tests/Factory/Resource/FileResourceTest.php | 2 +- Tests/FilterManagerTest.php | 10 +++++----- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Tests/Command/DumpCommandTest.php b/Tests/Command/DumpCommandTest.php index 079d4154..00d39de0 100644 --- a/Tests/Command/DumpCommandTest.php +++ b/Tests/Command/DumpCommandTest.php @@ -49,9 +49,9 @@ protected function setUp() $this->definition = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputDefinition') ->disableOriginalConstructor() ->getMock(); - $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); - $this->helperSet = $this->getMock('Symfony\\Component\\Console\\Helper\\HelperSet'); - $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); + $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); + $this->helperSet = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\HelperSet')->getMock(); + $this->container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); $this->am = $this->getMockBuilder('Assetic\\Factory\\LazyAssetManager') ->disableOriginalConstructor() ->getMock(); @@ -120,7 +120,7 @@ public function testEmptyAssetManager() public function testDumpOne() { - $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $this->am->expects($this->once()) ->method('getNames') @@ -161,8 +161,8 @@ public function testDumpOne() public function testDumpDebug() { - $asset = $this->getMock('Assetic\\Asset\\AssetCollection'); - $leaf = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetCollection')->getMock(); + $leaf = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $this->am->expects($this->once()) ->method('getNames') diff --git a/Tests/Controller/AsseticControllerTest.php b/Tests/Controller/AsseticControllerTest.php index a2a17276..e8e14de9 100644 --- a/Tests/Controller/AsseticControllerTest.php +++ b/Tests/Controller/AsseticControllerTest.php @@ -27,13 +27,13 @@ protected function setUp() $this->markTestSkipped('Assetic is not available.'); } - $this->request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request', array('getETags', 'getMethod')); - $this->headers = $this->getMock('Symfony\\Component\\HttpFoundation\\ParameterBag'); + $this->request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->setMethods(array('getETags', 'getMethod'))->getMock(); + $this->headers = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\ParameterBag')->getMock(); $this->request->headers = $this->headers; $this->am = $this->getMockBuilder('Assetic\\Factory\\LazyAssetManager') ->disableOriginalConstructor() ->getMock(); - $this->cache = $this->getMock('Assetic\\Cache\\CacheInterface'); + $this->cache = $this->getMockBuilder('Assetic\\Cache\\CacheInterface')->getMock(); $this->request->expects($this->any()) ->method('getMethod') @@ -58,7 +58,7 @@ public function testRenderNotFound() public function testRenderLastModifiedFresh() { - $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $name = 'foo'; $lastModified = strtotime('2010-10-10 10:10:10'); @@ -93,7 +93,7 @@ public function testRenderLastModifiedFresh() public function testRenderLastModifiedStale() { - $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $name = 'foo'; $content = '==ASSET_CONTENT=='; @@ -135,7 +135,7 @@ public function testRenderLastModifiedStale() public function testRenderETagFresh() { - $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $name = 'foo'; $formula = array(array('js/core.js'), array(), array('')); @@ -173,7 +173,7 @@ public function testRenderETagFresh() public function testRenderETagStale() { - $asset = $this->getMock('Assetic\\Asset\\AssetInterface'); + $asset = $this->getMockBuilder('Assetic\\Asset\\AssetInterface')->getMock(); $name = 'foo'; $content = '==ASSET_CONTENT=='; diff --git a/Tests/DependencyInjection/AsseticExtensionTest.php b/Tests/DependencyInjection/AsseticExtensionTest.php index dae3e8a7..8d4fd759 100644 --- a/Tests/DependencyInjection/AsseticExtensionTest.php +++ b/Tests/DependencyInjection/AsseticExtensionTest.php @@ -56,7 +56,7 @@ protected function setUp() $this->markTestSkipped('Twig is not available.'); } - $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); + $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); $this->container = new ContainerBuilder(); // Symfony 2.3 BC diff --git a/Tests/Factory/AssetFactoryTest.php b/Tests/Factory/AssetFactoryTest.php index 70414145..19b5048b 100644 --- a/Tests/Factory/AssetFactoryTest.php +++ b/Tests/Factory/AssetFactoryTest.php @@ -26,16 +26,16 @@ protected function setUp() $this->markTestSkipped('Assetic is not available.'); } - $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface'); - $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); - $this->parameterBag = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface'); + $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); + $this->container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); + $this->parameterBag = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface')->getMock(); $this->factory = new AssetFactory($this->kernel, $this->container, $this->parameterBag, '/path/to/web'); } public function testBundleNotation() { $input = '@MyBundle/Resources/css/main.css'; - $bundle = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface'); + $bundle = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface')->getMock(); $this->parameterBag->expects($this->once()) ->method('resolveValue') @@ -64,7 +64,7 @@ public function testBundleNotation() */ public function testBundleGlobNotation($input) { - $bundle = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface'); + $bundle = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface')->getMock(); $this->parameterBag->expects($this->once()) ->method('resolveValue') diff --git a/Tests/Factory/Resource/CoalescingDirectoryResourceTest.php b/Tests/Factory/Resource/CoalescingDirectoryResourceTest.php index 4967e45c..5a687b59 100644 --- a/Tests/Factory/Resource/CoalescingDirectoryResourceTest.php +++ b/Tests/Factory/Resource/CoalescingDirectoryResourceTest.php @@ -17,13 +17,13 @@ class CoalescingDirectoryResourceTest extends \PHPUnit_Framework_TestCase { public function testFiltering() { - $dir1 = $this->getMock('Assetic\\Factory\\Resource\\IteratorResourceInterface'); - $file1a = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'); - $file1b = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'); + $dir1 = $this->getMockBuilder('Assetic\\Factory\\Resource\\IteratorResourceInterface')->getMock(); + $file1a = $this->getMockBuilder('Assetic\\Factory\\Resource\\ResourceInterface')->getMock(); + $file1b = $this->getMockBuilder('Assetic\\Factory\\Resource\\ResourceInterface')->getMock(); - $dir2 = $this->getMock('Assetic\\Factory\\Resource\\IteratorResourceInterface'); - $file2a = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'); - $file2c = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'); + $dir2 = $this->getMockBuilder('Assetic\\Factory\\Resource\\IteratorResourceInterface')->getMock(); + $file2a = $this->getMockBuilder('Assetic\\Factory\\Resource\\ResourceInterface')->getMock(); + $file2c = $this->getMockBuilder('Assetic\\Factory\\Resource\\ResourceInterface')->getMock(); $dir1->expects($this->any()) ->method('getIterator') diff --git a/Tests/Factory/Resource/FileResourceTest.php b/Tests/Factory/Resource/FileResourceTest.php index 2132366e..645cf3ab 100644 --- a/Tests/Factory/Resource/FileResourceTest.php +++ b/Tests/Factory/Resource/FileResourceTest.php @@ -19,7 +19,7 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->loader = $this->getMock('Symfony\\Component\\Templating\\Loader\\LoaderInterface'); + $this->loader = $this->getMockBuilder('Symfony\\Component\\Templating\\Loader\\LoaderInterface')->getMock(); } public function testCastAsString() diff --git a/Tests/FilterManagerTest.php b/Tests/FilterManagerTest.php index 9ef67fb1..d873d8b0 100644 --- a/Tests/FilterManagerTest.php +++ b/Tests/FilterManagerTest.php @@ -24,8 +24,8 @@ protected function setUp() public function testGet() { - $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); - $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); + $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); + $filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock(); $container->expects($this->exactly(2)) ->method('get') @@ -40,7 +40,7 @@ public function testGet() public function testHas() { - $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); $fm = new FilterManager($container, array('foo' => 'assetic.filter.bar')); $this->assertTrue($fm->has('foo'), '->has() returns true for lazily mapped filters'); @@ -48,8 +48,8 @@ public function testHas() public function testGetNames() { - $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); - $filter = $this->getMock('Assetic\\Filter\\FilterInterface'); + $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); + $filter = $this->getMockBuilder('Assetic\\Filter\\FilterInterface')->getMock(); $fm = new FilterManager($container, array('foo' => 'assetic.filter.bar')); $fm->set('bar', $filter);