Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
minor #424 Remove usage of deprecated PHUnit mocking APIs (stof)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.8-dev branch.

Discussion
----------

Remove usage of deprecated PHUnit mocking APIs

Commits
-------

1ddc07b Remove usage of deprecated PHUnit mocking APIs
  • Loading branch information
stof committed Nov 22, 2016
2 parents 1de96db + 1ddc07b commit fd9bac2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
12 changes: 6 additions & 6 deletions Tests/Command/DumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
14 changes: 7 additions & 7 deletions Tests/Controller/AsseticControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');
Expand Down Expand Up @@ -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==';
Expand Down Expand Up @@ -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(''));
Expand Down Expand Up @@ -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==';
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/AsseticExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions Tests/Factory/AssetFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions Tests/Factory/Resource/CoalescingDirectoryResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion Tests/Factory/Resource/FileResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions Tests/FilterManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -40,16 +40,16 @@ 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');
}

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);
Expand Down

0 comments on commit fd9bac2

Please sign in to comment.