diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
index 45d0310e6d..6fa34345cd 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
@@ -139,7 +139,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
->method('getDatabasePlatform')
->will($this->returnValue(new MySqlPlatform()));
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry
->expects($this->any())
->method('getConnectionNames')
@@ -152,7 +152,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
->method('getConnection')
->will($this->returnValue($connection));
- $logger = $this->getMock('Doctrine\DBAL\Logging\DebugStack');
+ $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
$logger->queries = $queries;
$collector = new DoctrineDataCollector($registry);
diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
index 53ad5a0e3a..77d89088d2 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php
@@ -18,7 +18,7 @@ class ContainerAwareLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testShouldSetContainerOnContainerAwareFixture()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$loader = new ContainerAwareLoader($container);
$fixture = new ContainerAwareFixture();
diff --git a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
index a473b3ace2..e3d48a7030 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php
@@ -17,7 +17,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
{
public function testFetch()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock->expects($this->once())
@@ -31,7 +31,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
public function testFetchUnexisting()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock
@@ -44,7 +44,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
public function testSave()
{
- $doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache');
+ $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock);
$expression = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParsedExpression')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
index 4848d88818..98583b3bb1 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
@@ -72,14 +72,14 @@ class DoctrineChoiceLoaderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
- $this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
- $this->repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
+ $this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
+ $this->repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$this->class = 'stdClass';
$this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader')
->disableOriginalConstructor()
->getMock();
- $this->objectLoader = $this->getMock('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface');
+ $this->objectLoader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface')->getMock();
$this->obj1 = (object) array('name' => 'A');
$this->obj2 = (object) array('name' => 'B');
$this->obj3 = (object) array('name' => 'C');
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
index 0cb900f6d0..f6b96bb200 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
@@ -86,10 +86,10 @@ class DoctrineOrmTypeGuesserTest extends \PHPUnit_Framework_TestCase
private function getGuesser(ClassMetadata $classMetadata)
{
- $em = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
+ $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em)));
return new DoctrineOrmTypeGuesser($registry);
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
index 57df4195bc..16bf4e11ab 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php
@@ -32,7 +32,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
protected function getExtensions()
{
- $manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any())
->method('getManager')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
index 2fdccb946d..1d5d941f22 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -1334,7 +1334,7 @@ class EntityTypeTest extends TypeTestCase
protected function createRegistryMock($name, $em)
{
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
index 6acc47fe90..ddfd506c84 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
@@ -20,7 +20,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
*/
public function testLog($sql, $params, $logParams)
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -52,7 +52,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogNonUtf8()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -75,7 +75,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogNonUtf8Array()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -106,7 +106,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogLongString()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@@ -134,7 +134,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogUTF8LongString()
{
- $logger = $this->getMock('Psr\\Log\\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
index 56d590b109..959992f5a0 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
@@ -213,7 +213,7 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
private function getManager($em, $name = null)
{
- $manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any())
->method('getManager')
->with($this->equalTo($name))
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
index 95b0589fc9..dc26d95e4a 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
@@ -63,7 +63,7 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
protected function createRegistryMock(ObjectManager $em = null)
{
- $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->any())
->method('getManager')
->with($this->equalTo(self::EM_NAME))
@@ -92,7 +92,7 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
->will($this->returnValue($repositoryMock))
;
- $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
+ $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$classMetadata
->expects($this->any())
->method('hasField')
diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
index 6cb315967e..b8efa6fcf9 100644
--- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
+++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php
@@ -45,7 +45,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
*/
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array())
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->atLeastOnce())
->method('getVerbosity')
@@ -80,7 +80,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
public function testVerbosityChanged()
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->at(0))
->method('getVerbosity')
@@ -110,7 +110,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
public function testWritingAndFormatting()
{
- $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output
->expects($this->any())
->method('getVerbosity')
@@ -165,12 +165,12 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
$logger->addInfo('After terminate message.');
});
- $event = new ConsoleCommandEvent(new Command('foo'), $this->getMock('Symfony\Component\Console\Input\InputInterface'), $output);
+ $event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output);
$dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
$this->assertContains('Before command message.', $out = $output->fetch());
$this->assertContains('After command message.', $out);
- $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMock('Symfony\Component\Console\Input\InputInterface'), $output, 0);
+ $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output, 0);
$dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$this->assertContains('Before terminate message.', $out = $output->fetch());
$this->assertContains('After terminate message.', $out);
diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
index 8b2402b045..12bef7b72d 100644
--- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
+++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php
@@ -37,7 +37,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
public function testInstantiateProxy()
{
$instance = new \stdClass();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$definition = new Definition('stdClass');
$instantiator = function () use ($instance) {
return $instance;
diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
index 51a95bc4b5..92ed4600ba 100644
--- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
@@ -45,7 +45,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetSession()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('getSession')->willReturn($session = new Session());
$this->setRequestStack($request);
@@ -69,7 +69,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUser()
{
- $this->setTokenStorage($user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$this->assertEquals($user, $this->appVariable->getUser());
}
@@ -83,7 +83,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUserWithNoToken()
{
- $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->getUser());
@@ -131,7 +131,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setRequestStack($request)
{
- $requestStackMock = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackMock->method('getCurrentRequest')->willReturn($request);
$this->appVariable->setRequestStack($requestStackMock);
@@ -139,10 +139,10 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setTokenStorage($user)
{
- $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);
$token->method('getUser')->willReturn($user);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
index af93114e5a..0800ba8ea2 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
@@ -63,7 +63,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase
public function testDump($context, $args, $expectedOutput, $debug = true)
{
$extension = new DumpExtension(new VarCloner());
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'debug' => $debug,
'cache' => false,
'optimizations' => 0,
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
index bf26dda05b..09ea0a1782 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php
@@ -39,7 +39,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
index 026f3508a2..b683862865 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
@@ -39,7 +39,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
index 978a9c0e6e..5d53e5fd25 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
@@ -40,7 +40,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
index a0d582c5b9..83c9fc7271 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
@@ -39,7 +39,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig',
'custom_widgets.html.twig',
));
- $renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
+ $renderer = new TwigRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->extension = new FormExtension($renderer);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
index 403ed32fd8..abbd6c05d9 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php
@@ -51,7 +51,7 @@ class HttpKernelExtensionTest extends \PHPUnit_Framework_TestCase
protected function getFragmentHandler($return)
{
- $strategy = $this->getMock('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface');
+ $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock();
$strategy->expects($this->once())->method('getName')->will($this->returnValue('inline'));
$strategy->expects($this->once())->method('render')->will($return);
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
index 9733cd7b8a..9f06b50ba0 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
@@ -20,8 +20,8 @@ class RoutingExtensionTest extends \PHPUnit_Framework_TestCase
*/
public function testEscaping($template, $mustBeEscaped)
{
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
- $twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
+ $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()));
$nodes = $twig->parse($twig->tokenize(new \Twig_Source($template, '')));
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
index 8c0cdfe69b..2ea111b0ba 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php
@@ -53,7 +53,7 @@ class StopwatchExtensionTest extends \PHPUnit_Framework_TestCase
protected function getStopwatch($events = array())
{
$events = is_array($events) ? $events : array($events);
- $stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$i = -1;
foreach ($events as $eventName) {
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
index 035dc4f671..8d3ede471c 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
@@ -19,7 +19,7 @@ class DumpNodeTest extends \PHPUnit_Framework_TestCase
{
$node = new DumpNode('bar', null, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -43,7 +43,7 @@ EOTXT;
{
$node = new DumpNode('bar', null, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -70,7 +70,7 @@ EOTXT;
));
$node = new DumpNode('bar', $vars, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@@ -99,7 +99,7 @@ EOTXT;
));
$node = new DumpNode('bar', $vars, 7);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
index 590b9ef75c..02732f1932 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
@@ -41,7 +41,7 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase
$node = new FormThemeNode($form, $resources, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
index 0a3d30bdd5..408b7cfd14 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
@@ -23,7 +23,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -46,7 +46,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -66,7 +66,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -86,7 +86,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -108,7 +108,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -129,7 +129,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -153,7 +153,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -182,7 +182,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@@ -210,7 +210,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@@ -247,7 +247,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
- $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
+ $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
index cbd21fc46e..3a444e8a1f 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
@@ -24,7 +24,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
$vars = new \Twig_Node_Expression_Name('foo', 0);
$node = new TransNode($body, null, null, $vars);
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true));
$compiler = new \Twig_Compiler($env);
$this->assertEquals(
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
index f9cf08bc28..86dc25266c 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php
@@ -22,7 +22,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(\Twig_Node $node)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
@@ -48,7 +48,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
index 16736031e0..571b5bba31 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php
@@ -18,7 +18,7 @@ class TranslationNodeVisitorTest extends \PHPUnit_Framework_TestCase
/** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationNodeVisitor();
$visitor->enable();
$visitor->enterNode($node, $env);
diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
index 6b6a92abf1..6dea9fd693 100644
--- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
@@ -21,7 +21,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase
*/
public function testCompile($source, $expected)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env->addTokenParser(new FormThemeTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env);
diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
index 23869da436..4362e9131a 100644
--- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
@@ -22,14 +22,14 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
*/
public function testExtract($template, $messages)
{
- $loader = $this->getMock('Twig_LoaderInterface');
+ $loader = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
$twig = new \Twig_Environment($loader, array(
'strict_variables' => true,
'debug' => true,
'cache' => false,
'autoescape' => false,
));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
$extractor->setPrefix('prefix');
@@ -77,8 +77,8 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
*/
public function testExtractSyntaxError($resources)
{
- $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
@@ -120,7 +120,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
'cache' => false,
'autoescape' => false,
));
- $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
+ $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
$extractor = new TwigExtractor($twig);
$catalogue = new MessageCatalogue('en');
diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
index e7047c354d..b3eebb55c9 100644
--- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
@@ -71,7 +71,7 @@ class TwigEngineTest extends \PHPUnit_Framework_TestCase
'index' => 'foo',
'error' => '{{ foo }',
)));
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
return new TwigEngine($twig, $parser);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
index e42babd362..30b3242a5c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
@@ -63,7 +63,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
{
$routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo'));
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->any())
->method('getRouteCollection')
@@ -74,7 +74,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
index 3dc64a300e..1caa5df9d9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php
@@ -62,7 +62,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
$routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo'));
$requestContext = new RequestContext();
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->any())
->method('getRouteCollection')
@@ -78,7 +78,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
index 27f61c4383..60f81565d3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php
@@ -64,7 +64,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
public function testDebugCustomDirectory()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo($this->translationDir))
@@ -82,7 +82,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
*/
public function testDebugInvalidDirectory()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo('dir'))
@@ -130,7 +130,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
->method('getFallbackLocales')
->will($this->returnValue(array('en')));
- $extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
+ $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
@@ -140,7 +140,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
})
);
- $loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
+ $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$loader
->expects($this->any())
->method('loadMessages')
@@ -151,7 +151,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
);
if (null === $kernel) {
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -166,7 +166,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
->method('getRootDir')
->will($this->returnValue($this->translationDir));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -182,7 +182,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
private function getBundle($path)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle
->expects($this->any())
->method('getPath')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
index 536c59fae4..1293682969 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
@@ -85,7 +85,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
->method('getFallbackLocales')
->will($this->returnValue(array('en')));
- $extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
+ $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor
->expects($this->any())
->method('extract')
@@ -95,7 +95,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
})
);
- $loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
+ $loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$loader
->expects($this->any())
->method('loadMessages')
@@ -105,7 +105,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
})
);
- $writer = $this->getMock('Symfony\Component\Translation\Writer\TranslationWriter');
+ $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
$writer
->expects($this->any())
->method('getFormats')
@@ -114,7 +114,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
);
if (null === $kernel) {
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -129,7 +129,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
->method('getRootDir')
->will($this->returnValue($this->translationDir));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -146,7 +146,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
private function getBundle($path)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle
->expects($this->any())
->method('getPath')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
index a944da863f..fc60fd3bdd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
@@ -22,7 +22,7 @@ class ApplicationTest extends TestCase
{
public function testBundleInterfaceImplementation()
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$kernel = $this->getKernel(array($bundle), true);
@@ -117,10 +117,10 @@ class ApplicationTest extends TestCase
private function getKernel(array $bundles, $useDispatcher = false)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
if ($useDispatcher) {
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher
->expects($this->atLeastOnce())
->method('dispatch')
@@ -145,7 +145,7 @@ class ApplicationTest extends TestCase
->will($this->returnValue(array()))
;
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundles')
@@ -162,7 +162,7 @@ class ApplicationTest extends TestCase
private function createBundleMock(array $commands)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle
->expects($this->once())
->method('registerCommands')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
index 894e7ae328..2fe271663e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
@@ -147,7 +147,7 @@ class ControllerNameParserTest extends TestCase
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
);
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -178,7 +178,7 @@ class ControllerNameParserTest extends TestCase
private function getBundle($namespace, $name)
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
index 00ffa4c1fd..36e8ed90a7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php
@@ -175,12 +175,12 @@ class ControllerResolverTest extends BaseControllerResolverTest
protected function createMockParser()
{
- return $this->getMock('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', array(), array(), '', false);
+ return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock();
}
protected function createMockContainer()
{
- return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
index eaca189330..14b6e4428e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
@@ -66,14 +66,14 @@ class RedirectControllerTest extends TestCase
$request->attributes = new ParameterBag($attributes);
- $router = $this->getMock('Symfony\Component\Routing\RouterInterface');
+ $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router
->expects($this->once())
->method('generate')
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
->will($this->returnValue($url));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
@@ -230,7 +230,7 @@ class RedirectControllerTest extends TestCase
private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '')
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request
->expects($this->any())
->method('getScheme')
@@ -257,7 +257,7 @@ class RedirectControllerTest extends TestCase
private function createRedirectController($httpPort = null, $httpsPort = null)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
if (null !== $httpPort) {
$container
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
index 61d31cb86b..7ee9aa558e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
@@ -24,11 +24,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
'my_cache_warmer_service3' => 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')
@@ -56,11 +53,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition');
@@ -76,11 +70,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
public function testThatCacheWarmersMightBeNotDefined()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
index 0629d1ebaf..88901dda70 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
@@ -20,14 +20,11 @@ class AddConstraintValidatorsPassTest extends \PHPUnit_Framework_TestCase
'my_constraint_validator_service2' => array(),
);
- $validatorFactoryDefinition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
- );
+ $validatorFactoryDefinition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
- $validatorDefinition1 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
- $validatorDefinition2 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
+ $validatorDefinition1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
+ $validatorDefinition2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
$validatorDefinition1->expects($this->atLeastOnce())
->method('getClass')
@@ -67,11 +64,8 @@ class AddConstraintValidatorsPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
index 97c98d5d8f..e5c6adba8c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
@@ -33,15 +33,12 @@ class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('stdClass'));
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -65,22 +62,19 @@ class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(),
);
- $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRenderer', array(new Reference('my_content_renderer')))
;
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService'));
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
index ad0d65390d..b71fe0a807 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php
@@ -17,9 +17,9 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
{
public function testProcess()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
- $parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
+ $parameterBag = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface')->getMock();
$container->expects($this->exactly(2))
->method('hasAlias')
@@ -60,7 +60,7 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->once())
->method('hasAlias')
->will($this->returnValue(false));
@@ -71,7 +71,7 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->at(0))
->method('hasAlias')
->will($this->returnValue(true));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
index f2af872e3c..9edb44ebb6 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php
@@ -75,10 +75,7 @@ class ProfilerPassTest extends \PHPUnit_Framework_TestCase
private function createContainerMock($services)
{
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter'))->getMock();
$container->expects($this->any())
->method('hasDefinition')
->with($this->equalTo('profiler'))
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
index 27f1636e8c..16a724b460 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
@@ -23,7 +23,7 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
{
public function testThrowExceptionWhenNoNormalizers()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('hasDefinition', 'findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds'))->getMock();
$container->expects($this->once())
->method('hasDefinition')
@@ -43,11 +43,8 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
public function testThrowExceptionWhenNoEncoders()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$container->expects($this->once())
->method('hasDefinition')
@@ -85,7 +82,7 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
new Reference('n3'),
);
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds'));
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container->expects($this->any())
->method('findTaggedServiceIds')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
index 83f70514d5..dcdb0bc5bd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
@@ -18,7 +18,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
{
public function testValidCollector()
{
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->at(0))
->method('addMethodCall')
->with('addLoader', array('xliff', new Reference('xliff')));
@@ -26,10 +26,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
->method('addMethodCall')
->with('addLoader', array('xlf', new Reference('xliff')));
- $container = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition')
- );
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition'))->getMock();
$container->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -41,7 +38,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array('xliff' => array(array('alias' => 'xliff', 'legacy-alias' => 'xlf')))));
$container->expects($this->once())
->method('findDefinition')
- ->will($this->returnValue($this->getMock('Symfony\Component\DependencyInjection\Definition')));
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock()));
$pass = new TranslatorPass();
$pass->process($container);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
index 1757cfee96..cc85cdb02a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
@@ -22,7 +22,7 @@ class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase
{
public function testRender()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->once())
->method('get')
->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock()))
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
index 330e0659ca..d90f5d8358 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php
@@ -214,7 +214,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
*/
private function getServiceContainer(RouteCollection $routes)
{
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader
->expects($this->any())
@@ -222,7 +222,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($routes))
;
- $sc = $this->getMock('Symfony\\Component\\DependencyInjection\\Container', array('get'));
+ $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(array('get'))->getMock();
$sc
->expects($this->once())
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
index 4eaafddfa4..d18427dc4e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php
@@ -85,7 +85,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getEngineMock($template, $supports)
{
- $engine = $this->getMock('Symfony\Component\Templating\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -97,7 +97,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getFrameworkEngineMock($template, $supports)
{
- $engine = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -109,7 +109,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getContainerMock($services)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$i = 0;
foreach ($services as $id => $service) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
index 48a7737dd8..46c9303096 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
@@ -31,7 +31,7 @@ class GlobalVariablesTest extends TestCase
*/
public function testLegacyGetSecurity()
{
- $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
+ $securityContext = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock();
$this->assertNull($this->globals->getSecurity());
$this->container->set('security.context', $securityContext);
@@ -45,7 +45,7 @@ class GlobalVariablesTest extends TestCase
public function testGetUserNoToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getUser());
}
@@ -55,8 +55,8 @@ class GlobalVariablesTest extends TestCase
*/
public function testGetUser($user, $expectedUser)
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
@@ -75,9 +75,9 @@ class GlobalVariablesTest extends TestCase
public function getUserProvider()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$std = new \stdClass();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($user, $user),
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
index 1a0ff5f548..3518267d81 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
@@ -17,7 +17,7 @@ class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
{
public function testDevEnvironment()
{
- $stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$stopwatch->expects($this->once())
->method('start')
->with('foo');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
index 479475732c..aba568c51f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
@@ -22,7 +22,7 @@ class TemplateNameParserTest extends TestCase
protected function setUp()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
index 9411c1cb47..ef01f0e3b8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
@@ -44,7 +44,7 @@ class TimedPhpEngineTest extends TestCase
*/
private function getContainer()
{
- return $this->getMock('Symfony\Component\DependencyInjection\Container');
+ return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock();
}
/**
@@ -52,8 +52,8 @@ class TimedPhpEngineTest extends TestCase
*/
private function getTemplateNameParser()
{
- $templateReference = $this->getMock('Symfony\Component\Templating\TemplateReferenceInterface');
- $templateNameParser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock();
+ $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any())
->method('parse')
->will($this->returnValue($templateReference));
@@ -111,6 +111,6 @@ class TimedPhpEngineTest extends TestCase
*/
private function getStopwatch()
{
- return $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
index e09b0d3f33..11fe9da001 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
@@ -76,7 +76,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
// do it another time as the cache is primed now
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader->expects($this->never())->method('load');
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
@@ -96,7 +96,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function testTransWithCachingWithInvalidLocale()
{
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
$translator->setLocale('invalid locale');
@@ -121,7 +121,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function testGetDefaultLocale()
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('getParameter')
@@ -149,7 +149,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
protected function getLoader()
{
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader
->expects($this->at(0))
->method('load')
@@ -207,7 +207,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
protected function getContainer($loader)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
@@ -248,7 +248,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$translator->setFallbackLocales(array('fr'));
$translator->warmup($this->tmpDir);
- $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader
->expects($this->never())
->method('load');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
index b61851bb0c..12ee6ac673 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php
@@ -21,7 +21,7 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
{
$class = get_class($this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'));
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
@@ -46,14 +46,14 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
$validator = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator');
// mock ContainerBuilder b/c it implements TaggedContainerInterface
- $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder', array('get'));
+ $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('get'))->getMock();
$container
->expects($this->once())
->method('get')
->with($service)
->will($this->returnValue($validator));
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
@@ -68,7 +68,7 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function testGetInstanceInvalidValidatorClass()
{
- $constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint');
+ $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->once())
->method('validatedBy')
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
index acf4788adc..c7845959ac 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
@@ -54,7 +54,7 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCollectWhenAuthenticationTokenIsNull()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock();
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
$collector->collect($this->getRequest(), $this->getResponse());
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
index e4a47a0769..4dfb100e34 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
@@ -28,7 +28,7 @@ class PreviewErrorControllerTest extends TestCase
$code = 123;
$logicalControllerName = 'foo:bar:baz';
- $kernel = $this->getMock('\Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel
->expects($this->once())
->method('handle')
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php
index 08e9d4602d..e8d9476d8d 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php
@@ -31,10 +31,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition')
- );
+ $this->builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition'))->getMock();
$this->chainLoader = new Definition('loader');
$this->pass = new TwigLoaderPass();
}
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php
index 253399ddea..7ef380aaa6 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php
@@ -91,7 +91,7 @@ class LegacyAssetsExtensionTest extends TestCase
private function createContainerMock($helper)
{
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->any())
->method('get')
->with('templating.helper.assets')
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
index 64ba490388..a7abdecb87 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
@@ -19,8 +19,8 @@ class FilesystemLoaderTest extends TestCase
{
public function testGetSourceContext()
{
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator
->expects($this->once())
->method('locate')
@@ -39,8 +39,8 @@ class FilesystemLoaderTest extends TestCase
public function testExists()
{
// should return true for templates that Twig does not find, but Symfony does
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator
->expects($this->once())
->method('locate')
@@ -56,7 +56,7 @@ class FilesystemLoaderTest extends TestCase
*/
public function testTwigErrorIfLocatorThrowsInvalid()
{
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$parser
->expects($this->once())
->method('parse')
@@ -64,7 +64,7 @@ class FilesystemLoaderTest extends TestCase
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
;
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator
->expects($this->once())
->method('locate')
@@ -80,7 +80,7 @@ class FilesystemLoaderTest extends TestCase
*/
public function testTwigErrorIfLocatorReturnsFalse()
{
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$parser
->expects($this->once())
->method('parse')
@@ -88,7 +88,7 @@ class FilesystemLoaderTest extends TestCase
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
;
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator
->expects($this->once())
->method('locate')
@@ -105,8 +105,8 @@ class FilesystemLoaderTest extends TestCase
*/
public function testTwigErrorIfTemplateDoesNotExist()
{
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views');
@@ -118,8 +118,8 @@ class FilesystemLoaderTest extends TestCase
public function testTwigSoftErrorIfTemplateDoesNotExist()
{
- $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
- $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
+ $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views');
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
index 6a5806cd7a..13881c108d 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
@@ -25,7 +25,7 @@ class LegacyRenderTokenParserTest extends TestCase
*/
public function testCompile($source, $expected)
{
- $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
+ $env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env->addTokenParser(new RenderTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env);
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
index a6b9d3b340..8fb21a5aac 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
@@ -22,7 +22,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')
@@ -46,7 +46,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testReturns404onTokenNotFound()
{
- $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')
@@ -74,7 +74,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testSearchResult()
{
- $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')
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
index a3732fde42..e67958de73 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
@@ -45,7 +45,7 @@ class WebProfilerExtensionTest extends TestCase
{
parent::setUp();
- $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
+ $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock();
$this->container = new ContainerBuilder();
$this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'));
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
index f5aa3f4ab8..3b27745ddc 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
@@ -246,11 +246,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true)
{
- $request = $this->getMock(
- 'Symfony\Component\HttpFoundation\Request',
- array('getSession', 'isXmlHttpRequest', 'getRequestFormat'),
- array(), '', false
- );
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock();
$request->expects($this->any())
->method('isXmlHttpRequest')
->will($this->returnValue($isXmlHttpRequest));
@@ -259,7 +255,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($requestFormat));
if ($hasSession) {
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session', array(), array(), '', false);
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
$request->expects($this->any())
->method('getSession')
->will($this->returnValue($session));
@@ -270,7 +266,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getTwigMock($render = 'WDT')
{
- $templating = $this->getMock('Twig_Environment', array(), array(), '', false);
+ $templating = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$templating->expects($this->any())
->method('render')
->will($this->returnValue($render));
@@ -280,11 +276,11 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getUrlGeneratorMock()
{
- return $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
+ return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
}
protected function getKernelMock()
{
- return $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
}
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
index c9b199ea18..4ac2c7de5f 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
@@ -136,9 +136,9 @@ class TemplateManagerTest extends TestCase
->will($this->returnValue('loadedTemplate'));
if (interface_exists('\Twig_SourceContextLoaderInterface')) {
- $loader = $this->getMock('\Twig_SourceContextLoaderInterface');
+ $loader = $this->getMockBuilder('\Twig_SourceContextLoaderInterface')->getMock();
} else {
- $loader = $this->getMock('\Twig_LoaderInterface');
+ $loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock();
}
$this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));
diff --git a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php
index 07f75c9f5b..dea77a587e 100644
--- a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php
+++ b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php
@@ -17,7 +17,7 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
{
public function testGetBasePathEmpty()
{
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackContext = new RequestStackContext($requestStack);
$this->assertEmpty($requestStackContext->getBasePath());
@@ -27,10 +27,10 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
{
$testBasePath = 'test-path';
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('getBasePath')
->willReturn($testBasePath);
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->method('getMasterRequest')
->willReturn($request);
@@ -41,7 +41,7 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
public function testIsSecureFalse()
{
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackContext = new RequestStackContext($requestStack);
$this->assertFalse($requestStackContext->isSecure());
@@ -49,10 +49,10 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
public function testIsSecureTrue()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('isSecure')
->willReturn(true);
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->method('getMasterRequest')
->willReturn($request);
diff --git a/src/Symfony/Component/Asset/Tests/PackagesTest.php b/src/Symfony/Component/Asset/Tests/PackagesTest.php
index 0a78a8b4fa..bb515f2096 100644
--- a/src/Symfony/Component/Asset/Tests/PackagesTest.php
+++ b/src/Symfony/Component/Asset/Tests/PackagesTest.php
@@ -20,8 +20,8 @@ class PackagesTest extends \PHPUnit_Framework_TestCase
public function testGetterSetters()
{
$packages = new Packages();
- $packages->setDefaultPackage($default = $this->getMock('Symfony\Component\Asset\PackageInterface'));
- $packages->addPackage('a', $a = $this->getMock('Symfony\Component\Asset\PackageInterface'));
+ $packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
+ $packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
$this->assertEquals($default, $packages->getPackage());
$this->assertEquals($a, $packages->getPackage('a'));
diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php
index ff5b0a052f..1f0883abad 100644
--- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php
+++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php
@@ -76,7 +76,7 @@ class PathPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($basePath)
{
- $context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface');
+ $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
$context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath));
return $context;
diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
index 327876aeaf..588e998574 100644
--- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
+++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php
@@ -94,7 +94,7 @@ class UrlPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($secure)
{
- $context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface');
+ $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
$context->expects($this->any())->method('isSecure')->will($this->returnValue($secure));
return $context;
diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
index cdb0980307..8f3039df8e 100644
--- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
@@ -33,12 +33,12 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
public function testSupports()
{
- $loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
- $loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
@@ -46,7 +46,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
public function testLoad()
{
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader->expects($this->once())->method('load');
$resolver = new LoaderResolver(array($loader));
@@ -60,7 +60,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
{
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(false));
$resolver = new LoaderResolver(array($loader));
$loader = new DelegatingLoader($resolver);
diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php
index 1e8e91eda1..8f46051bd8 100644
--- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php
@@ -18,9 +18,9 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testImportWithFileLocatorDelegation()
{
- $locatorMock = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
- $locatorMockForAdditionalLoader = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
+ $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
array('path/to/file1'), // Default
array('path/to/file1', 'path/to/file2'), // First is imported
diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
index 03db21be4e..1685f32ed0 100644
--- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
@@ -18,7 +18,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testConstructor()
{
$resolver = new LoaderResolver(array(
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'),
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(),
));
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
@@ -26,11 +26,11 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testResolve()
{
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolver = new LoaderResolver(array($loader));
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
- $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$resolver = new LoaderResolver(array($loader));
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
@@ -39,7 +39,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testLoaders()
{
$resolver = new LoaderResolver();
- $resolver->addLoader($loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'));
+ $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock());
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
}
diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
index e938a4b071..e9f79a8d6d 100644
--- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
+++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
@@ -17,7 +17,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
{
public function testGetSetResolver()
{
- $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
@@ -27,9 +27,9 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testResolve()
{
- $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
- $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo.xml')
@@ -47,7 +47,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testResolveWhenResolverCannotFindLoader()
{
- $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('FOOBAR')
@@ -61,13 +61,13 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
- $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once())
->method('load')
->with('foo')
->will($this->returnValue('yes'));
- $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo')
@@ -81,13 +81,13 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testImportWithType()
{
- $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once())
->method('load')
->with('foo', 'bar')
->will($this->returnValue('yes'));
- $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo', 'bar')
diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
index 7ce5418994..237c197e02 100644
--- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
+++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
@@ -47,7 +47,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
$this->assertContains('XSD file or callable', $e->getMessage());
}
- $mock = $this->getMock(__NAMESPACE__.'\Validator');
+ $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock();
$mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true));
try {
diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php
index 2a503fc5ce..cd45f80dda 100644
--- a/src/Symfony/Component/Console/Tests/ApplicationTest.php
+++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -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')));
@@ -476,7 +476,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testSetCatchExceptions()
{
- $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@@ -523,7 +523,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderException()
{
- $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@@ -547,7 +547,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo3:bar'), array('decorated' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
- $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@@ -560,7 +560,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderExceptionWithDoubleWidthCharacters()
{
- $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@@ -576,7 +576,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo'), array('decorated' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
- $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@@ -710,7 +710,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')
@@ -725,7 +725,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')
diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php
index 4378847369..5abb13a342 100644
--- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php
+++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php
@@ -273,7 +273,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)');
- $command = $this->getMock('TestCommand', array('execute'));
+ $command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock();
$command->expects($this->once())
->method('execute')
->will($this->returnValue('2.3'));
diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
index 998249dbc1..7c7f71971d 100644
--- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
@@ -110,7 +110,7 @@ class HelperSetTest extends \PHPUnit_Framework_TestCase
private function getGenericMockHelper($name, HelperSet $helperset = null)
{
- $mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface');
+ $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
$mock_helper->expects($this->any())
->method('getName')
->will($this->returnValue($name));
diff --git a/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
index f835a71e77..94e5ba89a7 100644
--- a/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
@@ -142,7 +142,7 @@ class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency()
{
- $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display'));
+ $progress = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressHelper')->setMethods(array('display'))->getMock();
$progress->expects($this->exactly(4))
->method('display');
diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
index a35ddbc90a..14ebe134f6 100644
--- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
@@ -294,7 +294,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency()
{
- $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6));
+ $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream(), 6))->getMock();
$bar->expects($this->exactly(4))->method('display');
$bar->setRedrawFrequency(2);
@@ -307,7 +307,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
{
- $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
+ $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock();
$bar->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0);
@@ -317,7 +317,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
{
- $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
+ $bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock();
$bar->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0.9);
diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
index 86ad446c1b..044459660a 100644
--- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
@@ -388,7 +388,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
' [żółw ] bar',
' [łabądź] 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();
@@ -449,7 +449,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
protected function createInputInterfaceMock($interactive = true)
{
- $mock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any())
->method('isInteractive')
->will($this->returnValue($interactive));
diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
index f57d65070e..ac9976ea72 100644
--- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php
@@ -132,7 +132,7 @@ class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
protected function createInputInterfaceMock($interactive = true)
{
- $mock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any())
->method('isInteractive')
->will($this->returnValue($interactive));
diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
index 51c9672787..18ac7ad9e7 100644
--- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
@@ -134,7 +134,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
try {
$handler = ErrorHandler::register();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler->setDefaultLogger($logger, E_NOTICE);
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
@@ -213,7 +213,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler();
restore_exception_handler();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this;
$warnArgCheck = function ($logLevel, $message, $context) use ($that) {
@@ -238,7 +238,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler();
restore_exception_handler();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) {
@@ -306,7 +306,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$that->assertArrayHasKey('stack', $context);
};
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->once())
->method('log')
@@ -325,7 +325,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$exception = new \Exception('foo');
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) {
@@ -372,7 +372,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$handler = ErrorHandler::register();
$handler->screamAt(E_USER_WARNING);
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->exactly(2))
@@ -455,7 +455,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
'line' => 123,
);
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) {
@@ -507,7 +507,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
try {
$handler = ErrorHandler::register();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->once())
->method('log')
@@ -560,7 +560,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler();
restore_exception_handler();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) {
diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
index d4b93c0838..fb105828d2 100644
--- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
@@ -100,7 +100,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('foo');
- $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
+ $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
$handler
->expects($this->exactly(2))
->method('sendPhpResponse');
@@ -119,7 +119,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
- $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
+ $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
$handler
->expects($this->once())
->method('sendPhpResponse');
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php
index b786db95f6..33060dcd0e 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php
@@ -23,7 +23,7 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$this->pass = new ExtensionCompilerPass();
}
@@ -46,10 +46,10 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
private function createExtensionMock($hasInlineCompile)
{
- return $this->getMock('Symfony\Component\DependencyInjection\\'.(
+ return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
$hasInlineCompile
? 'Compiler\CompilerPassInterface'
: 'Extension\ExtensionInterface'
- ));
+ ))->getMock();
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
index aed8cdfe1a..8d957d47b5 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php
@@ -21,7 +21,7 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
{
$tmpProviders = array();
- $extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface');
+ $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->any())
->method('getXsdValidationBasePath')
->will($this->returnValue(false));
@@ -37,7 +37,7 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
$tmpProviders = $container->getExpressionLanguageProviders();
}));
- $provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
$container = new ContainerBuilder(new ParameterBag());
$container->registerExtension($extension);
$container->prependExtensionConfig('foo', array('bar' => true));
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 38a0565a57..b0e99ba3b8 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -275,7 +275,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$builder = new ContainerBuilder();
$builder->setResourceTracking(false);
$builderCompilerPasses = $builder->getCompiler()->getPassConfig()->getPasses();
- $builder->addCompilerPass($this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'));
+ $builder->addCompilerPass($this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock());
$this->assertCount(count($builder->getCompiler()->getPassConfig()->getPasses()) - 1, $builderCompilerPasses);
}
@@ -658,7 +658,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');
@@ -670,7 +670,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')));
diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php
index 6dcf25d2be..a3524c3d72 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php
@@ -25,7 +25,7 @@ class RealServiceInstantiatorTest extends \PHPUnit_Framework_TestCase
{
$instantiator = new RealServiceInstantiator();
$instance = new \stdClass();
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$callback = function () use ($instance) {
return $instance;
};
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
index fcdb54a916..b1f84d4814 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
@@ -30,7 +30,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{
$event = new Event();
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service
->expects($this->once())
@@ -51,7 +51,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{
$event = new Event();
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock();
$service
->expects($this->once())
@@ -86,7 +86,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{
$event = new Event();
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service
->expects($this->once())
@@ -110,7 +110,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
*/
public function testTriggerAListenerServiceOutOfScope()
{
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$scope = new Scope('scope');
$container = new Container();
@@ -133,7 +133,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{
$event = new Event();
- $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service1 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service1
->expects($this->exactly(2))
@@ -152,7 +152,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
$dispatcher->dispatch('onEvent', $event);
- $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service2 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service2
->expects($this->once())
@@ -174,7 +174,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{
$event = new Event();
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container();
$container->set('service.listener', $service);
@@ -200,7 +200,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testGetListenersOnLazyLoad()
{
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container();
$container->set('service.listener', $service);
@@ -217,7 +217,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testRemoveAfterDispatch()
{
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container();
$container->set('service.listener', $service);
@@ -232,7 +232,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testRemoveBeforeDispatch()
{
- $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+ $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container();
$container->set('service.listener', $service);
diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
index dd54e73b34..5c45876662 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
@@ -130,7 +130,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLogger()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
@@ -145,7 +145,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLoggerWithStoppedEvent()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
index 0fdd6372bd..cb04f74beb 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
@@ -29,7 +29,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
'my_event_subscriber' => array(0 => array()),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('isPublic')
->will($this->returnValue(true));
@@ -37,10 +37,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
->method('getClass')
->will($this->returnValue('stdClass'));
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -64,7 +61,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
'my_event_subscriber' => array(0 => array()),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('isPublic')
->will($this->returnValue(true));
@@ -72,10 +69,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
->method('getClass')
->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'));
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
index 80a7e43be6..0f8868037d 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -31,7 +31,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
}
@@ -80,7 +80,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/
public function testAddSubscriberDisallowed()
{
- $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
+ $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->addSubscriber($subscriber);
}
@@ -98,7 +98,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/
public function testRemoveSubscriberDisallowed()
{
- $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
+ $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->removeSubscriber($subscriber);
}
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
index 5af0c4a8e8..d2e60bd649 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
@@ -18,7 +18,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
{
public function testCachedParse()
{
- $cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
+ $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$savedParsedExpression = null;
$expressionLanguage = new ExpressionLanguage($cacheMock);
@@ -116,7 +116,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
public function testCachingWithDifferentNamesOrder()
{
- $cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface');
+ $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
$savedParsedExpressions = array();
$cacheMock
diff --git a/src/Symfony/Component/Form/Tests/AbstractFormTest.php b/src/Symfony/Component/Form/Tests/AbstractFormTest.php
index dc590c918c..ba8b574751 100644
--- a/src/Symfony/Component/Form/Tests/AbstractFormTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractFormTest.php
@@ -37,7 +37,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
// We need an actual dispatcher to use the deprecated
// bindRequest() method
$this->dispatcher = new EventDispatcher();
- $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->form = $this->createForm();
}
@@ -73,8 +73,8 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/
protected function getMockForm($name = 'name')
{
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $config = $this->getMock('Symfony\Component\Form\FormConfigInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
+ $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
$form->expects($this->any())
->method('getName')
@@ -91,7 +91,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/
protected function getDataMapper()
{
- return $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
/**
@@ -99,7 +99,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/
protected function getDataTransformer()
{
- return $this->getMock('Symfony\Component\Form\DataTransformerInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
}
/**
@@ -107,6 +107,6 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/
protected function getFormValidator()
{
- return $this->getMock('Symfony\Component\Form\FormValidatorInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
index e999ea06dc..023863d05c 100644
--- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -28,7 +28,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
\Locale::setDefault('en');
- $this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
+ $this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
parent::setUp();
}
diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
index 022b5148e9..5ddd6cb60b 100644
--- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
@@ -37,10 +37,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->serverParams = $this->getMock(
- 'Symfony\Component\Form\Util\ServerParams',
- array('getNormalizedIniPostMaxSize', 'getContentLength')
- );
+ $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock();
$this->requestHandler = $this->getRequestHandler();
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
$this->request = null;
@@ -363,7 +360,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm($name, $method = null, $compound = true)
{
- $config = $this->getMock('Symfony\Component\Form\FormConfigInterface');
+ $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
$config->expects($this->any())
->method('getMethod')
->will($this->returnValue($method));
@@ -371,7 +368,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
->method('getCompound')
->will($this->returnValue($compound));
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$form->expects($this->any())
->method('getName')
->will($this->returnValue($name));
diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php
index b0c766c73c..5fa2fa1368 100644
--- a/src/Symfony/Component/Form/Tests/ButtonTest.php
+++ b/src/Symfony/Component/Form/Tests/ButtonTest.php
@@ -25,8 +25,8 @@ class ButtonTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $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();
}
/**
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
index d3d530afb5..251a1dfb58 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
@@ -30,7 +30,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
+ $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->factory = new CachingFactoryDecorator($this->decoratedFactory);
}
@@ -295,7 +295,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderSameLoader()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -309,8 +309,8 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderDifferentLoader()
{
- $loader1 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
- $loader2 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
+ $loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list1 = new \stdClass();
$list2 = new \stdClass();
@@ -329,7 +329,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderSameValueClosure()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list = new \stdClass();
$closure = function () {};
@@ -344,7 +344,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderDifferentValueClosure()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list1 = new \stdClass();
$list2 = new \stdClass();
$closure1 = function () {};
@@ -366,7 +366,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSamePreferredChoices()
{
$preferred = array('a');
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -382,7 +382,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$preferred1 = array('a');
$preferred2 = array('b');
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -402,7 +402,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSamePreferredChoicesClosure()
{
$preferred = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -418,7 +418,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$preferred1 = function () {};
$preferred2 = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -438,7 +438,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameLabelClosure()
{
$labels = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -454,7 +454,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$labels1 = function () {};
$labels2 = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -474,7 +474,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameIndexClosure()
{
$index = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -490,7 +490,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$index1 = function () {};
$index2 = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -510,7 +510,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameGroupByClosure()
{
$groupBy = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -526,7 +526,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$groupBy1 = function () {};
$groupBy2 = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -546,7 +546,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameAttributes()
{
$attr = array('class' => 'foobar');
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -562,7 +562,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$attr1 = array('class' => 'foobar1');
$attr2 = array('class' => 'foobar2');
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
@@ -582,7 +582,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameAttributesClosure()
{
$attr = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass();
$this->decoratedFactory->expects($this->once())
@@ -598,7 +598,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{
$attr1 = function () {};
$attr2 = function () {};
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass();
$view2 = new \stdClass();
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php
index 741cde5b43..ac6f5d5c71 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php
@@ -332,7 +332,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoader()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list = $this->factory->createListFromLoader($loader);
@@ -341,7 +341,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderWithValues()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$value = function () {};
$list = $this->factory->createListFromLoader($loader, $value);
@@ -771,7 +771,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$preferred = array(new LegacyChoiceView('x', 'x', 'Preferred'));
$other = array(new LegacyChoiceView('y', 'y', 'Other'));
- $list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock();
$list->expects($this->once())
->method('getPreferredViews')
@@ -798,7 +798,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
new LegacyChoiceView('z', 'z', 'Other one'),
);
- $list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock();
$list->expects($this->once())
->method('getPreferredViews')
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
index 44490a686a..5dc192c3f2 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
@@ -31,7 +31,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
+ $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->factory = new PropertyAccessDecorator($this->decoratedFactory);
}
@@ -84,7 +84,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPath()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@@ -114,7 +114,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@@ -128,7 +128,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPathInstance()
{
- $loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@@ -142,7 +142,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPath()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -159,7 +159,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPathInstance()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -177,7 +177,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -194,7 +194,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPath()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -212,7 +212,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPathInstance()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -230,7 +230,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPath()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -249,7 +249,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPathInstance()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -268,7 +268,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPath()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -288,7 +288,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPathInstance()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -309,7 +309,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -329,7 +329,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPath()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@@ -350,7 +350,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPathInstance()
{
- $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
+ $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
index 5db96e6a7d..3aae8e683d 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php
@@ -37,8 +37,8 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->innerList = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
- $this->loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
+ $this->innerList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
+ $this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->value = function () {};
$this->list = new LazyChoiceList($this->loader, $this->value);
}
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php
index 911d8c001e..32f0729424 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php
@@ -32,7 +32,7 @@ class LegacyChoiceListAdapterTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->adaptedList = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface');
+ $this->adaptedList = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock();
$this->list = new LegacyChoiceListAdapter($this->adaptedList);
}
diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
index 0a9ed8e670..c768f4707b 100644
--- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php
+++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
@@ -925,7 +925,7 @@ class CompoundFormTest extends AbstractFormTest
// Basic cases are covered in SimpleFormTest
public function testCreateViewWithChildren()
{
- $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
+ $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$options = array('a' => 'Foo', 'b' => 'Bar');
$field1 = $this->getMockForm('foo');
$field2 = $this->getMockForm('bar');
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php
index 0597de74e2..3385c05dc4 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php
@@ -34,8 +34,8 @@ class PropertyPathMapperTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->propertyAccessor = $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface');
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->propertyAccessor = $this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyAccessorInterface')->getMock();
$this->mapper = new PropertyPathMapper($this->propertyAccessor);
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
index 7eb716b6d3..ac61acc4e6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
@@ -19,11 +19,7 @@ class BaseDateTimeTransformerTest extends \PHPUnit_Framework_TestCase
*/
public function testConstructFailsIfInputTimezoneIsInvalid()
{
- $this->getMock(
- 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer',
- array(),
- array('this_timezone_does_not_exist')
- );
+ $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(array('this_timezone_does_not_exist'))->getMock();
}
/**
@@ -32,10 +28,6 @@ class BaseDateTimeTransformerTest extends \PHPUnit_Framework_TestCase
*/
public function testConstructFailsIfOutputTimezoneIsInvalid()
{
- $this->getMock(
- 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer',
- array(),
- array(null, 'that_timezone_does_not_exist')
- );
+ $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(array(null, 'that_timezone_does_not_exist'))->getMock();
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
index 2ee2f22db0..9ec553db4b 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
@@ -17,12 +17,12 @@ class DataTransformerChainTest extends \PHPUnit_Framework_TestCase
{
public function testTransform()
{
- $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
+ $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer1->expects($this->once())
->method('transform')
->with($this->identicalTo('foo'))
->will($this->returnValue('bar'));
- $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
+ $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer2->expects($this->once())
->method('transform')
->with($this->identicalTo('bar'))
@@ -35,12 +35,12 @@ class DataTransformerChainTest extends \PHPUnit_Framework_TestCase
public function testReverseTransform()
{
- $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
+ $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer2->expects($this->once())
->method('reverseTransform')
->with($this->identicalTo('foo'))
->will($this->returnValue('bar'));
- $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
+ $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer1->expects($this->once())
->method('reverseTransform')
->with($this->identicalTo('bar'))
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
index b936ea35cc..65cc255394 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
@@ -39,7 +39,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testFixRadio()
{
$data = '1';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$listener = new FixRadioInputListener($this->choiceList, true);
@@ -51,7 +51,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testFixZero()
{
$data = '0';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$listener = new FixRadioInputListener($this->choiceList, true);
@@ -63,7 +63,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testFixEmptyString()
{
$data = '';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$listener = new FixRadioInputListener($this->choiceList, true);
@@ -77,7 +77,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$list = new ArrayKeyChoiceList(array(0 => 'A', 1 => 'B'));
$data = '';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$listener = new FixRadioInputListener($list, true);
@@ -91,7 +91,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$list = new ArrayKeyChoiceList(array(0 => 'A', 1 => 'B'));
$data = '';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$listener = new FixRadioInputListener($list, false);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
index c3c9d08463..d31de3cada 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
@@ -19,7 +19,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
public function testFixHttpUrl()
{
$data = 'www.symfony.com';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
@@ -31,7 +31,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
public function testSkipKnownUrl()
{
$data = 'http://www.symfony.com';
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
@@ -56,7 +56,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testSkipOtherProtocol($url)
{
- $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$event = new FormEvent($form, $url);
$filter = new FixUrlProtocolListener('http');
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
index 2d7ecfec75..ddd46819a4 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
@@ -22,8 +22,8 @@ abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $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();
$this->form = $this->getForm('axes');
}
@@ -45,7 +45,7 @@ abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm()
{
- return $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
}
public function getBooleanMatrix1()
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
index e4959a3c95..52afec7601 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
@@ -24,8 +24,8 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $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();
$this->form = $this->getBuilder()
->setCompound(true)
->setDataMapper($this->getDataMapper())
@@ -54,12 +54,12 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
*/
private function getDataMapper()
{
- return $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
protected function getMockForm()
{
- return $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
}
public function testPreSetDataResizesForm()
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
index 8618de1804..43918643b6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
@@ -23,13 +23,7 @@ class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->session = $this->getMock(
- 'Symfony\Component\HttpFoundation\Session\Session',
- array(),
- array(),
- '',
- false // don't call constructor
- );
+ $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
$this->provider = new SessionCsrfProvider($this->session, 'SECRET');
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
index 4904b679dd..356d1c808c 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
@@ -25,9 +25,9 @@ class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
- $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
+ $this->tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
$this->form = $this->getBuilder('post')
->setDataMapper($this->getDataMapper())
->getForm();
@@ -53,12 +53,12 @@ class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
protected function getDataMapper()
{
- return $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
protected function getMockForm()
{
- return $this->getMock('Symfony\Component\Form\Test\FormInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
}
// https://github.com/symfony/symfony/pull/5838
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
index 3a34394070..0e7261cc2e 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
@@ -42,8 +42,8 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
protected function setUp()
{
- $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
- $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
+ $this->tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
+ $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
parent::setUp();
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php
index da34d4a975..7c44eb7a0b 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php
@@ -27,7 +27,7 @@ class DataCollectorExtensionTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface');
+ $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock();
$this->extension = new DataCollectorExtension($this->dataCollector);
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
index f6fa2493d5..f76b19e4b6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
@@ -65,11 +65,11 @@ class FormDataCollectorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dataExtractor = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface');
+ $this->dataExtractor = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface')->getMock();
$this->dataCollector = new FormDataCollector($this->dataExtractor);
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
- $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
+ $this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
$this->form = $this->createForm('name');
$this->childForm = $this->createForm('child');
$this->view = new FormView();
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
index fc0b76fdf0..ac74746cd8 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
@@ -60,13 +60,13 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
{
$this->valueExporter = new FormDataExtractorTest_SimpleValueExporter();
$this->dataExtractor = new FormDataExtractor($this->valueExporter);
- $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('getName')
->will($this->returnValue('type_name'));
@@ -91,7 +91,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('getName')
->will($this->returnValue('type_name'));
@@ -129,7 +129,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('getName')
->will($this->returnValue('type_name'));
@@ -164,7 +164,7 @@ 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('getName')
->will($this->returnValue('type_name'));
@@ -174,11 +174,11 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
$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)
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php
index 9c53387ce3..abe98e29b1 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php
@@ -27,7 +27,7 @@ class DataCollectorTypeExtensionTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface');
+ $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock();
$this->extension = new DataCollectorTypeExtension($this->dataCollector);
}
@@ -38,7 +38,7 @@ class DataCollectorTypeExtensionTest extends \PHPUnit_Framework_TestCase
public function testBuildForm()
{
- $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
+ $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock();
$builder->expects($this->atLeastOnce())
->method('addEventSubscriber')
->with($this->isInstanceOf('Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener'));
diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php
index 37765991cc..f84220c78c 100644
--- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php
@@ -92,7 +92,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => $method,
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -115,7 +115,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => $method,
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('', null, $dispatcher);
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -138,10 +138,10 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => $method,
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(true);
- $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
+ $config->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -161,7 +161,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => $method,
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(false);
$form = new Form($config);
@@ -181,7 +181,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => 'GET',
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -201,7 +201,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => 'GET',
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('', null, $dispatcher);
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -221,10 +221,10 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => 'GET',
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(true);
- $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
+ $config->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());
$form = new Form($config);
$event = new FormEvent($form, $request);
@@ -240,7 +240,7 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
'REQUEST_METHOD' => 'GET',
));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$config = new FormConfigBuilder('author', null, $dispatcher);
$config->setCompound(false);
$form = new Form($config);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
index e10b43db1a..dc5ff0511e 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
@@ -47,12 +47,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
protected function setUp()
{
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
- $this->serverParams = $this->getMock(
- 'Symfony\Component\Form\Extension\Validator\Util\ServerParams',
- array('getNormalizedIniPostMaxSize', 'getContentLength')
- );
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
+ $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock();
parent::setUp();
}
@@ -69,7 +66,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidate()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => array('group1', 'group2'));
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@@ -85,7 +82,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidateConstraints()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
$constraint2 = new NotBlank(array('groups' => 'group2'));
@@ -158,7 +155,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfParentWithoutCascadeValidation()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent', null, array('cascade_validation' => false))
->setCompound(true)
@@ -192,7 +189,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidateConstraintsEvenIfNoCascadeValidation()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
$constraint2 = new NotBlank(array('groups' => 'group2'));
@@ -219,7 +216,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfNoValidationGroups()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'validation_groups' => array(),
@@ -238,9 +235,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateConstraintsIfNoValidationGroups()
{
- $object = $this->getMock('\stdClass');
- $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
- $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
+ $constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
+ $constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$options = array(
'validation_groups' => array(),
@@ -262,7 +259,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfNotSynchronized()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'invalid_message' => 'invalid_message_key',
@@ -296,7 +293,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testAddInvalidErrorEvenIfNoValidationGroups()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'invalid_message' => 'invalid_message_key',
@@ -331,9 +328,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateConstraintsIfNotSynchronized()
{
- $object = $this->getMock('\stdClass');
- $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
- $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
+ $constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
+ $constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$options = array(
'invalid_message' => 'invalid_message_key',
@@ -366,7 +363,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
// https://github.com/symfony/symfony/issues/4359
public function testDontMarkInvalidIfAnyChildIsNotSynchronized()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$failingTransformer = new CallbackTransformer(
function ($data) { return $data; },
@@ -396,7 +393,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testHandleCallbackValidationGroups()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => array($this, 'getValidationGroups'));
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@@ -412,7 +409,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontExecuteFunctionNames()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => 'header');
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@@ -427,7 +424,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testHandleClosureValidationGroups()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => function (FormInterface $form) {
return array('group1', 'group2');
});
@@ -445,7 +442,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseValidationGroupOfClickedButton()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent')
->setCompound(true)
@@ -472,7 +469,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontUseValidationGroupOfUnclickedButton()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent')
->setCompound(true)
@@ -499,7 +496,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedValidationGroup()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array('validation_groups' => 'group');
$parent = $this->getBuilder('parent', null, $parentOptions)
@@ -521,7 +518,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedCallbackValidationGroup()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array('validation_groups' => array($this, 'getValidationGroups'));
$parent = $this->getBuilder('parent', null, $parentOptions)
@@ -543,7 +540,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedClosureValidationGroup()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array(
'validation_groups' => function (FormInterface $form) {
@@ -569,7 +566,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testAppendPropertyPath()
{
- $object = $this->getMock('\stdClass');
+ $object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass')
->setData($object)
->getForm();
@@ -652,9 +649,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
private function getMockExecutionContext()
{
- $context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
- $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
- $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
+ $context = $this->getMockBuilder('Symfony\Component\Validator\Context\ExecutionContextInterface')->getMock();
+ $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
+ $contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
$validator->expects($this->any())
->method('inContext')
@@ -702,6 +699,6 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
*/
private function getDataMapper()
{
- return $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
index 644d51a46a..3f6a338107 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
@@ -68,7 +68,7 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
public function testValidatorInterfaceSinceSymfony25()
{
// Mock of ValidatorInterface since apiVersion 2.5
- $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
+ $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$formTypeValidatorExtension = new FormTypeValidatorExtension($validator);
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension);
@@ -77,7 +77,7 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
public function testValidatorInterfaceUntilSymfony24()
{
// Mock of ValidatorInterface until apiVersion 2.4
- $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
+ $validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock();
$formTypeValidatorExtension = new FormTypeValidatorExtension($validator);
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php
index dbe13a2745..8c0984f7e4 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php
@@ -19,7 +19,7 @@ class UploadValidatorExtensionTest extends TypeTestCase
{
public function testPostMaxSizeTranslation()
{
- $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
$translator->expects($this->any())
->method('trans')
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php
index 957b59702e..3627f4b9e6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php
@@ -31,7 +31,7 @@ class ServerParamsTest extends \PHPUnit_Framework_TestCase
public function testGetContentLengthFromRequest()
{
$request = Request::create('http://foo', 'GET', array(), array(), array(), array('CONTENT_LENGTH' => 1024));
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('getCurrentRequest'));
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('getCurrentRequest'))->getMock();
$requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
$serverParams = new ServerParams($requestStack);
@@ -41,7 +41,7 @@ class ServerParamsTest extends \PHPUnit_Framework_TestCase
/** @dataProvider getGetPostMaxSizeTestData */
public function testGetPostMaxSize($size, $bytes)
{
- $serverParams = $this->getMock('Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize'));
+ $serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize'))->getMock();
$serverParams
->expects($this->any())
->method('getNormalizedIniPostMaxSize')
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
index 74da4aee1c..314a645dbc 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
@@ -62,7 +62,7 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->mapper = new ViolationMapper();
$this->message = 'Message';
$this->messageTemplate = 'Message template';
@@ -95,7 +95,7 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
*/
private function getDataMapper()
{
- return $this->getMock('Symfony\Component\Form\DataMapperInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
/**
diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php
index 86f50b50ec..d8e490a674 100644
--- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php
+++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php
@@ -23,8 +23,8 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $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();
$this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory);
}
@@ -120,7 +120,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase
public function testAddFormType()
{
$this->assertFalse($this->builder->has('foo'));
- $this->builder->add('foo', $this->getMock('Symfony\Component\Form\FormTypeInterface'));
+ $this->builder->add('foo', $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock());
$this->assertTrue($this->builder->has('foo'));
}
diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php
index b77632c505..1bfaf4d0e0 100644
--- a/src/Symfony/Component/Form/Tests/FormConfigTest.php
+++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php
@@ -71,7 +71,7 @@ class FormConfigTest extends \PHPUnit_Framework_TestCase
*/
public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $accepted)
{
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
try {
new FormConfigBuilder($name, null, $dispatcher);
@@ -141,7 +141,7 @@ class FormConfigTest extends \PHPUnit_Framework_TestCase
private function getConfigBuilder($name = 'name')
{
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
return new FormConfigBuilder($name, null, $dispatcher);
}
diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
index 32b6e73394..169f35f9a4 100644
--- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php
+++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
@@ -57,11 +57,11 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactoryInterface');
- $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
- $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
- $this->registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface');
- $this->builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
+ $this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactoryInterface')->getMock();
+ $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
+ $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
+ $this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
+ $this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock();
$this->factory = new FormFactory($this->registry, $this->resolvedTypeFactory);
$this->registry->expects($this->any())
@@ -611,7 +611,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateBuilderForPropertyWithoutTypeGuesser()
{
- $registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface');
+ $registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
$factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
->setMethods(array('createNamedBuilder'))
->setConstructorArgs(array($registry, $this->resolvedTypeFactory))
@@ -850,6 +850,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
private function getMockResolvedType()
{
- return $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
+ return $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index 64a83e3570..961eaba55c 100644
--- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php
+++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
@@ -685,8 +685,8 @@ class SimpleFormTest extends AbstractFormTest
public function testCreateView()
{
- $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
- $view = $this->getMock('Symfony\Component\Form\FormView');
+ $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
+ $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$form = $this->getBuilder()->setType($type)->getForm();
$type->expects($this->once())
@@ -699,10 +699,10 @@ class SimpleFormTest extends AbstractFormTest
public function testCreateViewWithParent()
{
- $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
- $view = $this->getMock('Symfony\Component\Form\FormView');
- $parentForm = $this->getMock('Symfony\Component\Form\Test\FormInterface');
- $parentView = $this->getMock('Symfony\Component\Form\FormView');
+ $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
+ $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
+ $parentForm = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
+ $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$form = $this->getBuilder()->setType($type)->getForm();
$form->setParent($parentForm);
@@ -720,9 +720,9 @@ class SimpleFormTest extends AbstractFormTest
public function testCreateViewWithExplicitParent()
{
- $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
- $view = $this->getMock('Symfony\Component\Form\FormView');
- $parentView = $this->getMock('Symfony\Component\Form\FormView');
+ $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
+ $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
+ $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$form = $this->getBuilder()->setType($type)->getForm();
$type->expects($this->once())
@@ -857,7 +857,7 @@ class SimpleFormTest extends AbstractFormTest
public function testViewDataMayBeArrayAccessIfDataClassIsNull()
{
- $arrayAccess = $this->getMock('\ArrayAccess');
+ $arrayAccess = $this->getMockBuilder('\ArrayAccess')->getMock();
$config = new FormConfigBuilder('name', null, $this->dispatcher);
$config->addViewTransformer(new FixedDataTransformer(array(
'' => '',
@@ -921,7 +921,7 @@ class SimpleFormTest extends AbstractFormTest
public function testHandleRequestForwardsToRequestHandler()
{
- $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface');
+ $handler = $this->getMockBuilder('Symfony\Component\Form\RequestHandlerInterface')->getMock();
$form = $this->getBuilder()
->setRequestHandler($handler)
@@ -1034,7 +1034,7 @@ class SimpleFormTest extends AbstractFormTest
public function testInitializeSetsDefaultData()
{
$config = $this->getBuilder()->setData('DEFAULT')->getFormConfig();
- $form = $this->getMock('Symfony\Component\Form\Form', array('setData'), array($config));
+ $form = $this->getMockBuilder('Symfony\Component\Form\Form')->setMethods(array('setData'))->setConstructorArgs(array($config))->getMock();
$form->expects($this->once())
->method('setData')
diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
index a92f572884..129d99eea4 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
@@ -166,7 +166,7 @@ class FileTest extends \PHPUnit_Framework_TestCase
protected function createMockGuesser($path, $mimeType)
{
- $guesser = $this->getMock('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface');
+ $guesser = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface')->getMock();
$guesser
->expects($this->once())
->method('guess')
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
index 97674d48fd..d73dd3d344 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -442,7 +442,7 @@ class ResponseTest extends ResponseTestCase
public function testDefaultContentType()
{
- $headerMock = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag', array('set'));
+ $headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(array('set'))->getMock();
$headerMock->expects($this->at(0))
->method('set')
->with('Content-Type', 'text/html');
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php
index 6745a22455..b321a9279c 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php
@@ -35,7 +35,7 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
}
parent::setUp();
- $this->memcache = $this->getMock('Memcache');
+ $this->memcache = $this->getMockBuilder('Memcache')->getMock();
$this->storage = new MemcacheSessionHandler(
$this->memcache,
array('prefix' => self::PREFIX, 'expiretime' => self::TTL)
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
index bd023ed165..2ffd7c15c5 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
@@ -41,7 +41,7 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher');
}
- $this->memcached = $this->getMock('Memcached');
+ $this->memcached = $this->getMockBuilder('Memcached')->getMock();
$this->storage = new MemcachedSessionHandler(
$this->memcached,
array('prefix' => self::PREFIX, 'expiretime' => self::TTL)
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
index 1f88d00d8f..cfc8acebaa 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
@@ -140,7 +140,7 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
}
$pdo = new MockPdo('pgsql');
- $pdo->prepareResult = $this->getMock('PDOStatement');
+ $pdo->prepareResult = $this->getMockBuilder('PDOStatement')->getMock();
$content = 'foobar';
$stream = $this->createStream($content);
@@ -161,8 +161,8 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
}
$pdo = new MockPdo('pgsql');
- $selectStmt = $this->getMock('PDOStatement');
- $insertStmt = $this->getMock('PDOStatement');
+ $selectStmt = $this->getMockBuilder('PDOStatement')->getMock();
+ $insertStmt = $this->getMockBuilder('PDOStatement')->getMock();
$pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) {
return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt;
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php
index 069c887039..4fbf31aa3e 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php
@@ -20,7 +20,7 @@ class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase
{
public function test()
{
- $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface');
+ $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock);
$wrappedSessionHandlerMock
@@ -35,7 +35,7 @@ class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase
public function testWrite()
{
- $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface');
+ $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock);
$wrappedSessionHandlerMock
@@ -50,7 +50,7 @@ class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase
public function testSkippedWrite()
{
- $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface');
+ $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock);
$wrappedSessionHandlerMock
@@ -71,7 +71,7 @@ class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase
public function testNonSkippedWrite()
{
- $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface');
+ $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock);
$wrappedSessionHandlerMock
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
index d2775a80a2..052296a4c5 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
@@ -35,7 +35,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->mock = $this->getMock('SessionHandlerInterface');
+ $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$this->proxy = new SessionHandlerProxy($this->mock);
}
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
index 9a499a737a..7929cfc614 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
@@ -12,10 +12,8 @@
namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\HttpFoundation\ParameterBag;
-use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -40,12 +38,8 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$responseHeaders = $response->headers->all();
- $cookies = array();
foreach ($response->headers->getCookies() as $cookie) {
- $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
- }
- if (count($cookies) > 0) {
- $responseHeaders['Set-Cookie'] = $cookies;
+ $responseHeaders['set-cookie'][] = (string) $cookie;
}
// attributes are serialized and as they can be anything, they need to be converted to strings.
@@ -121,6 +115,18 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$this->data['request_request']['_password'] = '******';
}
+ foreach ($this->data as $key => $value) {
+ if (!is_array($value)) {
+ continue;
+ }
+ if ('request_headers' === $key || 'response_headers' === $key) {
+ $value = array_map(function ($v) { return isset($v[0]) && !isset($v[1]) ? $v[0] : $v; }, $value);
+ }
+ if ('request_server' !== $key && 'request_cookies' !== $key) {
+ $this->data[$key] = $value;
+ }
+ }
+
if (isset($this->controllers[$request])) {
$controller = $this->controllers[$request];
if (is_array($controller)) {
@@ -183,7 +189,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
public function getRequestHeaders()
{
- return new HeaderBag($this->data['request_headers']);
+ return new ParameterBag($this->data['request_headers']);
}
public function getRequestServer()
@@ -203,7 +209,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
public function getResponseHeaders()
{
- return new ResponseHeaderBag($this->data['response_headers']);
+ return new ParameterBag($this->data['response_headers']);
}
public function getSessionMetadata()
@@ -302,41 +308,4 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
{
return 'request';
}
-
- private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly)
- {
- $cookie = sprintf('%s=%s', $name, urlencode($value));
-
- if (0 !== $expires) {
- if (is_numeric($expires)) {
- $expires = (int) $expires;
- } elseif ($expires instanceof \DateTime) {
- $expires = $expires->getTimestamp();
- } else {
- $tmp = strtotime($expires);
- if (false === $tmp || -1 == $tmp) {
- throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires));
- }
- $expires = $tmp;
- }
-
- $cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T'));
- }
-
- if ($domain) {
- $cookie .= '; domain='.$domain;
- }
-
- $cookie .= '; path='.$path;
-
- if ($secure) {
- $cookie .= '; secure';
- }
-
- if ($httponly) {
- $cookie .= '; httponly';
- }
-
- return $cookie;
- }
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
index ee0c3128f1..a421bd0f67 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
@@ -32,7 +32,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase
public function testRegisterCommands()
{
$cmd = new FooCommand();
- $app = $this->getMock('Symfony\Component\Console\Application');
+ $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
$app->expects($this->once())->method('add')->with($this->equalTo($cmd));
$bundle = new ExtensionPresentBundle();
@@ -58,7 +58,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase
$container = new ContainerBuilder();
$container->register('console.command.Symfony_Component_HttpKernel_Tests_Fixtures_ExtensionPresentBundle_Command_FooCommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand');
- $application = $this->getMock('Symfony\Component\Console\Application');
+ $application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
// add() is never called when the found command classes are already registered as services
$application->expects($this->never())->method('add');
diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php
index b54d169a59..41af579b06 100644
--- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php
@@ -52,6 +52,6 @@ class ChainCacheClearerTest extends \PHPUnit_Framework_TestCase
protected function getMockClearer()
{
- return $this->getMock('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface');
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
index be59486269..b7babf2c5f 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php
@@ -17,7 +17,7 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase
{
public function testLocate()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->atLeastOnce())
->method('locateResource')
@@ -35,7 +35,7 @@ class FileLocatorTest extends \PHPUnit_Framework_TestCase
public function testLocateWithGlobalResourcePath()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->atLeastOnce())
->method('locateResource')
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
index f3b0ac025d..53aa6ca3c6 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
@@ -21,7 +21,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
{
public function testGetControllerWithoutControllerParameter()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.');
$resolver = $this->createControllerResolver($logger);
@@ -215,7 +215,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
public function testCreateControllerCanReturnAnyCallable()
{
- $mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
+ $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(array('createController'))->getMock();
$mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'));
$request = Request::create('/');
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
index 4c1f380d41..451da66216 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
@@ -20,7 +20,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
{
- $logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
+ $logger = $this->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')->getMock();
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
index 2eb1c41e8d..ba70bfa92a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
@@ -31,7 +31,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
$attributes = $c->getRequestAttributes();
$this->assertSame('request', $c->getName());
- $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getRequestHeaders());
+ $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes);
@@ -45,7 +45,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
$this->assertRegExp('/Resource\(stream#\d+\)/', $attributes->get('resource'));
$this->assertSame('Object(stdClass)', $attributes->get('object'));
- $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders());
+ $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders());
$this->assertSame('OK', $c->getStatusText());
$this->assertSame(200, $c->getStatusCode());
$this->assertSame('application/json', $c->getContentType());
@@ -185,7 +185,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
protected function injectController($collector, $controller, $request)
{
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver);
$event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
$collector->onKernelController($event);
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
index 0bdcccd53d..a07e924d86 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
@@ -41,7 +41,7 @@ class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase
$c->collect($request, new Response());
$this->assertEquals(0, $c->getStartTime());
- $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
$c = new TimeDataCollector($kernel);
diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
index f64d7247c0..32b286999f 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
@@ -108,7 +108,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
protected function getHttpKernel($dispatcher, $controller)
{
- $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock();
$resolver->expects($this->once())->method('getController')->will($this->returnValue($controller));
$resolver->expects($this->once())->method('getArguments')->will($this->returnValue(array()));
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php
index c32f5bb01a..c6ce79783b 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php
@@ -34,7 +34,7 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
return $expected;
};
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$this
->expectsEnterScopeOnce($container)
->expectsLeaveScopeOnce($container)
@@ -63,11 +63,11 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
return $expected;
};
- $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
+ $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock();
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
$stack->expects($this->at(1))->method('pop');
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$dispatcher = new EventDispatcher();
$resolver = $this->getResolverMockFor($controller, $request);
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
@@ -86,7 +86,7 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
throw $expected;
};
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$this
->expectsEnterScopeOnce($container)
->expectsLeaveScopeOnce($container)
@@ -95,7 +95,7 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
;
$dispatcher = new EventDispatcher();
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$resolver = $this->getResolverMockFor($controller, $request);
$stack = new RequestStack();
$kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack);
@@ -120,7 +120,7 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
private function getResolverMockFor($controller, $request)
{
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$resolver->expects($this->once())
->method('getController')
->with($request)
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
index 3e2bfd072a..c4652cd88a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
@@ -28,14 +28,14 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(array()),
);
- $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRenderer', array(new Reference('my_content_renderer')))
;
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
@@ -45,10 +45,7 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true))
;
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -79,12 +76,9 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(array('alias' => 'foo')),
);
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@@ -108,14 +102,14 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(array('alias' => 'foo')),
);
- $renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRendererService', array('foo', 'my_content_renderer'))
;
- $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
@@ -125,10 +119,7 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true))
;
- $builder = $this->getMock(
- 'Symfony\Component\DependencyInjection\ContainerBuilder',
- array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
- );
+ $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
index 34bd87a9a9..12fbf23f9b 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php
@@ -19,14 +19,14 @@ class LazyLoadingFragmentHandlerTest extends \PHPUnit_Framework_TestCase
{
public function test()
{
- $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface');
+ $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
- $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->once())->method('get')->will($this->returnValue($renderer));
$handler = new LazyLoadingFragmentHandler($container, $requestStack, false);
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php
index 895973d7c4..516813f072 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php
@@ -17,18 +17,8 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
{
public function testAutoloadMainExtension()
{
- $container = $this->getMock(
- 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
- array(
- 'getExtensionConfig',
- 'loadFromExtension',
- 'getParameterBag',
- 'getDefinitions',
- 'getAliases',
- 'getExtensions',
- )
- );
- $params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag');
+ $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('getExtensionConfig', 'loadFromExtension', 'getParameterBag', 'getDefinitions', 'getAliases', 'getExtensions'))->getMock();
+ $params = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag')->getMock();
$container->expects($this->at(0))
->method('getExtensionConfig')
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
index 3a82ce0fb6..0f3577cbdb 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php
@@ -64,7 +64,7 @@ class AddRequestFormatsListenerTest extends \PHPUnit_Framework_TestCase
protected function getRequestMock()
{
- return $this->getMock('Symfony\Component\HttpFoundation\Request');
+ return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
}
protected function getGetResponseEventMock(Request $request)
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
index 8e1c35b345..2aa284cc71 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php
@@ -36,7 +36,7 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase
{
public function testConfigure()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$userHandler = function () {};
$listener = new DebugHandlersListener($userHandler, $logger);
$xHandler = new ExceptionHandler();
@@ -70,7 +70,7 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase
$listener = new DebugHandlersListener(null);
$eHandler = new ErrorHandler();
$event = new KernelEvent(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
Request::create('/'),
HttpKernelInterface::MASTER_REQUEST
);
@@ -94,7 +94,7 @@ class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase
{
$dispatcher = new EventDispatcher();
$listener = new DebugHandlersListener(null);
- $app = $this->getMock('Symfony\Component\Console\Application');
+ $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
$app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
$command = new Command(__FUNCTION__);
$command->setApplication($app);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
index 947af11228..94c2557fb1 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
@@ -105,9 +105,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
public function testSubRequestFormat()
{
- $listener = new ExceptionListener('foo', $this->getMock('Psr\Log\LoggerInterface'));
+ $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock());
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
return new Response($request->getRequestFormat());
}));
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
index 7cfce98f2e..b1d7d82c13 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
@@ -116,6 +116,6 @@ class FragmentListenerTest extends \PHPUnit_Framework_TestCase
private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST)
{
- return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType);
+ return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, $requestType);
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
index a23268ca1d..46444e6600 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
@@ -22,7 +22,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false);
+ $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock();
}
public function testDefaultLocaleWithoutSession()
@@ -51,10 +51,10 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
public function testLocaleSetForRoutingContext()
{
// the request context is updated
- $context = $this->getMock('Symfony\Component\Routing\RequestContext');
+ $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock();
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
- $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false);
+ $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock();
$router->expects($this->once())->method('getContext')->will($this->returnValue($context));
$request = Request::create('/');
@@ -67,10 +67,10 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
public function testRouterResetWithParentRequestOnKernelFinishRequest()
{
// the request context is updated
- $context = $this->getMock('Symfony\Component\Routing\RequestContext');
+ $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock();
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
- $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false);
+ $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock();
$router->expects($this->once())->method('getContext')->will($this->returnValue($context));
$parentRequest = Request::create('/');
@@ -78,7 +78,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
$this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\FinishRequestEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock();
$listener = new LocaleListener($this->requestStack, 'fr', $router);
$listener->onKernelFinishRequest($event);
@@ -97,6 +97,6 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
private function getEvent(Request $request)
{
- return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST);
+ return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
index ce6fe8e5c1..16724d5116 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php
@@ -40,7 +40,7 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
->method('collect')
->will($this->returnValue($profile));
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
->disableOriginalConstructor()
@@ -73,7 +73,7 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
->method('collect')
->will($this->returnValue($profile));
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
->disableOriginalConstructor()
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php
index 821688eff4..e23c2cd188 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php
@@ -31,7 +31,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
$listener = new ResponseListener('UTF-8');
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'));
- $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
}
protected function tearDown()
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
index 9eb1ec96ce..c6c05e644f 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
@@ -23,7 +23,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false);
+ $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock();
}
/**
@@ -67,7 +67,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
*/
private function createGetResponseEventForUri($uri)
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create($uri);
$request->attributes->set('_controller', null); // Prevents going in to routing process
@@ -84,11 +84,11 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
public function testRequestMatcher()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('http://localhost/');
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
- $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
@@ -100,11 +100,11 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
public function testSubRequestWithDifferentMethod()
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('http://localhost/', 'post');
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
- $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->any())
->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
@@ -116,7 +116,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
$listener->onKernelRequest($event);
// sub-request with another HTTP method
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('http://localhost/', 'get');
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST);
@@ -130,17 +130,17 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testLoggingParameter($parameter, $log)
{
- $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
->method('matchRequest')
->will($this->returnValue($parameter));
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once())
->method('info')
->with($this->equalTo($log));
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('http://localhost/');
$listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php
index 1a0acf92fa..0100131f00 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php
@@ -25,7 +25,7 @@ class SurrogateListenerTest extends \PHPUnit_Framework_TestCase
public function testFilterDoesNothingForSubRequests()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$response = new Response('foo ');
$listener = new SurrogateListener(new Esi());
@@ -39,7 +39,7 @@ class SurrogateListenerTest extends \PHPUnit_Framework_TestCase
public function testFilterWhenThereIsSomeEsiIncludes()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$response = new Response('foo ');
$listener = new SurrogateListener(new Esi());
@@ -53,7 +53,7 @@ class SurrogateListenerTest extends \PHPUnit_Framework_TestCase
public function testFilterWhenThereIsNoEsiIncludes()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$response = new Response('foo');
$listener = new SurrogateListener(new Esi());
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
index cbaaf5f93a..34f561d149 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
@@ -82,7 +82,7 @@ class TestSessionListenerTest extends \PHPUnit_Framework_TestCase
{
$request->setSession($this->session);
$response = new Response();
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$event = new FilterResponseEvent($kernel, $request, $type, $response);
$this->listener->onKernelResponse($event);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
index c37d64786c..b5b05bb454 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php
@@ -25,8 +25,8 @@ class TranslatorListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
- $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+ $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$this->listener = new TranslatorListener($this->translator, $this->requestStack);
}
@@ -96,7 +96,7 @@ class TranslatorListenerTest extends \PHPUnit_Framework_TestCase
private function createHttpKernel()
{
- return $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
}
private function createRequest($locale)
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
index b9d8f06f00..7fcbc3b7e6 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
@@ -26,7 +26,7 @@ class ValidateRequestListenerTest extends \PHPUnit_Framework_TestCase
public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = new Request();
$request->setTrustedProxies(array('1.1.1.1'));
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
index 79fee3fcb6..230c15eda4 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
@@ -74,7 +74,7 @@ class FragmentHandlerTest extends \PHPUnit_Framework_TestCase
protected function getHandler($returnValue, $arguments = array())
{
- $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface');
+ $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
$renderer
->expects($this->any())
->method('getName')
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
index 2f266dba77..9a9373c6d5 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -75,7 +75,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testRenderWithDefaultText()
{
- $engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
$engine->expects($this->once())
->method('exists')
->with('default')
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
index d14ebb0d12..49e94a0bb0 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
@@ -51,7 +51,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController()
{
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', array('getController'));
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(array('getController'))->getMock();
$resolver
->expects($this->once())
->method('getController')
@@ -84,7 +84,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
public function testRenderExceptionNoIgnoreErrors()
{
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher->expects($this->never())->method('dispatch');
$strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
@@ -94,7 +94,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testRenderExceptionIgnoreErrors()
{
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION);
$strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
@@ -114,7 +114,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
private function getKernel($returnValue)
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel
->expects($this->any())
->method('handle')
@@ -130,7 +130,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
private function getKernelExpectingRequest(Request $request)
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel
->expects($this->any())
->method('handle')
@@ -142,7 +142,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
{
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$resolver
->expects($this->once())
->method('getController')
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
index 0d52ce89db..dd8955780d 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
@@ -225,7 +225,7 @@ class EsiTest extends \PHPUnit_Framework_TestCase
protected function getCache($request, $response)
{
- $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false);
+ $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('getRequest')
->will($this->returnValue($request))
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
index 07b70dcee8..357fc56717 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
@@ -192,7 +192,7 @@ class SsiTest extends \PHPUnit_Framework_TestCase
protected function getCache($request, $response)
{
- $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false);
+ $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('getRequest')
->will($this->returnValue($request))
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
index 0fd0fdec7b..270926f79c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
@@ -261,7 +261,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
{
$request = new Request();
- $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
+ $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock();
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
$stack->expects($this->at(1))->method('pop');
@@ -298,7 +298,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
$controller = function () { return new Response('Hello'); };
}
- $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
+ $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$resolver->expects($this->any())
->method('getController')
->will($this->returnValue($controller));
diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
index 1fbc272beb..8639818397 100644
--- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
@@ -65,7 +65,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
public function testBootSetsTheContainerToTheBundles()
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle->expects($this->once())
->method('setContainer');
@@ -162,7 +162,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
public function testShutdownCallsShutdownOnAllBundles()
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle->expects($this->once())
->method('shutdown');
@@ -174,7 +174,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase
public function testShutdownGivesNullContainerToAllBundles()
{
- $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
+ $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle->expects($this->at(3))
->method('setContainer')
->with(null);
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
index 90bdc4835e..9ddef240a4 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
@@ -62,7 +62,7 @@ class BundleEntryReaderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->readerImpl = $this->getMock('Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface');
+ $this->readerImpl = $this->getMockBuilder('Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface')->getMock();
$this->reader = new BundleEntryReader($this->readerImpl);
}
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
index ad87687bc0..9b53998cad 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
@@ -121,8 +121,8 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testSetValueCallsAdderAndRemoverForNestedCollections()
{
- $car = $this->getMock(__CLASS__.'_CompositeCar');
- $structure = $this->getMock(__CLASS__.'_CarStructure');
+ $car = $this->getMockBuilder(__CLASS__.'_CompositeCar')->getMock();
+ $structure = $this->getMockBuilder(__CLASS__.'_CarStructure')->getMock();
$axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth'));
$axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third'));
@@ -152,7 +152,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
*/
public function testSetValueFailsIfNoAdderNorRemoverFound()
{
- $car = $this->getMock(__CLASS__.'_CarNoAdderAndRemover');
+ $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
$axesBefore = $this->getContainer(array(1 => 'second', 3 => 'fourth'));
$axesAfter = $this->getContainer(array(0 => 'first', 1 => 'second', 2 => 'third'));
@@ -165,25 +165,25 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
{
- $car = $this->getMock(__CLASS__.'_Car');
+ $car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfOnlyAdderExists()
{
- $car = $this->getMock(__CLASS__.'_CarOnlyAdder');
+ $car = $this->getMockBuilder(__CLASS__.'_CarOnlyAdder')->getMock();
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfOnlyRemoverExists()
{
- $car = $this->getMock(__CLASS__.'_CarOnlyRemover');
+ $car = $this->getMockBuilder(__CLASS__.'_CarOnlyRemover')->getMock();
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
{
- $car = $this->getMock(__CLASS__.'_CarNoAdderAndRemover');
+ $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
@@ -193,7 +193,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
*/
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
{
- $car = $this->getMock(__CLASS__.'_Car');
+ $car = $this->getMockBuilder(__CLASS__.'_Car')->getMock();
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');
}
diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
index b2a4ecd72d..9f4090ff86 100644
--- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
+++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
@@ -208,7 +208,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
{
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once())
->method('error');
$generator = $this->getGenerator($routes, array(), $logger);
diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
index 5d66446f0f..ed7c5a4ba7 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
@@ -18,7 +18,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testSupports()
{
- $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
+ $loader = new PhpFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
$this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
index 78065070a0..f2edebd584 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
@@ -19,7 +19,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testSupports()
{
- $loader = new XmlFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
+ $loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
index de1542040b..d3edc08494 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
@@ -19,7 +19,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testSupports()
{
- $loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
+ $loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
$this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
$this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable');
diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php
index 9a1c568ee3..fd418e1300 100644
--- a/src/Symfony/Component/Routing/Tests/RouterTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouterTest.php
@@ -22,7 +22,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
+ $this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$this->router = new Router($this->loader, 'routing.yml');
}
@@ -82,7 +82,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
{
$this->router->setOption('resource_type', 'ResourceType');
- $routeCollection = $this->getMock('Symfony\Component\Routing\RouteCollection');
+ $routeCollection = $this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock();
$this->loader->expects($this->once())
->method('load')->with('routing.yml', 'ResourceType')
@@ -100,7 +100,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
- ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection')));
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock()));
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
}
@@ -122,7 +122,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
- ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection')));
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock()));
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator());
}
@@ -137,7 +137,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testMatchRequestWithUrlMatcherInterface()
{
- $matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
+ $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$matcher->expects($this->once())->method('match');
$p = new \ReflectionProperty($this->router, 'matcher');
@@ -149,7 +149,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testMatchRequestWithRequestMatcherInterface()
{
- $matcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$matcher->expects($this->once())->method('matchRequest');
$p = new \ReflectionProperty($this->router, 'matcher');
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
index cc8b7c0202..274992ed04 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
@@ -44,7 +44,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (ProviderNotFoundException $e) {
$this->assertSame($token, $e->getToken());
@@ -58,7 +58,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (AccountStatusException $e) {
$this->assertSame($token, $e->getToken());
@@ -72,7 +72,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (AuthenticationException $e) {
$this->assertSame($token, $e->getToken());
@@ -83,26 +83,26 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
{
$manager = new AuthenticationProviderManager(array(
$this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'),
- $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
+ $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($expected, $token);
}
public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider()
{
- $second = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
+ $second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
$second
->expects($this->never())
->method('supports')
;
$manager = new AuthenticationProviderManager(array(
- $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
+ $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
$second,
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($expected, $token);
}
@@ -112,20 +112,20 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('', $token->getCredentials());
$manager = new AuthenticationProviderManager(array(
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
), false);
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('bar', $token->getCredentials());
}
protected function getAuthenticationProvider($supports, $token = null, $exception = null)
{
- $provider = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
$provider->expects($this->once())
->method('supports')
->will($this->returnValue($supports))
@@ -139,7 +139,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
} elseif (null !== $exception) {
$provider->expects($this->once())
->method('authenticate')
- ->will($this->throwException($this->getMock($exception, null, array(), '')))
+ ->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
;
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
index 36409811c7..e3f7f5f18b 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
@@ -47,17 +47,17 @@ class AuthenticationTrustResolverTest extends \PHPUnit_Framework_TestCase
protected function getToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
protected function getAnonymousToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', ''));
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock();
}
protected function getRememberMeToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock();
}
protected function getResolver()
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
index 3eedb8e584..8edf1b02d4 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
@@ -34,13 +34,13 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testRetrieveUserWhenUsernameIsNotFound()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->throwException(new UsernameNotFoundException()))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -52,13 +52,13 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testRetrieveUserWhenAnExceptionOccurs()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->throwException(new \RuntimeException()))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -67,19 +67,19 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->never())
->method('loadUserByUsername')
;
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getUser')
->will($this->returnValue($user))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$reflection = new \ReflectionMethod($provider, 'retrieveUser');
$reflection->setAccessible(true);
$result = $reflection->invoke($provider, null, $token);
@@ -89,15 +89,15 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUser()
{
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->returnValue($user))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -109,7 +109,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationWhenCredentialsAreEmpty()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder
->expects($this->never())
->method('isPasswordValid')
@@ -128,14 +128,14 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$method->invoke(
$provider,
- $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'),
+ $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
$token
);
}
public function testCheckAuthenticationWhenCredentialsAre0()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder
->expects($this->once())
->method('isPasswordValid')
@@ -155,7 +155,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$method->invoke(
$provider,
- $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'),
+ $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
$token
);
}
@@ -165,7 +165,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationWhenCredentialsAreNotValid()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
->will($this->returnValue(false))
@@ -181,7 +181,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token);
+ $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
}
/**
@@ -189,7 +189,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
{
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$user->expects($this->once())
->method('getPassword')
->will($this->returnValue('foo'))
@@ -200,7 +200,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('getUser')
->will($this->returnValue($user));
- $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
->will($this->returnValue('newFoo'))
@@ -214,7 +214,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials()
{
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$user->expects($this->once())
->method('getPassword')
->will($this->returnValue('foo'))
@@ -225,7 +225,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('getUser')
->will($this->returnValue($user));
- $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
->will($this->returnValue('foo'))
@@ -239,7 +239,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testCheckAuthentication()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
->will($this->returnValue(true))
@@ -255,12 +255,12 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token);
+ $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
}
protected function getSupportedToken()
{
- $mock = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', array('getCredentials', 'getUser', 'getProviderKey'), array(), '', false);
+ $mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(array('getCredentials', 'getUser', 'getProviderKey'))->disableOriginalConstructor()->getMock();
$mock
->expects($this->any())
->method('getProviderKey')
@@ -272,7 +272,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null)
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -281,14 +281,14 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
}
if (null === $userChecker) {
- $userChecker = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock();
}
if (null === $passwordEncoder) {
$passwordEncoder = new PlaintextPasswordEncoder();
}
- $encoderFactory = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface');
+ $encoderFactory = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock();
$encoderFactory
->expects($this->any())
->method('getEncoder')
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
index 5fd7b05ef0..27d8566e68 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
@@ -21,7 +21,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
$provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken()));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')
->disableOriginalConstructor()
@@ -39,7 +39,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
{
$provider = $this->getProvider();
- $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
/**
@@ -53,7 +53,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
public function testAuthenticate()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getRoles')
@@ -75,9 +75,9 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
*/
public function testAuthenticateWhenUserCheckerThrowsException()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPostAuth')
->will($this->throwException(new LockedException()))
@@ -90,7 +90,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
protected function getSupportedToken($user = false, $credentials = false)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', array('getUser', 'getCredentials', 'getProviderKey'), array(), '', false);
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')->setMethods(array('getUser', 'getCredentials', 'getProviderKey'))->disableOriginalConstructor()->getMock();
if (false !== $user) {
$token->expects($this->once())
->method('getUser')
@@ -117,7 +117,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
protected function getProvider($user = null, $userChecker = null)
{
- $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -126,7 +126,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
}
if (null === $userChecker) {
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
}
return new PreAuthenticatedAuthenticationProvider($userProvider, $userChecker, 'key');
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
index 05030543e6..0a78ee8c77 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -25,14 +25,14 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken()));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();
- $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
/**
@@ -82,7 +82,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testAuthenticateWhenPreChecksFails()
{
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPreAuth')
->will($this->throwException(new CredentialsExpiredException()))
@@ -91,7 +91,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->authenticate($this->getSupportedToken());
@@ -102,7 +102,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testAuthenticateWhenPostChecksFails()
{
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPostAuth')
->will($this->throwException(new AccountExpiredException()))
@@ -111,7 +111,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->authenticate($this->getSupportedToken());
@@ -126,7 +126,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -145,7 +145,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -157,7 +157,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testAuthenticate()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())
->method('getRoles')
->will($this->returnValue(array('ROLE_FOO')))
@@ -191,7 +191,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testAuthenticateWithPreservingRoleSwitchUserRole()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())
->method('getRoles')
->will($this->returnValue(array('ROLE_FOO')))
@@ -209,7 +209,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $switchUserRole = new SwitchUserRole('foo', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$token->expects($this->once())
->method('getRoles')
->will($this->returnValue(array($switchUserRole)))
@@ -227,7 +227,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getSupportedToken()
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', array('getCredentials', 'getProviderKey', 'getRoles'), array(), '', false);
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')->setMethods(array('getCredentials', 'getProviderKey', 'getRoles'))->disableOriginalConstructor()->getMock();
$mock
->expects($this->any())
->method('getProviderKey')
@@ -242,7 +242,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getProvider($userChecker = false, $hide = true)
{
if (false === $userChecker) {
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
}
return $this->getMockForAbstractClass('Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider', array($userChecker, 'key', $hide));
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
index 1a786d7c45..896ea37f1e 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
@@ -68,7 +68,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$token->setUser(new TestUser('fabien'));
$this->assertEquals('fabien', $token->getUsername());
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien'));
$token->setUser($user);
$this->assertEquals('fabien', $token->getUsername());
@@ -78,7 +78,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
{
$token = $this->getToken(array('ROLE_FOO'));
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())->method('eraseCredentials');
$token->setUser($user);
@@ -168,8 +168,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
public function getUsers()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
return array(
array($advancedUser),
@@ -197,8 +197,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
public function getUserChanges()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
return array(
array(
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
index b83de4a984..882f222476 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
@@ -54,7 +54,7 @@ class RememberMeTokenTest extends \PHPUnit_Framework_TestCase
protected function getUser($roles = array('ROLE_FOO'))
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getRoles')
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
index d06e3f03c6..a3bcc96fdf 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
@@ -19,7 +19,7 @@ class TokenStorageTest extends \PHPUnit_Framework_TestCase
{
$tokenStorage = new TokenStorage();
$this->assertNull($tokenStorage->getToken());
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->setToken($token);
$this->assertSame($token, $tokenStorage->getToken());
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
index 412af91c4f..94b9820288 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -65,7 +65,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
$this->assertSame($expected, $manager->decide($token, array('ROLE_FOO')));
@@ -83,7 +83,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
public function getStrategiesWith2RolesTests()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false),
@@ -101,7 +101,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterFor2Roles($token, $vote1, $vote2)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValueMap(array(
@@ -166,7 +166,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoter($vote)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValue($vote));
@@ -176,7 +176,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterSupportsClass($ret)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('supportsClass')
->will($this->returnValue($ret));
@@ -186,7 +186,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterSupportsAttribute($ret)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('supportsAttribute')
->will($this->returnValue($ret));
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
index aafc12fd90..eed361cbad 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
@@ -23,8 +23,8 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
+ $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
$this->tokenStorage = new TokenStorage();
$this->authorizationChecker = new AuthorizationChecker(
@@ -36,10 +36,10 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
public function testVoteAuthenticatesTokenIfNecessary()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->tokenStorage->setToken($token);
- $newToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $newToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->authenticationManager
->expects($this->once())
@@ -78,7 +78,7 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
*/
public function testIsGranted($decide)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('isAuthenticated')
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php
index 69cfba34bb..558d4af0de 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AbstractVoterTest.php
@@ -25,7 +25,7 @@ class AbstractVoterTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
/**
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
index 4679c0ff0e..a59848c79b 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
@@ -68,11 +68,11 @@ class AuthenticatedVoterTest extends \PHPUnit_Framework_TestCase
protected function getToken($authenticated)
{
if ('fully' === $authenticated) {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
} elseif ('remembered' === $authenticated) {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock();
} else {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', ''));
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock();
}
}
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
index dc8ea7960e..07700396bf 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
@@ -20,7 +20,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
public function testSupportsAttribute()
{
$expression = $this->createExpression();
- $expressionLanguage = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage');
+ $expressionLanguage = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock();
$voter = new ExpressionVoter($expressionLanguage, $this->createTrustResolver(), $this->createRoleHierarchy());
$this->assertTrue($voter->supportsAttribute($expression));
@@ -54,7 +54,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
foreach ($roles as $i => $role) {
$roles[$i] = new Role($role);
}
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
if ($tokenExpectsGetRoles) {
$token->expects($this->once())
@@ -67,7 +67,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock();
if ($expressionLanguageExpectsEvaluate) {
$mock->expects($this->once())
@@ -80,12 +80,12 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createTrustResolver()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
}
protected function createRoleHierarchy()
{
- return $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock();
}
protected function createExpression()
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
index c15e936f6e..ce4f4cf4fb 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php
@@ -57,7 +57,7 @@ class RoleVoterTest extends \PHPUnit_Framework_TestCase
foreach ($roles as $i => $role) {
$roles[$i] = new Role($role);
}
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->once())
->method('getRoles')
->will($this->returnValue($roles));
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
index 21aaae4fb4..191a4d8770 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
@@ -26,7 +26,7 @@ class EncoderFactoryTest extends \PHPUnit_Framework_TestCase
'arguments' => array('sha512', true, 5),
)));
- $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$expectedEncoder = new MessageDigestPasswordEncoder('sha512', true, 5);
$this->assertEquals($expectedEncoder->encodePassword('foo', 'moo'), $encoder->encodePassword('foo', 'moo'));
@@ -38,7 +38,7 @@ class EncoderFactoryTest extends \PHPUnit_Framework_TestCase
'Symfony\Component\Security\Core\User\UserInterface' => new MessageDigestPasswordEncoder('sha1'),
));
- $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$expectedEncoder = new MessageDigestPasswordEncoder('sha1');
$this->assertEquals($expectedEncoder->encodePassword('foo', ''), $encoder->encodePassword('foo', ''));
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
index 590652da04..e8adb9b33d 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php
@@ -17,18 +17,18 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
{
public function testEncodePassword()
{
- $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
->will($this->returnValue('userSalt'));
- $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('encodePassword')
->with($this->equalTo('plainPassword'), $this->equalTo('userSalt'))
->will($this->returnValue('encodedPassword'));
- $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
@@ -42,7 +42,7 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testIsPasswordValid()
{
- $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
->will($this->returnValue('userSalt'));
@@ -50,13 +50,13 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
->method('getPassword')
->will($this->returnValue('encodedPassword'));
- $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('isPasswordValid')
->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt'))
->will($this->returnValue(true));
- $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
diff --git a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
index 45022618b0..0c9cc51b5b 100644
--- a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
@@ -26,14 +26,14 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $this->authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
+ $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $this->authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
$this->securityContext = new SecurityContext($this->tokenStorage, $this->authorizationChecker);
}
public function testGetTokenDelegation()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->tokenStorage
->expects($this->once())
@@ -45,7 +45,7 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
public function testSetTokenDelegation()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->tokenStorage
->expects($this->once())
@@ -85,8 +85,8 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
*/
public function testOldConstructorSignature()
{
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
+ $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
new SecurityContext($authenticationManager, $accessDecisionManager);
}
@@ -101,10 +101,10 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
public function oldConstructorSignatureFailuresProvider()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
+ $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
return array(
array(new \stdClass(), new \stdClass()),
diff --git a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php
index f0ce468637..fff5ff21f5 100644
--- a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php
@@ -17,14 +17,14 @@ class SwitchUserRoleTest extends \PHPUnit_Framework_TestCase
{
public function testGetSource()
{
- $role = new SwitchUserRole('FOO', $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($token, $role->getSource());
}
public function testGetRole()
{
- $role = new SwitchUserRole('FOO', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $role = new SwitchUserRole('FOO', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('FOO', $role->getRole());
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
index ab01f476eb..dae58ae9ad 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
@@ -173,11 +173,11 @@ class ChainUserProviderTest extends \PHPUnit_Framework_TestCase
protected function getAccount()
{
- return $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
}
protected function getProvider()
{
- return $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
index ac217814ea..4b6e52717e 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
@@ -19,14 +19,14 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $this->assertNull($checker->checkPostAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
+ $this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()));
}
public function testCheckPostAuthPass()
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true));
$this->assertNull($checker->checkPostAuth($account));
@@ -39,7 +39,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false));
$checker->checkPostAuth($account);
@@ -49,14 +49,14 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $this->assertNull($checker->checkPreAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
+ $this->assertNull($checker->checkPreAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()));
}
public function testCheckPreAuthPass()
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
$account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true));
@@ -71,7 +71,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false));
$checker->checkPreAuth($account);
@@ -84,7 +84,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
@@ -98,7 +98,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
$account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false));
diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
index 047c929904..7ebe65c647 100644
--- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
@@ -95,7 +95,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
*/
public function testUserIsNotValid()
{
- $user = $this->getMock('Foo\Bar\User');
+ $user = $this->getMockBuilder('Foo\Bar\User')->getMock();
$this->tokenStorage = $this->createTokenStorage($user);
$this->validator = $this->createValidator();
@@ -106,7 +106,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createUser()
{
- $mock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$mock
->expects($this->any())
@@ -125,12 +125,12 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createPasswordEncoder($isPasswordValid = true)
{
- return $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
}
protected function createEncoderFactory($encoder = null)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mock
->expects($this->any())
@@ -145,7 +145,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
{
$token = $this->createAuthenticationToken($user);
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$mock
->expects($this->any())
->method('getToken')
@@ -157,7 +157,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createAuthenticationToken($user = null)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$mock
->expects($this->any())
->method('getUser')
diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
index 3112038eee..16baec1365 100644
--- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
+++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php
@@ -36,8 +36,8 @@ class CsrfTokenManagerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->generator = $this->getMock('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface');
- $this->storage = $this->getMock('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface');
+ $this->generator = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock();
+ $this->storage = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock();
$this->manager = new CsrfTokenManager($this->generator, $this->storage);
}
diff --git a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
index d8ab7aae90..b71ad8561c 100644
--- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php
@@ -17,7 +17,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase
{
public function testReturnsFirstMatchedPattern()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$requestMatcher1 = $this->getRequestMatcher($request, false);
$requestMatcher2 = $this->getRequestMatcher($request, true);
@@ -30,7 +30,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase
public function testReturnsEmptyPatternIfNoneMatched()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$requestMatcher = $this->getRequestMatcher($request, false);
$map = new AccessMap();
@@ -41,7 +41,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase
private function getRequestMatcher($request, $matches)
{
- $requestMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcherInterface');
+ $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
->method('matches')->with($request)
->will($this->returnValue($matches));
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
index c97ee6926e..cb5fb51c32 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
@@ -27,14 +27,14 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
protected function setUp()
{
- $this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
- $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
- $this->logger = $this->getMock('Psr\Log\LoggerInterface');
+ $this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
+ $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
- $this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
- $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
+ $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
- $this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException', array('getMessage'));
+ $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(array('getMessage'))->getMock();
}
public function testForward()
@@ -181,8 +181,8 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
private function getRequest()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $request->attributes = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
+ $request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock();
return $request;
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
index 537299343c..8b937c5fc5 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
@@ -24,10 +24,10 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas
protected function setUp()
{
- $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
- $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $this->request->headers = $this->getMock('Symfony\Component\HttpFoundation\HeaderBag');
- $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
+ $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
+ $this->request->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\HeaderBag')->getMock();
+ $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
public function testRequestIsRedirected()
@@ -101,7 +101,7 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas
public function testTargetPathIsTakenFromTheSession()
{
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())
->method('get')->with('_security.admin.target_path')
->will($this->returnValue('/admin/dashboard'));
diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
index 8a3188689b..330b21a488 100644
--- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php
@@ -34,11 +34,11 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface');
- $this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
+ $this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock();
+ $this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
- $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
+ $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
// No methods are invoked on the exception; we just assert on its class
$this->authenticationException = new AuthenticationException();
@@ -47,7 +47,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase
public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler()
{
- $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$this->successHandler->expects($this->once())
->method('onAuthenticationSuccess')
@@ -117,7 +117,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase
public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler()
{
- $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$this->failureHandler->expects($this->once())
->method('onAuthenticationFailure')
diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php
index ca5922c8df..359c6de532 100644
--- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php
@@ -18,7 +18,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
{
public function testStart()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$authException = new AuthenticationException('The exception message');
@@ -31,7 +31,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
public function testStartWithoutAuthException()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$entryPoint = new BasicAuthenticationEntryPoint('TheRealmName');
diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php
index 4082986e1c..e9c7f10820 100644
--- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php
@@ -19,7 +19,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
{
public function testStart()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$authenticationException = new AuthenticationException('TheAuthenticationExceptionMessage');
@@ -32,7 +32,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
public function testStartWithNoException()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheSecret');
$response = $entryPoint->start($request);
@@ -43,7 +43,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
public function testStartWithNonceExpiredException()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$nonceExpiredException = new NonceExpiredException('TheNonceExpiredExceptionMessage');
diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
index 75a6be4dfa..0247e5fc4b 100644
--- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php
@@ -19,11 +19,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
{
public function testStart()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$response = new Response();
- $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
- $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
+ $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils
->expects($this->once())
->method('createRedirectResponse')
@@ -38,11 +38,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
public function testStartWithUseForward()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
- $subRequest = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
+ $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$response = new Response('', 200);
- $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
+ $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils
->expects($this->once())
->method('createRequest')
@@ -50,7 +50,7 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($subRequest))
;
- $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$httpKernel
->expects($this->once())
->method('handle')
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
index 61f086a555..fa8a583e0c 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
@@ -24,9 +24,9 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), array());
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -38,7 +38,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo($token))
;
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->once())
->method('authenticate')
@@ -56,7 +56,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->method('getPreAuthenticatedData')
->will($this->returnValue($userCredentials));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -72,7 +72,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), array());
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -84,7 +84,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
;
$exception = new AuthenticationException('Authentication failed.');
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->once())
->method('authenticate')
@@ -102,7 +102,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->method('getPreAuthenticatedData')
->will($this->returnValue($userCredentials));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -120,7 +120,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), array());
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -132,7 +132,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
;
$exception = new AuthenticationException('Authentication failed.');
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->once())
->method('authenticate')
@@ -150,7 +150,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->method('getPreAuthenticatedData')
->will($this->returnValue($userCredentials));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -168,14 +168,14 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
->will($this->returnValue($token))
;
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->never())
->method('authenticate')
@@ -191,7 +191,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->method('getPreAuthenticatedData')
->will($this->returnValue($userCredentials));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -209,7 +209,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -222,7 +222,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
;
$exception = new AuthenticationException('Authentication failed.');
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->once())
->method('authenticate')
@@ -240,7 +240,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
->method('getPreAuthenticatedData')
->will($this->returnValue($userCredentials));
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
index af9d565462..7f8eceaadd 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
@@ -20,9 +20,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -30,21 +30,21 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array('foo' => 'bar'), null)))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->any())
->method('isAuthenticated')
->will($this->returnValue(true))
;
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
->will($this->returnValue($token))
;
- $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
$accessDecisionManager
->expects($this->once())
->method('decide')
@@ -56,10 +56,10 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
$tokenStorage,
$accessDecisionManager,
$accessMap,
- $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -71,9 +71,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleWhenTheTokenIsNotAuthenticated()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -81,21 +81,21 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array('foo' => 'bar'), null)))
;
- $notAuthenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$notAuthenticatedToken
->expects($this->any())
->method('isAuthenticated')
->will($this->returnValue(false))
;
- $authenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$authenticatedToken
->expects($this->any())
->method('isAuthenticated')
->will($this->returnValue(true))
;
- $authManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authManager
->expects($this->once())
->method('authenticate')
@@ -103,7 +103,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($authenticatedToken))
;
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -115,7 +115,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo($authenticatedToken))
;
- $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
$accessDecisionManager
->expects($this->once())
->method('decide')
@@ -130,7 +130,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
$authManager
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -142,9 +142,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -152,13 +152,13 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(null, null)))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->never())
->method('isAuthenticated')
;
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -167,12 +167,12 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
$listener = new AccessListener(
$tokenStorage,
- $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(),
$accessMap,
- $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -187,7 +187,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -196,12 +196,12 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase
$listener = new AccessListener(
$tokenStorage,
- $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
- $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'),
- $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(),
+ $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$listener->handle($event);
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
index 8901cb2d79..62c23f619c 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
@@ -27,9 +27,9 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
'PHP_AUTH_PW' => 'ThePassword',
));
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -41,7 +41,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo($token))
;
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->once())
->method('authenticate')
@@ -53,10 +53,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$tokenStorage,
$authenticationManager,
'TheProviderKey',
- $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -73,9 +73,9 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
'PHP_AUTH_PW' => 'ThePassword',
));
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -88,7 +88,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$response = new Response();
- $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$authenticationEntryPoint
->expects($this->any())
->method('start')
@@ -98,12 +98,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$listener = new BasicAuthenticationListener(
$tokenStorage,
- new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))),
+ new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())),
'TheProviderKey',
$authenticationEntryPoint
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -122,7 +122,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request();
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->never())
->method('getToken')
@@ -130,12 +130,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$listener = new BasicAuthenticationListener(
$tokenStorage,
- $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(),
'TheProviderKey',
- $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -151,14 +151,14 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$token = new UsernamePasswordToken('TheUsername', 'ThePassword', 'TheProviderKey', array('ROLE_FOO'));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
->will($this->returnValue($token))
;
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$authenticationManager
->expects($this->never())
->method('authenticate')
@@ -168,10 +168,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$tokenStorage,
$authenticationManager,
'TheProviderKey',
- $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock()
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -188,10 +188,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testItRequiresProviderKey()
{
new BasicAuthenticationListener(
- $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
- $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(),
'',
- $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')
+ $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock()
);
}
@@ -204,7 +204,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
->method('getToken')
@@ -217,7 +217,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$response = new Response();
- $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$authenticationEntryPoint
->expects($this->any())
->method('start')
@@ -227,12 +227,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$listener = new BasicAuthenticationListener(
$tokenStorage,
- new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))),
+ new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())),
'TheProviderKey',
$authenticationEntryPoint
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
index 1465224e78..ae6c39f3b9 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php
@@ -18,14 +18,14 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
{
public function testHandleWithNotSecuredRequestAndHttpChannel()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$request
->expects($this->any())
->method('isSecure')
->will($this->returnValue(false))
;
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -33,13 +33,13 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array(), 'http')))
;
- $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint
->expects($this->never())
->method('start')
;
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -56,14 +56,14 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleWithSecuredRequestAndHttpsChannel()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$request
->expects($this->any())
->method('isSecure')
->will($this->returnValue(true))
;
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -71,13 +71,13 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array(), 'https')))
;
- $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint
->expects($this->never())
->method('start')
;
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -94,7 +94,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleWithNotSecuredRequestAndHttpsChannel()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$request
->expects($this->any())
->method('isSecure')
@@ -103,7 +103,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
$response = new Response();
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -111,7 +111,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array(), 'https')))
;
- $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint
->expects($this->once())
->method('start')
@@ -119,7 +119,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($response))
;
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
@@ -137,7 +137,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleWithSecuredRequestAndHttpChannel()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$request
->expects($this->any())
->method('isSecure')
@@ -146,7 +146,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
$response = new Response();
- $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
+ $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
$accessMap
->expects($this->any())
->method('getPatterns')
@@ -154,7 +154,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array(), 'http')))
;
- $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint
->expects($this->once())
->method('start')
@@ -162,7 +162,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($response))
;
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
index ae1199ac3c..5453b317de 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
@@ -32,7 +32,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
public function testItRequiresContextKey()
{
new ContextListener(
- $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
array(),
''
);
@@ -45,7 +45,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
public function testUserProvidersNeedToImplementAnInterface()
{
new ContextListener(
- $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
array(new \stdClass()),
'key123'
);
@@ -94,7 +94,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$request->setSession($session);
$event = new FilterResponseEvent(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
$request,
HttpKernelInterface::MASTER_REQUEST,
new Response()
@@ -113,7 +113,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$request->setSession($session);
$event = new FilterResponseEvent(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
$request,
HttpKernelInterface::MASTER_REQUEST,
new Response()
@@ -130,12 +130,12 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidTokenInSession($token)
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
->disableOriginalConstructor()
->getMock();
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$event->expects($this->any())
->method('getRequest')
@@ -169,8 +169,8 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleAddsKernelResponseListener()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
->disableOriginalConstructor()
->getMock();
@@ -182,7 +182,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true));
$event->expects($this->any())
->method('getRequest')
- ->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Request')));
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock()));
$dispatcher->expects($this->once())
->method('addListener')
@@ -193,15 +193,15 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
public function testOnKernelResponseListenerRemovesItself()
{
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
->disableOriginalConstructor()
->getMock();
$listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher);
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->expects($this->any())
->method('hasSession')
->will($this->returnValue(true));
@@ -222,7 +222,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleRemovesTokenIfNoPreviousSessionWasFound()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false));
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
@@ -230,7 +230,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
->getMock();
$event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage->expects($this->once())->method('setToken')->with(null);
$listener = new ContextListener($tokenStorage, array(), 'key123');
@@ -253,7 +253,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
$request->cookies->set('MOCKSESSID', true);
$event = new FilterResponseEvent(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
$request,
HttpKernelInterface::MASTER_REQUEST,
new Response()
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
index 3d409e5457..b372447d8b 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
@@ -84,12 +84,12 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null)
{
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('error')));
$event = $this->createEvent($exception, $kernel);
- $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
+ $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error')));
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error');
@@ -106,7 +106,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
{
$event = $this->createEvent($exception);
- $accessDeniedHandler = $this->getMock('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface');
+ $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock();
$accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error')));
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler);
@@ -123,8 +123,8 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
{
$event = $this->createEvent($exception);
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
$listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint());
$listener->onKernelException($event);
@@ -146,7 +146,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
private function createEntryPoint()
{
- $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
+ $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint->expects($this->once())->method('start')->will($this->returnValue(new Response('OK')));
return $entryPoint;
@@ -154,7 +154,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
private function createTrustResolver($fullFledged)
{
- $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface');
+ $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
$trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged));
return $trustResolver;
@@ -163,7 +163,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
private function createEvent(\Exception $exception, $kernel = null)
{
if (null === $kernel) {
- $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
}
return new GetResponseForExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception);
@@ -172,9 +172,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null)
{
return new ExceptionListener(
- $tokenStorage ?: $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
- $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'),
- $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'),
+ $tokenStorage ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
+ $trustResolver ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(),
+ $httpUtils ?: $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(),
'key',
$authenticationEntryPoint,
$errorPage,
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
index 367c810f51..8f6db59d41 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
@@ -172,12 +172,12 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
private function getTokenManager()
{
- return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
}
private function getTokenStorage()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
}
private function getGetResponseEvent()
@@ -195,7 +195,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
private function getHandler()
{
- return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface')->getMock();
}
private function getHttpUtils()
@@ -225,11 +225,11 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase
private function getSuccessHandler()
{
- return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface')->getMock();
}
private function getToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
index cd2f1b8735..141b4cc2ad 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -25,7 +25,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$tokenStorage
->expects($this->once())
->method('getToken')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
;
$tokenStorage
@@ -75,7 +75,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
;
$service
@@ -117,7 +117,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$service
->expects($this->once())
->method('autoLogin')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
;
$service
@@ -152,7 +152,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(null))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
@@ -191,7 +191,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(null))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
@@ -210,14 +210,14 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($token))
;
- $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session
->expects($this->once())
->method('isStarted')
->will($this->returnValue(true))
;
- $request = $this->getMock('\Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock();
$request
->expects($this->once())
->method('hasSession')
@@ -256,7 +256,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(null))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
@@ -275,7 +275,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($token))
;
- $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session
->expects($this->once())
->method('isStarted')
@@ -286,7 +286,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->method('migrate')
;
- $request = $this->getMock('\Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock();
$request
->expects($this->any())
->method('hasSession')
@@ -319,7 +319,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(null))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service
->expects($this->once())
->method('autoLogin')
@@ -360,12 +360,12 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
protected function getGetResponseEvent()
{
- return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
}
protected function getFilterResponseEvent()
{
- return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')->disableOriginalConstructor()->getMock();
}
protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false)
@@ -385,31 +385,31 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
protected function getLogger()
{
- return $this->getMock('Psr\Log\LoggerInterface');
+ return $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
}
protected function getManager()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
}
protected function getService()
{
- return $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock();
}
protected function getTokenStorage()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
}
protected function getDispatcher()
{
- return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ return $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
}
private function getSessionStrategy()
{
- return $this->getMock('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface');
+ return $this->getMockBuilder('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
index dad7aadcdc..985152c770 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
@@ -24,9 +24,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), $serverVars);
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new RemoteUserAuthenticationListener(
$tokenStorage,
@@ -48,9 +48,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request(array(), array(), array(), array(), array(), array());
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new RemoteUserAuthenticationListener(
$tokenStorage,
@@ -71,9 +71,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), array(
'TheUserKey' => 'TheUser',
));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new RemoteUserAuthenticationListener(
$tokenStorage,
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
index 28d73e0c3b..b80f8c608f 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
@@ -31,13 +31,13 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
- $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
- $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
- $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $this->request->query = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
- $this->request->server = $this->getMock('Symfony\Component\HttpFoundation\ServerBag');
+ $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
+ $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
+ $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
+ $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
+ $this->request->query = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock();
+ $this->request->server = $this->getMockBuilder('Symfony\Component\HttpFoundation\ServerBag')->getMock();
$this->event = $this->getEvent($this->request);
}
@@ -66,7 +66,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound()
{
- $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
+ $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock()));
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('_exit'));
@@ -104,8 +104,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
public function testExitUserDispatchesEventWithRefreshedUser()
{
- $originalUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $refreshedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $originalUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $refreshedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$this
->userProvider
->expects($this->any())
@@ -145,7 +145,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
->method('all')
->will($this->returnValue(array()));
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher
->expects($this->once())
->method('dispatch')
@@ -201,7 +201,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
->method('getUri')
->willReturn('/');
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher
->expects($this->never())
->method('dispatch')
@@ -216,7 +216,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testSwitchUserIsDisallowed()
{
- $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
+ $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock()));
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
@@ -231,8 +231,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
public function testSwitchUser()
{
- $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock()));
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
@@ -261,8 +261,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
public function testSwitchUserKeepsOtherQueryStringParameters()
{
- $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock()));
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
@@ -303,7 +303,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
private function getToken(array $roles = array())
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token->expects($this->any())
->method('getRoles')
->will($this->returnValue($roles));
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
index 66690d9710..3e58e69e08 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
@@ -31,9 +31,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), $serverVars);
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
@@ -60,9 +60,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
$request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
@@ -88,9 +88,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request(array(), array(), array(), array(), array(), array());
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey');
@@ -108,9 +108,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
'TheUserKey' => 'TheUser',
'TheCredentialsKey' => 'TheCredentials',
));
- $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
- $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+ $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
$listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey');
diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
index 85a57ab82c..016c72df45 100644
--- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php
@@ -22,7 +22,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
$request = new Request();
- $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$notMatchingMatcher
->expects($this->once())
->method('matches')
@@ -30,27 +30,27 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(false))
;
- $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface')));
+ $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()));
- $matchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $matchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$matchingMatcher
->expects($this->once())
->method('matches')
->with($this->equalTo($request))
->will($this->returnValue(true))
;
- $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
- $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false);
+ $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
+ $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock();
$map->add($matchingMatcher, array($theListener), $theException);
- $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$tooLateMatcher
->expects($this->never())
->method('matches')
;
- $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface')));
+ $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()));
list($listeners, $exception) = $map->getListeners($request);
@@ -64,7 +64,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
$request = new Request();
- $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$notMatchingMatcher
->expects($this->once())
->method('matches')
@@ -72,20 +72,20 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(false))
;
- $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface')));
+ $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()));
- $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
- $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false);
+ $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
+ $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock();
$map->add(null, array($theListener), $theException);
- $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$tooLateMatcher
->expects($this->never())
->method('matches')
;
- $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface')));
+ $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()));
list($listeners, $exception) = $map->getListeners($request);
@@ -99,7 +99,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
$request = new Request();
- $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher');
+ $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock();
$notMatchingMatcher
->expects($this->once())
->method('matches')
@@ -107,7 +107,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(false))
;
- $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface')));
+ $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()));
list($listeners, $exception) = $map->getListeners($request);
diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
index 1e0c1ef0dd..20da3ae31a 100644
--- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php
@@ -20,18 +20,18 @@ class FirewallTest extends \PHPUnit_Framework_TestCase
{
public function testOnKernelRequestRegistersExceptionListener()
{
- $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
- $listener = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false);
+ $listener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock();
$listener
->expects($this->once())
->method('register')
->with($this->equalTo($dispatcher))
;
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
- $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface');
+ $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock();
$map
->expects($this->once())
->method('getListeners')
@@ -39,7 +39,7 @@ class FirewallTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(array(array(), $listener)))
;
- $event = new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
$firewall = new Firewall($map, $dispatcher);
$firewall->onKernelRequest($event);
@@ -49,59 +49,59 @@ class FirewallTest extends \PHPUnit_Framework_TestCase
{
$response = new Response();
- $first = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
+ $first = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
$first
->expects($this->once())
->method('handle')
;
- $second = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface');
+ $second = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
$second
->expects($this->never())
->method('handle')
;
- $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface');
+ $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock();
$map
->expects($this->once())
->method('getListeners')
->will($this->returnValue(array(array($first, $second), null)))
;
- $event = $this->getMock(
- 'Symfony\Component\HttpKernel\Event\GetResponseEvent',
- array('hasResponse'),
- array(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
- $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false),
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
+ ->setMethods(array('hasResponse'))
+ ->setConstructorArgs(array(
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
+ $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(),
HttpKernelInterface::MASTER_REQUEST,
- )
- );
+ ))
+ ->getMock()
+ ;
$event
->expects($this->once())
->method('hasResponse')
->will($this->returnValue(true))
;
- $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'));
+ $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock());
$firewall->onKernelRequest($event);
}
public function testOnKernelRequestWithSubRequest()
{
- $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface');
+ $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock();
$map
->expects($this->never())
->method('getListeners')
;
$event = new GetResponseEvent(
- $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
- $this->getMock('Symfony\Component\HttpFoundation\Request'),
+ $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(),
+ $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(),
HttpKernelInterface::SUB_REQUEST
);
- $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'));
+ $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock());
$firewall->onKernelRequest($event);
$this->assertFalse($event->hasResponse());
diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
index 45a0281591..bb432a0c52 100644
--- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
@@ -39,7 +39,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCreateRedirectResponseWithRouteName()
{
- $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'));
+ $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock());
$urlGenerator
->expects($this->any())
@@ -50,7 +50,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
$urlGenerator
->expects($this->any())
->method('getContext')
- ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()))
;
$response = $utils->createRedirectResponse($this->getRequest(), 'foobar');
@@ -73,7 +73,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCreateRequestWithRouteName()
{
- $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'));
+ $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock());
$urlGenerator
->expects($this->once())
@@ -83,7 +83,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
$urlGenerator
->expects($this->any())
->method('getContext')
- ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()))
;
$subRequest = $utils->createRequest($this->getRequest(), 'foobar');
@@ -93,7 +93,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCreateRequestWithAbsoluteUrl()
{
- $utils = new HttpUtils($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'));
+ $utils = new HttpUtils($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock());
$subRequest = $utils->createRequest($this->getRequest(), 'http://symfony.com/');
$this->assertEquals('/', $subRequest->getPathInfo());
@@ -102,7 +102,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCreateRequestPassesSessionToTheNewRequest()
{
$request = $this->getRequest();
- $request->setSession($session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
+ $request->setSession($session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
$utils = new HttpUtils($this->getUrlGenerator());
$subRequest = $utils->createRequest($request, '/foobar');
@@ -148,7 +148,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCheckRequestPathWithUrlMatcherAndResourceNotFound()
{
- $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
+ $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('match')
@@ -163,7 +163,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCheckRequestPathWithUrlMatcherAndMethodNotAllowed()
{
$request = $this->getRequest();
- $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('matchRequest')
@@ -177,7 +177,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl()
{
- $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
+ $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('match')
@@ -192,7 +192,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest()
{
$request = $this->getRequest();
- $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
+ $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('matchRequest')
@@ -209,7 +209,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckRequestPathWithUrlMatcherLoadingException()
{
- $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface');
+ $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('match')
@@ -250,7 +250,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
private function getUrlGenerator($generatedUrl = '/foo/bar')
{
- $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
+ $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
$urlGenerator
->expects($this->any())
->method('generate')
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php
index 84745040c8..300f28dc6a 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php
@@ -22,7 +22,7 @@ class CookieClearingLogoutHandlerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$handler = new CookieClearingLogoutHandler(array('foo' => array('path' => '/foo', 'domain' => 'foo.foo'), 'foo2' => array('path' => null, 'domain' => null)));
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
index 8a94e5332d..7f20f67b2b 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php
@@ -18,10 +18,10 @@ class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testLogout()
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$response = new Response();
- $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
+ $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils->expects($this->once())
->method('createRedirectResponse')
->with($request, '/dashboard')
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
index c3429951fc..6a435d74ba 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php
@@ -20,9 +20,9 @@ class SessionLogoutHandlerTest extends \PHPUnit_Framework_TestCase
{
$handler = new SessionLogoutHandler();
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$response = new Response();
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session', array(), array(), '', false);
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
$request
->expects($this->once())
@@ -35,6 +35,6 @@ class SessionLogoutHandlerTest extends \PHPUnit_Framework_TestCase
->method('invalidate')
;
- $handler->logout($request, $response, $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $handler->logout($request, $response, $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
}
}
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
index 7495398ec2..84d11e78f4 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
@@ -62,7 +62,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$request->cookies->set('foo', 'foo');
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getRoles')
@@ -90,7 +90,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, $options);
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service->logout($request, $response, $token);
$cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie);
@@ -125,8 +125,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request();
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -148,8 +148,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null));
$request = new Request();
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -172,8 +172,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request();
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -199,8 +199,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$request->request->set('foo', array('bar' => $value));
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -226,8 +226,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$request->request->set('foo', $value);
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -290,7 +290,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
protected function getProvider()
{
- $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$provider
->expects($this->any())
->method('supportsClass')
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
index 30cf4a231b..6628b5bb5c 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
@@ -60,7 +60,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$tokenValue = 'foovalue',
)));
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
@@ -79,7 +79,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
@@ -104,7 +104,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$service->setTokenProvider($tokenProvider);
$tokenProvider
@@ -135,7 +135,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
@@ -150,7 +150,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
public function testAutoLogin()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getRoles')
@@ -169,7 +169,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('loadTokenBySeries')
@@ -192,9 +192,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue')));
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('deleteTokenBySeries')
@@ -218,9 +218,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null));
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->never())
->method('deleteTokenBySeries')
@@ -241,9 +241,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$request->cookies->set('foo', 'somefoovalue');
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->never())
->method('deleteTokenBySeries')
@@ -271,20 +271,20 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$request = new Request();
$response = new Response();
- $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$account
->expects($this->once())
->method('getUsername')
->will($this->returnValue('foo'))
;
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->any())
->method('getUser')
->will($this->returnValue($account))
;
- $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface');
+ $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
$tokenProvider
->expects($this->once())
->method('createNewToken')
@@ -326,7 +326,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
protected function getProvider()
{
- $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$provider
->expects($this->any())
->method('supportsClass')
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
index 23f7df70d3..0db86e7433 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php
@@ -83,7 +83,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
private function getResponse()
{
$response = new Response();
- $response->headers = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag');
+ $response->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->getMock();
return $response;
}
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
index ee8a99e3da..ce1048e3ea 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
@@ -62,7 +62,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash'));
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getPassword')
@@ -87,7 +87,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass'));
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getPassword')
@@ -112,7 +112,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
*/
public function testAutoLogin($username)
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getRoles')
@@ -156,7 +156,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'secure' => true, 'httponly' => false));
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$service->logout($request, $response, $token);
@@ -186,7 +186,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null));
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
->method('getUser')
@@ -208,8 +208,8 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request();
$response = new Response();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->once())
->method('getPassword')
@@ -272,7 +272,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
protected function getProvider()
{
- $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$provider
->expects($this->any())
->method('supportsClass')
diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
index 4aef4b203b..c23821a4ce 100644
--- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
@@ -43,7 +43,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('We cannot destroy the old session on PHP 5.4.0 - 5.4.10.');
}
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())->method('migrate')->with($this->equalTo(true));
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
@@ -56,7 +56,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('This PHP version is not affected.');
}
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())->method('migrate')->with($this->equalTo(false));
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
@@ -65,7 +65,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
public function testSessionIsInvalidated()
{
- $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
+ $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())->method('invalidate');
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE);
@@ -74,7 +74,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
private function getRequest($session = null)
{
- $request = $this->getMock('Symfony\Component\HttpFoundation\Request');
+ $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
if (null !== $session) {
$request->expects($this->any())->method('getSession')->will($this->returnValue($session));
@@ -85,6 +85,6 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
private function getToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
index b7c6ab9db5..3e65b09b7d 100644
--- a/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
@@ -24,16 +24,16 @@ class UsernamePasswordFormAuthenticationListenerTest extends \PHPUnit_Framework_
public function testHandleWhenUsernameLength($username, $ok)
{
$request = Request::create('/login_check', 'POST', array('_username' => $username));
- $request->setSession($this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
+ $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
- $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
+ $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils
->expects($this->any())
->method('checkRequestPath')
->will($this->returnValue(true))
;
- $failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
+ $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
$failureHandler
->expects($ok ? $this->never() : $this->once())
->method('onAuthenticationFailure')
@@ -48,17 +48,17 @@ class UsernamePasswordFormAuthenticationListenerTest extends \PHPUnit_Framework_
;
$listener = new UsernamePasswordFormAuthenticationListener(
- $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock(),
$authenticationManager,
- $this->getMock('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
$httpUtils,
'TheProviderKey',
- $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'),
+ $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
$failureHandler,
array('require_previous_session' => false)
);
- $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')
diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php
index 629c17b788..9ce3d020bc 100644
--- a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php
@@ -28,10 +28,10 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
{
$classMetadata = new ClassMetadata('c');
- $a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a1->method('getName')->willReturn('a1');
- $a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a2->method('getName')->willReturn('a2');
$classMetadata->addAttributeMetadata($a1);
@@ -45,11 +45,11 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
$classMetadata1 = new ClassMetadata('c1');
$classMetadata2 = new ClassMetadata('c2');
- $ac1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $ac1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$ac1->method('getName')->willReturn('a1');
$ac1->method('getGroups')->willReturn(array('a', 'b'));
- $ac2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $ac2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$ac2->method('getName')->willReturn('a1');
$ac2->method('getGroups')->willReturn(array('b', 'c'));
@@ -67,10 +67,10 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
{
$classMetadata = new ClassMetadata('a');
- $a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a1->method('getName')->willReturn('b1');
- $a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
+ $a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a2->method('getName')->willReturn('b2');
$classMetadata->addAttributeMetadata($a1);
diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php
index 2e2ba22dce..331aa3a25e 100644
--- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php
@@ -47,7 +47,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testCacheExists()
{
- $cache = $this->getMock('Doctrine\Common\Cache\Cache');
+ $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$cache
->expects($this->once())
->method('fetch')
@@ -60,7 +60,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testCacheNotExists()
{
- $cache = $this->getMock('Doctrine\Common\Cache\Cache');
+ $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$cache
->method('fetch')
->will($this->returnValue(false))
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
index 66ac992350..6f550369f6 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
@@ -29,8 +29,8 @@ class AbstractNormalizerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $loader = $this->getMock('Symfony\Component\Serializer\Mapping\Loader\LoaderChain', array(), array(array()));
- $this->classMetadata = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory', array(), array($loader));
+ $loader = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Loader\LoaderChain')->setConstructorArgs(array(array()))->getMock();
+ $this->classMetadata = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory')->setConstructorArgs(array($loader))->getMock();
$this->normalizer = new AbstractNormalizerDummy($this->classMetadata);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
index 9b0f0df1bd..f449bf430e 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
@@ -36,7 +36,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->serializer = $this->getMock(__NAMESPACE__.'\SerializerNormalizer');
+ $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\SerializerNormalizer')->getMock();
$this->normalizer = new GetSetMethodNormalizer();
$this->normalizer->setSerializer($this->serializer);
}
@@ -470,7 +470,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testUnableToNormalizeObjectAttribute()
{
- $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
+ $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
$obj = new GetSetDummy();
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
index 2bb98cf365..8dc48c93e8 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
@@ -39,7 +39,7 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->serializer = $this->getMock(__NAMESPACE__.'\ObjectSerializerNormalizer');
+ $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\ObjectSerializerNormalizer')->getMock();
$this->normalizer = new ObjectNormalizer();
$this->normalizer->setSerializer($this->serializer);
}
@@ -416,7 +416,7 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testUnableToNormalizeObjectAttribute()
{
- $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
+ $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
$obj = new ObjectDummy();
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
index a2d1a063d3..a0402c5a34 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
@@ -35,7 +35,7 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
+ $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer = new PropertyNormalizer();
$this->normalizer->setSerializer($this->serializer);
}
@@ -423,7 +423,7 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testUnableToNormalizeObjectAttribute()
{
- $serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
+ $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
$obj = new PropertyDummy();
diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
index 0a6bbe51bd..686c573592 100644
--- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
@@ -41,7 +41,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
*/
public function testNormalizeNoMatch()
{
- $serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
+ $serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()));
$serializer->normalize(new \stdClass(), 'xml');
}
@@ -73,7 +73,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
*/
public function testDenormalizeNoMatch()
{
- $serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
+ $serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()));
$serializer->denormalize('foo', 'stdClass');
}
@@ -98,14 +98,14 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testNormalizeWithSupportOnData()
{
- $normalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
+ $normalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock();
$normalizer1->method('supportsNormalization')
->willReturnCallback(function ($data, $format) {
return isset($data->test);
});
$normalizer1->method('normalize')->willReturn('test1');
- $normalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
+ $normalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock();
$normalizer2->method('supportsNormalization')
->willReturn(true);
$normalizer2->method('normalize')->willReturn('test2');
@@ -121,14 +121,14 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testDenormalizeWithSupportOnData()
{
- $denormalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
+ $denormalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock();
$denormalizer1->method('supportsDenormalization')
->willReturnCallback(function ($data, $type, $format) {
return isset($data['test1']);
});
$denormalizer1->method('denormalize')->willReturn('test1');
- $denormalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
+ $denormalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock();
$denormalizer2->method('supportsDenormalization')
->willReturn(true);
$denormalizer2->method('denormalize')->willReturn('test2');
diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
index e9cb5fc472..bf82ed51fc 100644
--- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
@@ -126,7 +126,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getEngineMock($template, $supports)
{
- $engine = $this->getMock('Symfony\Component\Templating\EngineInterface');
+ $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
diff --git a/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php
index 890a942208..b6d7ce9928 100644
--- a/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php
+++ b/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php
@@ -22,7 +22,7 @@ class LegacyCoreAssetsHelperTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->package = $this->getMock('Symfony\Component\Templating\Asset\PackageInterface');
+ $this->package = $this->getMockBuilder('Symfony\Component\Templating\Asset\PackageInterface')->getMock();
}
protected function tearDown()
diff --git a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
index 01896c2e18..344f3d07cf 100644
--- a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
+++ b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
@@ -34,7 +34,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
$this->assertFalse($loader->load(new TemplateReference('foo', 'php')), '->load() returns false if the embed loader is not able to load the template');
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->once())
->method('debug')
@@ -42,7 +42,7 @@ class CacheLoaderTest extends \PHPUnit_Framework_TestCase
$loader->setLogger($logger);
$loader->load(new TemplateReference('index'));
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->once())
->method('debug')
diff --git a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php
index 939d6753a7..b7e1197960 100644
--- a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php
+++ b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php
@@ -58,7 +58,7 @@ class FilesystemLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\Templating\Storage\FileStorage', $storage, '->load() returns a FileStorage if you pass a relative template that exists');
$this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the absolute path of the template');
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->exactly(2))->method('debug');
$loader = new ProjectTemplateLoader2($pathPattern);
diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
index 87e78508e5..b79dd618f9 100644
--- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
+++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php
@@ -19,7 +19,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testGetSetLogger()
{
$loader = new ProjectTemplateLoader4();
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$loader->setLogger($logger);
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
}
@@ -30,7 +30,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetSetDebugger()
{
$loader = new ProjectTemplateLoader4();
- $debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
+ $debugger = $this->getMockBuilder('Symfony\Component\Templating\DebuggerInterface')->getMock();
$loader->setDebugger($debugger);
$this->assertSame($debugger, $loader->getDebugger(), '->setDebugger() sets the debugger instance');
}
diff --git a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php
index 9f3e849bf4..66e9d587de 100644
--- a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php
+++ b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php
@@ -19,7 +19,7 @@ class LoggingTranslatorTest extends \PHPUnit_Framework_TestCase
{
public function testTransWithNoTranslationIsLogged()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->exactly(2))
->method('warning')
->with('Translation not found.')
@@ -33,7 +33,7 @@ class LoggingTranslatorTest extends \PHPUnit_Framework_TestCase
public function testTransChoiceFallbackIsLogged()
{
- $logger = $this->getMock('Psr\Log\LoggerInterface');
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once())
->method('debug')
->with('Translation use fallback catalogue.')
diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
index e5bb981004..eb18dae0a1 100644
--- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
+++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
@@ -82,10 +82,10 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
public function testAddCatalogue()
{
- $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
- $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
$catalogue = new MessageCatalogue('en', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
@@ -104,13 +104,13 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
public function testAddFallbackCatalogue()
{
- $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
- $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
- $r2 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r2->expects($this->any())->method('__toString')->will($this->returnValue('r2'));
$catalogue = new MessageCatalogue('fr_FR', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
@@ -169,11 +169,11 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
public function testGetAddResource()
{
$catalogue = new MessageCatalogue('en');
- $r = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
$catalogue->addResource($r);
$catalogue->addResource($r);
- $r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
+ $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock();
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
$catalogue->addResource($r1);
diff --git a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php
index f7a8a83d24..041a83679a 100644
--- a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php
+++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php
@@ -19,7 +19,7 @@ class TranslationWriterTest extends \PHPUnit_Framework_TestCase
{
public function testWriteTranslations()
{
- $dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface');
+ $dumper = $this->getMockBuilder('Symfony\Component\Translation\Dumper\DumperInterface')->getMock();
$dumper
->expects($this->once())
->method('dump');
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
index 9d292fbc7b..b68f9eef89 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
@@ -94,9 +94,9 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
protected function createContext()
{
- $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
- $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
- $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+ $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
+ $contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
switch ($this->getApiVersion()) {
case Validation::API_VERSION_2_5:
@@ -111,7 +111,7 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
$context = new LegacyExecutionContext(
$validator,
$this->root,
- $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'),
+ $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock(),
$translator
);
break;
diff --git a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
index f0139c0da5..ebf9696a35 100644
--- a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
+++ b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
@@ -45,9 +45,9 @@ class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$this->violations = new ConstraintViolationList();
- $this->metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
- $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
- $this->globalContext = $this->getMock('Symfony\Component\Validator\GlobalExecutionContextInterface');
+ $this->metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock();
+ $this->metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\MetadataFactoryInterface')->getMock();
+ $this->globalContext = $this->getMockBuilder('Symfony\Component\Validator\GlobalExecutionContextInterface')->getMock();
$this->globalContext->expects($this->any())
->method('getRoot')
->will($this->returnValue('Root'));
@@ -60,7 +60,7 @@ class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
$this->globalContext->expects($this->any())
->method('getMetadataFactory')
->will($this->returnValue($this->metadataFactory));
- $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
+ $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
$this->context = new ExecutionContext($this->globalContext, $this->translator, self::TRANS_DOMAIN, $this->metadata, 'currentValue', 'Group', 'foo.bar');
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
index c1aaa9f8c7..1de7455186 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
@@ -76,7 +76,7 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testWriteMetadataToCache()
{
- $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
+ $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock();
$factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
$parentClassConstraints = array(
@@ -115,8 +115,8 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testReadMetadataFromCache()
{
- $loader = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
- $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
+ $loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
+ $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock();
$factory = new LazyLoadingMetadataFactory($loader, $cache);
$metadata = new ClassMetadata(self::PARENT_CLASS);
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php
index 09e6e449e0..c131f28aea 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php
@@ -43,6 +43,6 @@ class FilesLoaderTest extends \PHPUnit_Framework_TestCase
public function getFileLoader()
{
- return $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ return $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
index 647a568c2c..c0a46cb0fd 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php
@@ -20,12 +20,12 @@ class LoaderChainTest extends \PHPUnit_Framework_TestCase
{
$metadata = new ClassMetadata('\stdClass');
- $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())
->method('loadClassMetadata')
->with($this->equalTo($metadata));
- $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader2->expects($this->once())
->method('loadClassMetadata')
->with($this->equalTo($metadata));
@@ -42,12 +42,12 @@ class LoaderChainTest extends \PHPUnit_Framework_TestCase
{
$metadata = new ClassMetadata('\stdClass');
- $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader1->expects($this->any())
->method('loadClassMetadata')
->will($this->returnValue(true));
- $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader2->expects($this->any())
->method('loadClassMetadata')
->will($this->returnValue(false));
@@ -64,12 +64,12 @@ class LoaderChainTest extends \PHPUnit_Framework_TestCase
{
$metadata = new ClassMetadata('\stdClass');
- $loader1 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader1->expects($this->any())
->method('loadClassMetadata')
->will($this->returnValue(false));
- $loader2 = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
+ $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$loader2->expects($this->any())
->method('loadClassMetadata')
->will($this->returnValue(false));
diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
index 1e6f3403e7..5e97d523bf 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
@@ -550,7 +550,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
{
$entity = new Entity();
- $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata')->getMock();
$metadata->expects($this->any())
->method('getClassName')
->will($this->returnValue(get_class($entity)));
@@ -569,7 +569,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
$entity = new Entity();
$entity->reference = new Reference();
- $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata')->getMock();
$metadata->expects($this->any())
->method('getClassName')
->will($this->returnValue(get_class($entity->reference)));
@@ -590,7 +590,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
$entity = new Entity();
// Legacy interface
- $propertyMetadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
+ $propertyMetadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock();
$metadata = new FakeClassMetadata(get_class($entity));
$metadata->addCustomPropertyMetadata('firstName', $propertyMetadata);
@@ -672,8 +672,8 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
$entity->initialized = false;
// prepare initializers that set "initialized" to true
- $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
- $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
+ $initializer1 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
+ $initializer2 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
$initializer1->expects($this->once())
->method('initialize')
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
index cbbaecfcdd..47346324b8 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
@@ -267,8 +267,8 @@ abstract class AbstractLegacyApiTest extends AbstractValidatorTest
$entity->initialized = false;
// prepare initializers that set "initialized" to true
- $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
- $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
+ $initializer1 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
+ $initializer2 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
$initializer1->expects($this->once())
->method('initialize')
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
index 7359348432..d5ff2954f8 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
@@ -844,7 +844,7 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
public function testLegacyValidatePropertyFailsIfPropertiesNotSupported()
{
// $metadata does not implement PropertyMetadataContainerInterface
- $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock();
$this->metadataFactory->addMetadataForValue('VALUE', $metadata);
@@ -975,7 +975,7 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported()
{
// $metadata does not implement PropertyMetadataContainerInterface
- $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
+ $metadata = $this->getMockBuilder('Symfony\Component\Validator\MetadataInterface')->getMock();
$this->metadataFactory->addMetadataForValue('VALUE', $metadata);
diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php
index b27e6454be..1313fb9e31 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php
@@ -35,7 +35,7 @@ class RecursiveValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
{
$entity = new Entity();
- $validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
+ $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
$validatorContext
->expects($this->once())
->method('validate')
diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
index fbc863157d..d41a791978 100644
--- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
+++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php
@@ -34,7 +34,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testAddObjectInitializer()
{
$this->assertSame($this->builder, $this->builder->addObjectInitializer(
- $this->getMock('Symfony\Component\Validator\ObjectInitializerInterface')
+ $this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock()
));
}
@@ -86,21 +86,21 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testSetMetadataCache()
{
$this->assertSame($this->builder, $this->builder->setMetadataCache(
- $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'))
+ $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock())
);
}
public function testSetConstraintValidatorFactory()
{
$this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory(
- $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'))
+ $this->getMockBuilder('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')->getMock())
);
}
public function testSetTranslator()
{
$this->assertSame($this->builder, $this->builder->setTranslator(
- $this->getMock('Symfony\Component\Translation\TranslatorInterface'))
+ $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())
);
}