fixed obsolete getMock() usage

This commit is contained in:
Fabien Potencier 2016-12-19 17:09:34 +01:00
parent 3f96468942
commit 0a9e391f36
23 changed files with 68 additions and 74 deletions

View File

@ -59,7 +59,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
// check that the handler actually outputs the record if it handles it
$levelName = Logger::getLevelName($level);
$realOutput = $this->getMock('Symfony\Component\Console\Output\Output', array('doWrite'));
$realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock();
$realOutput->setVerbosity($verbosity);
$realOutput
->expects($isHandling ? $this->once() : $this->never())

View File

@ -69,10 +69,10 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetToken()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->method('getToken')->willReturn($token);
$this->assertEquals($token, $this->appVariable->getToken());
@ -94,7 +94,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetTokenWithNoToken()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getToken());

View File

@ -120,7 +120,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase
'</pre><script>Sfdump("%s")</script>'
);
$extension = new DumpExtension(new VarCloner(), $dumper);
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
$twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'debug' => true,
'cache' => false,
'optimizations' => 0,

View File

@ -47,7 +47,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
$this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -43,7 +43,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
$this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -47,7 +47,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
$this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -44,7 +44,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig',
'custom_widgets.html.twig',
), $environment);
$this->renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
$this->renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -74,7 +74,7 @@ class HttpKernelExtensionTest extends \PHPUnit_Framework_TestCase
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
$twig->addExtension(new HttpKernelExtension());
$loader = $this->getMock('Twig_RuntimeLoaderInterface');
$loader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)),
)));

View File

@ -17,7 +17,7 @@ trait RuntimeLoaderProvider
{
protected function registerTwigRuntimeLoader(\Twig_Environment $environment, TwigRenderer $renderer)
{
$loader = $this->getMock('Twig_RuntimeLoaderInterface');
$loader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap(array(
array('Symfony\Bridge\Twig\Form\TwigRenderer', $renderer),
)));

View File

@ -215,8 +215,8 @@ class ControllerTest extends TestCase
public function testFile()
{
/* @var ContainerInterface $container */
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$container->set('kernel', $kernel);
$controller = new TestController();
@ -235,7 +235,7 @@ class ControllerTest extends TestCase
public function testFileAsInline()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);
@ -253,7 +253,7 @@ class ControllerTest extends TestCase
public function testFileWithOwnFileName()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);
@ -272,7 +272,7 @@ class ControllerTest extends TestCase
public function testFileWithOwnFileNameAsInline()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$controller = new TestController();
$controller->setContainer($container);

View File

@ -24,11 +24,8 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase
'checker_3' => array(0 => array()),
);
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$container = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
);
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
@ -52,10 +49,7 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase
public function testThatCheckersCanBeMissing()
{
$container = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('findTaggedServiceIds')
);
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')

View File

@ -33,8 +33,8 @@ class SecurityUserValueResolverTest extends \PHPUnit_Framework_TestCase
public function testResolveNoUser()
{
$mock = $this->getMock(UserInterface::class);
$token = $this->getMock(TokenInterface::class);
$mock = $this->getMockBuilder(UserInterface::class)->getMock();
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@ -55,8 +55,8 @@ class SecurityUserValueResolverTest extends \PHPUnit_Framework_TestCase
public function testResolve()
{
$user = $this->getMock(UserInterface::class);
$token = $this->getMock(TokenInterface::class);
$user = $this->getMockBuilder(UserInterface::class)->getMock();
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())->method('getUser')->willReturn($user);
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@ -70,8 +70,8 @@ class SecurityUserValueResolverTest extends \PHPUnit_Framework_TestCase
public function testIntegration()
{
$user = $this->getMock(UserInterface::class);
$token = $this->getMock(TokenInterface::class);
$user = $this->getMockBuilder(UserInterface::class)->getMock();
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token->expects($this->any())->method('getUser')->willReturn($user);
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);
@ -82,7 +82,7 @@ class SecurityUserValueResolverTest extends \PHPUnit_Framework_TestCase
public function testIntegrationNoUser()
{
$token = $this->getMock(TokenInterface::class);
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$tokenStorage = new TokenStorage();
$tokenStorage->setToken($token);

View File

@ -23,7 +23,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
*/
public function testEmptyToken($token)
{
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
$twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
@ -151,10 +151,10 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
private function createController($profiler, $twig, $withCSP)
{
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
if ($withCSP) {
$nonceGenerator = $this->getMock('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator');
$nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();
return new ProfilerController($urlGenerator, $profiler, $twig, array(), 'normal', new ContentSecurityPolicyHandler($nonceGenerator));
}

View File

@ -188,7 +188,7 @@ class ContentSecurityPolicyHandlerTest extends \PHPUnit_Framework_TestCase
private function mockNonceGenerator($value)
{
$generator = $this->getMock('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator');
$generator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();
$generator->expects($this->any())
->method('generate')

View File

@ -454,7 +454,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock();
$application->expects($this->once())
->method('getNamespaces')
->will($this->returnValue(array('foo:sublong', 'bar:sub')));
@ -701,7 +701,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('', 4);
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')
@ -716,7 +716,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('', 0);
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')

View File

@ -17,7 +17,7 @@ abstract class AbstractQuestionHelperTest extends \PHPUnit_Framework_TestCase
{
protected function createStreamableInputInterfaceMock($stream = null, $interactive = true)
{
$mock = $this->getMock(StreamableInputInterface::class);
$mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock();
$mock->expects($this->any())
->method('isInteractive')
->will($this->returnValue($interactive));

View File

@ -730,7 +730,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
' [<info>żółw </info>] bar',
' [<info>łabądź</info>] baz',
);
$output = $this->getMock('\Symfony\Component\Console\Output\OutputInterface');
$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
$output->method('getFormatter')->willReturn(new OutputFormatter());
$dialog = new QuestionHelper();

View File

@ -23,10 +23,10 @@ class PassConfigTest extends \PHPUnit_Framework_TestCase
{
$config = new PassConfig();
$pass1 = $this->getMock(CompilerPassInterface::class);
$pass1 = $this->getMockBuilder(CompilerPassInterface::class)->getMock();
$config->addPass($pass1, PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
$pass2 = $this->getMock(CompilerPassInterface::class);
$pass2 = $this->getMockBuilder(CompilerPassInterface::class)->getMock();
$config->addPass($pass2, PassConfig::TYPE_BEFORE_OPTIMIZATION, 30);
$this->assertSame(array($pass2, $pass1), $config->getBeforeOptimizationPasses());

View File

@ -284,8 +284,8 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$builder = new ContainerBuilder();
$builder->setResourceTracking(false);
$defaultPasses = $builder->getCompiler()->getPassConfig()->getPasses();
$builder->addCompilerPass($pass1 = $this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'), PassConfig::TYPE_BEFORE_OPTIMIZATION, -5);
$builder->addCompilerPass($pass2 = $this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
$builder->addCompilerPass($pass1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -5);
$builder->addCompilerPass($pass2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
$passes = $builder->getCompiler()->getPassConfig()->getPasses();
$this->assertCount(count($passes) - 2, $defaultPasses);
@ -648,7 +648,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredButNotLoadedExtension()
{
$extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface');
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->once())->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->never())->method('load');
@ -660,7 +660,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredAndLoadedExtension()
{
$extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface');
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->once())->method('load')->with(array(array('foo' => 'bar')));

View File

@ -19,8 +19,8 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
{
public function testCachedParse()
{
$cacheMock = $this->getMock('Psr\Cache\CacheItemPoolInterface');
$cacheItemMock = $this->getMock('Psr\Cache\CacheItemInterface');
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$savedParsedExpression = null;
$expressionLanguage = new ExpressionLanguage($cacheMock);
@ -66,9 +66,9 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
*/
public function testCachedParseWithDeprecatedParserCacheInterface()
{
$cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$cacheItemMock = $this->getMock('Psr\Cache\CacheItemInterface');
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$savedParsedExpression = null;
$expressionLanguage = new ExpressionLanguage($cacheMock);
@ -98,7 +98,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
*/
public function testWrongCacheImplementation()
{
$cacheMock = $this->getMock('Psr\Cache\CacheItemSpoolInterface');
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemSpoolInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
}
@ -172,8 +172,8 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
public function testCachingWithDifferentNamesOrder()
{
$cacheMock = $this->getMock('Psr\Cache\CacheItemPoolInterface');
$cacheItemMock = $this->getMock('Psr\Cache\CacheItemInterface');
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
$savedParsedExpressions = array();

View File

@ -22,7 +22,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
{
public function testGetItem()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$key = 'key';
$value = 'value';
@ -43,8 +43,8 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testSave()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$cacheItemMock = $this->getMock('Psr\Cache\CacheItemInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$key = 'key';
$value = new ParsedExpression('1 + 1', new Node(array(), array()));
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
@ -72,7 +72,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testGetItems()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);
@ -81,7 +81,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testHasItem()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$key = 'key';
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);
@ -91,7 +91,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testClear()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);
@ -100,7 +100,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testDeleteItem()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$key = 'key';
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);
@ -110,7 +110,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testDeleteItems()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$keys = array('key');
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);
@ -120,9 +120,9 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testSaveDeferred()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$cacheItemMock = $this->getMock('Psr\Cache\CacheItemInterface');
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$this->setExpectedException(\BadMethodCallException::class);
$parserCacheAdapter->saveDeferred($cacheItemMock);
@ -130,7 +130,7 @@ class ParserCacheAdapterTest extends \PHPUnit_Framework_TestCase
public function testCommit()
{
$poolMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
$this->setExpectedException(\BadMethodCallException::class);

View File

@ -46,13 +46,13 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->dataExtractor = new FormDataExtractor();
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
}
public function testExtractConfiguration()
{
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
->will($this->returnValue(new \stdClass()));
@ -73,7 +73,7 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
public function testExtractConfigurationSortsPassedOptions()
{
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
->will($this->returnValue(new \stdClass()));
@ -107,7 +107,7 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
public function testExtractConfigurationSortsResolvedOptions()
{
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
->will($this->returnValue(new \stdClass()));
@ -138,18 +138,18 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
public function testExtractConfigurationBuildsIdRecursively()
{
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any())
->method('getInnerType')
->will($this->returnValue(new \stdClass()));
$grandParent = $this->createBuilder('grandParent')
->setCompound(true)
->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'))
->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock())
->getForm();
$parent = $this->createBuilder('parent')
->setCompound(true)
->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'))
->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock())
->getForm();
$form = $this->createBuilder('name')
->setType($type)

View File

@ -846,7 +846,7 @@ class ResponseTest extends ResponseTestCase
public function testNoDeprecationsAreTriggered()
{
new DefaultResponse();
$this->getMock(Response::class);
$this->getMockBuilder(Response::class)->getMock();
}
/**