diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 959992f5a0..038185b536 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -180,12 +180,12 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() { - $repository = $this->getMock('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface'); + $repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock(); $repository->expects($this->once()) ->method('loadUserByUsername') ->with('name') ->willReturn( - $this->getMock('\Symfony\Component\Security\Core\User\UserInterface') + $this->getMockBuilder('\Symfony\Component\Security\Core\User\UserInterface')->getMock() ); $provider = new EntityUserProvider( @@ -201,7 +201,7 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUserNameShouldDeclineInvalidInterface() { - $repository = $this->getMock('\Symfony\Component\Security\Core\User\AdvancedUserInterface'); + $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index e3f81fe8ea..8c9fcd507e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -33,12 +33,12 @@ class ControllerTest extends TestCase $requestStack = new RequestStack(); $requestStack->push($request); - $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().'--'.$request->getLocale()); })); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('get')->will($this->returnValue($requestStack)); $container->expects($this->at(1))->method('get')->will($this->returnValue($kernel)); @@ -84,7 +84,7 @@ class ControllerTest extends TestCase */ public function testGetUserWithEmptyContainer() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->once()) ->method('has') @@ -104,13 +104,13 @@ class ControllerTest extends TestCase */ private function getContainerWithTokenStorage($token = null) { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock(); $tokenStorage ->expects($this->once()) ->method('getToken') ->will($this->returnValue($token)); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->once()) ->method('has') @@ -128,10 +128,10 @@ class ControllerTest extends TestCase public function testIsGranted() { - $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->will($this->returnValue($authorizationChecker)); @@ -146,10 +146,10 @@ class ControllerTest extends TestCase */ public function testdenyAccessUnlessGranted() { - $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->will($this->returnValue($authorizationChecker)); @@ -164,7 +164,7 @@ class ControllerTest extends TestCase $twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); @@ -180,7 +180,7 @@ class ControllerTest extends TestCase $twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); @@ -195,7 +195,7 @@ class ControllerTest extends TestCase { $twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); @@ -208,10 +208,10 @@ class ControllerTest extends TestCase public function testRedirectToRoute() { - $router = $this->getMock('Symfony\Component\Routing\RouterInterface'); + $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('get')->will($this->returnValue($router)); $controller = new TestController(); @@ -226,10 +226,10 @@ class ControllerTest extends TestCase public function testAddFlash() { $flashBag = new FlashBag(); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock(); $session->expects($this->once())->method('getFlashBag')->willReturn($flashBag); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->will($this->returnValue($session)); @@ -249,10 +249,10 @@ class ControllerTest extends TestCase public function testIsCsrfTokenValid() { - $tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + $tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); $tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->will($this->returnValue($tokenManager)); @@ -264,10 +264,10 @@ class ControllerTest extends TestCase public function testGenerateUrl() { - $router = $this->getMock('Symfony\Component\Routing\RouterInterface'); + $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('get')->will($this->returnValue($router)); $controller = new Controller(); @@ -288,10 +288,10 @@ class ControllerTest extends TestCase public function testRenderViewTemplating() { - $templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); + $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); @@ -303,10 +303,10 @@ class ControllerTest extends TestCase public function testRenderTemplating() { - $templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); + $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating->expects($this->once())->method('renderResponse')->willReturn(new Response('bar')); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); @@ -318,9 +318,9 @@ class ControllerTest extends TestCase public function testStreamTemplating() { - $templating = $this->getMock('Symfony\Component\Routing\RouterInterface'); + $templating = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); @@ -339,12 +339,12 @@ class ControllerTest extends TestCase public function testCreateForm() { - $form = $this->getMock('Symfony\Component\Form\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\FormInterface')->getMock(); - $formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory->expects($this->once())->method('create')->willReturn($form); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory)); $controller = new Controller(); @@ -355,12 +355,12 @@ class ControllerTest extends TestCase public function testCreateFormBuilder() { - $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface'); + $formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock(); - $formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory)); $controller = new Controller(); @@ -371,9 +371,9 @@ class ControllerTest extends TestCase public function testGetDoctrine() { - $doctrine = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); + $doctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php index c0eef3d627..cf13e7e56a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php @@ -24,11 +24,8 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase 'checker_3' => 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->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') @@ -52,11 +49,8 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase public function testThatCheckersCanBeMissing() { - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $container = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('findTaggedServiceIds') - ); + $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock(); $container->expects($this->atLeastOnce()) ->method('findTaggedServiceIds') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 74f0b607bd..c8e252c8fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -30,7 +30,7 @@ class PropertyInfoPassTest 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') @@ -51,7 +51,7 @@ class PropertyInfoPassTest extends \PHPUnit_Framework_TestCase public function testReturningEmptyArrayWhenNoService() { - $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/UnusedTagsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php index f354007bb9..02f5e6b672 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php @@ -19,19 +19,17 @@ class UnusedTagsPassTest extends \PHPUnit_Framework_TestCase { $pass = new UnusedTagsPass(); - $formatter = $this->getMock('Symfony\Component\DependencyInjection\Compiler\LoggingFormatter'); + $formatter = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\LoggingFormatter')->getMock(); $formatter ->expects($this->at(0)) ->method('format') ->with($pass, 'Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?') ; - $compiler = $this->getMock('Symfony\Component\DependencyInjection\Compiler\Compiler'); + $compiler = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\Compiler')->getMock(); $compiler->expects($this->once())->method('getLoggingFormatter')->will($this->returnValue($formatter)); - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', - array('findTaggedServiceIds', 'getCompiler', 'findUnusedTags', 'findTags') - ); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getCompiler', 'findUnusedTags', 'findTags'))->getMock(); $container->expects($this->once())->method('getCompiler')->will($this->returnValue($compiler)); $container->expects($this->once()) ->method('findTags') diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 13bb9ef909..636d5796f8 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -17,7 +17,7 @@ class TemplateIteratorTest extends TestCase { public function testGetIterator() { - $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('BarBundle')); $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php index 17817ae7c2..ab36cf75d1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php @@ -33,7 +33,7 @@ class ExportCommandTest extends \PHPUnit_Framework_TestCase ; $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); @@ -56,7 +56,7 @@ class ExportCommandTest extends \PHPUnit_Framework_TestCase $profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile)); $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php index 2c440ecc75..0b3fd0b546 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php @@ -32,7 +32,7 @@ class ImportCommandTest extends \PHPUnit_Framework_TestCase $profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN'))); $helperSet = new HelperSet(); - $helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper'); + $helper = $this->getMockBuilder('Symfony\Component\Console\Helper\FormatterHelper')->getMock(); $helper->expects($this->any())->method('formatSection'); $helperSet->set($helper, 'formatter'); diff --git a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php index c76c0dd0ac..d66c2e89d9 100644 --- a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php @@ -44,7 +44,7 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase public function testCacheIsNotFreshIfEmpty() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface') + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock() ->expects($this->never())->method('supports'); /* If there is nothing in the cache, it needs to be filled (and thus it's not fresh). @@ -75,7 +75,7 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase public function testIsFreshWithchecker() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') @@ -93,7 +93,7 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase public function testIsNotFreshWithchecker() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $checker->expects($this->once()) ->method('supports') @@ -111,7 +111,7 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase public function testCacheIsNotFreshWhenUnserializeFails() { - $checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface'); + $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); $cache->write('foo', array(new FileResource(__FILE__))); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 18ac7ad9e7..61f1206b9f 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -435,7 +435,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase $bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]); - $mockLogger = $this->getMock('Psr\Log\LoggerInterface'); + $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]); diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 5c45876662..46eece72ff 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -75,7 +75,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase public function testGetListenerPriorityReturnsZeroWhenWrappedMethodDoesNotExist() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $traceableEventDispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); $traceableEventDispatcher->addListener('foo', function () {}, 123); $listeners = $traceableEventDispatcher->getListeners('foo'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 959eb928d2..b60365cacf 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -19,7 +19,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase public function testTrim() { $data = ' Foo! '; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new TrimListener(); @@ -31,7 +31,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase public function testTrimSkipNonStrings() { $data = 1234; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $event = new FormEvent($form, $data); $filter = new TrimListener(); diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index 77fb370d73..cfb7fadfa2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -18,17 +18,17 @@ class DependencyInjectionExtensionTest extends \PHPUnit_Framework_TestCase { public function testGetTypeExtensions() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $typeExtension1 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension1->expects($this->any()) ->method('getExtendedType') ->willReturn('test'); - $typeExtension2 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension2->expects($this->any()) ->method('getExtendedType') ->willReturn('test'); - $typeExtension3 = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension3 = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension3->expects($this->any()) ->method('getExtendedType') ->willReturn('other'); @@ -61,9 +61,9 @@ class DependencyInjectionExtensionTest extends \PHPUnit_Framework_TestCase */ public function testThrowExceptionForInvalidExtendedType() { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $typeExtension = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); + $typeExtension = $this->getMockBuilder('Symfony\Component\Form\FormTypeExtensionInterface')->getMock(); $typeExtension->expects($this->any()) ->method('getExtendedType') ->willReturn('unmatched'); 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 dc5ff0511e..59231e9fbc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -109,7 +109,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest public function testValidateIfParentWithCascadeValidation() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) ->setCompound(true) @@ -131,7 +131,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest public function testValidateIfChildWithValidConstraint() { - $object = $this->getMock('\stdClass'); + $object = $this->getMockBuilder('\stdClass')->getMock(); $parent = $this->getBuilder('parent') ->setCompound(true) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php index 788b8a082b..a851cd82ff 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php @@ -54,10 +54,10 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); + $this->violationMapper = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface')->getMock(); $this->listener = new ValidationListener($this->validator, $this->violationMapper); $this->message = 'Message'; $this->messageTemplate = 'Message template'; @@ -87,7 +87,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase private function getMockForm() { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); + return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); } // More specific mapping tests can be found in ViolationMapperTest @@ -183,7 +183,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase 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(); $listener = new ValidationListener($validator, $this->violationMapper); $this->assertAttributeSame($validator, 'validator', $listener); @@ -195,7 +195,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase 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(); $listener = new ValidationListener($validator, $this->violationMapper); $this->assertAttributeSame($validator, 'validator', $listener); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php index 19b6c1ca0c..663cdd0339 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php @@ -20,7 +20,7 @@ abstract class TypeTestCase extends BaseTypeTestCase protected function setUp() { - $this->validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); + $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $this->validator->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php index 9aa6053376..4ad0189f61 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php @@ -56,8 +56,8 @@ class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase */ public function test2Dot4ValidationApi() { - $factory = $this->getMock('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface'); - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); + $factory = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface')->getMock(); + $validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock(); $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 220e6898bd..a98b066934 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -51,7 +51,7 @@ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->metadata = new ClassMetadata(self::TEST_CLASS); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface'); + $this->metadataFactory = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface')->getMock(); $this->metadataFactory->expects($this->any()) ->method('getMetadataFor') ->with(self::TEST_CLASS) diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 20a1c0052c..af4220d824 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -26,7 +26,7 @@ class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase $this->registry = $factory->getProperty('registry'); $this->registry->setAccessible(true); - $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); + $this->guesser = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->type = new LegacyFooType(); } diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 3649bc4fb9..952cd046ff 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -63,9 +63,9 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactory'); - $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); + $this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactory')->getMock(); + $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->extension1 = new TestExtension($this->guesser1); $this->extension2 = new TestExtension($this->guesser2); $this->registry = new FormRegistry(array( @@ -305,7 +305,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); $registry = new FormRegistry( - array($this->getMock('Symfony\Component\Form\FormExtensionInterface')), + array($this->getMockBuilder('Symfony\Component\Form\FormExtensionInterface')->getMock()), $this->resolvedTypeFactory ); diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 36804ebebe..a6ca4e3536 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -69,9 +69,9 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $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->parentType = $this->getMockFormType(); $this->type = $this->getMockFormType(); $this->extension1 = $this->getMockFormTypeExtension(); @@ -127,7 +127,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase { $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -155,7 +155,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase { $givenOptions = array('data_class' => 'Foo'); $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolverInterface')->getMock(); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -194,7 +194,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase }; $options = array('a' => 'Foo', 'b' => 'Bar'); - $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); + $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); // First the form is built for the super type $this->parentType->expects($this->once()) @@ -224,7 +224,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase public function testCreateView() { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); $view = $this->resolvedType->createView($form); @@ -234,8 +234,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase public function testCreateViewWithParent() { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $view = $this->resolvedType->createView($form, $parentView); @@ -246,8 +246,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase public function testBuildView() { $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $test = $this; $i = 0; @@ -290,8 +290,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase public function testFinishView() { $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); + $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock(); + $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $test = $this; $i = 0; @@ -393,7 +393,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase public function testBlockPrefixDefaultsToNameIfSet() { // Type without getBlockPrefix() method - $type = $this->getMock('Symfony\Component\Form\FormTypeInterface'); + $type = $this->getMockBuilder('Symfony\Component\Form\FormTypeInterface')->getMock(); $type->expects($this->once()) ->method('getName') @@ -431,7 +431,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase */ private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType') { - return $this->getMock($typeClass, array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder($typeClass)->setMethods(array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -439,7 +439,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase */ private function getMockFormTypeExtension() { - return $this->getMock('Symfony\Component\Form\AbstractTypeExtension', array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock(); } /** @@ -447,7 +447,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase */ private function getMockFormFactory() { - return $this->getMock('Symfony\Component\Form\FormFactoryInterface'); + return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); } /** diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 963bbb3010..b5c9a6d48e 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -23,11 +23,7 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase */ public function testProcessFailedExceptionThrowsException() { - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful'), - array('php') - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful'))->setConstructorArgs(array('php'))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(true)); @@ -53,11 +49,7 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase $errorOutput = 'FATAL: Unexpected error'; $workingDirectory = getcwd(); - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'))->setConstructorArgs(array($cmd)); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); @@ -105,11 +97,7 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase $exitText = 'General error'; $workingDirectory = getcwd(); - $process = $this->getMock( - 'Symfony\Component\Process\Process', - array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'), - array($cmd) - ); + $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'))->setConstructorArgs(array($cmd))->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index b944ffe808..ece28746e9 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -20,8 +20,8 @@ class RouteCollectionBuilderTest extends \PHPUnit_Framework_TestCase { public function testImport() { - $resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); - $resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); + $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('admin_routing.yml', 'yaml') @@ -38,7 +38,7 @@ class RouteCollectionBuilderTest extends \PHPUnit_Framework_TestCase ->with('admin_routing.yml', 'yaml') ->will($this->returnValue($expectedCollection)); - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('getResolver') ->will($this->returnValue($resolver)); @@ -89,7 +89,7 @@ class RouteCollectionBuilderTest extends \PHPUnit_Framework_TestCase $importedCollection->add('imported_route1', new Route('/imported/foo1')); $importedCollection->add('imported_route2', new Route('/imported/foo2')); - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') @@ -252,7 +252,7 @@ class RouteCollectionBuilderTest extends \PHPUnit_Framework_TestCase public function testFlushSetsPrefixedWithMultipleLevels() { - $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $routes = new RouteCollectionBuilder($loader); $routes->add('homepage', 'MainController::homepageAction', 'homepage'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 8f4b39278a..f22227b0e2 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -20,14 +20,14 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $provider = $this->getProvider('foo'); $this->assertTrue($provider->supports($this->getSupportedToken('foo'))); - $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('foo'); - $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())); } /** @@ -50,7 +50,7 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase protected function getSupportedToken($secret) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getSecret'), array(), '', false); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getSecret'))->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') ->will($this->returnValue($secret)) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index fbb4d733a9..aae3c764af 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -27,9 +27,9 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase */ public function testEmptyPasswordShouldThrowAnException() { - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -44,14 +44,14 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase */ public function testBindFailureShouldThrowAnException() { - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('bind') ->will($this->throwException(new ConnectionException())) ; - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -62,15 +62,15 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase public function testRetrieveUser() { - $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') ->with('foo') ; - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); - $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 735d195d0c..2099d9835f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -22,14 +22,14 @@ class RememberMeAuthenticationProviderTest 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(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->assertNull($provider->authenticate($token)); } @@ -49,7 +49,7 @@ class RememberMeAuthenticationProviderTest 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 DisabledException())); @@ -61,7 +61,7 @@ class RememberMeAuthenticationProviderTest 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->exactly(2)) ->method('getRoles') ->will($this->returnValue(array('ROLE_FOO'))); @@ -80,14 +80,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase protected function getSupportedToken($user = null, $secret = 'test') { if (null === $user) { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->any()) ->method('getRoles') ->will($this->returnValue(array())); } - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $secret)); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('getProviderKey'))->setConstructorArgs(array($user, 'foo', $secret))->getMock(); $token ->expects($this->once()) ->method('getProviderKey') @@ -99,7 +99,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase protected function getProvider($userChecker = null, $key = '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 RememberMeAuthenticationProvider($userChecker, $key, 'foo'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 4bac44d981..cbd2755d5a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -21,7 +21,7 @@ class VoterTest 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(); } public function getTests() diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 9b126e9518..a8fc2618ea 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -24,7 +24,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUsernameFailsIfCantConnectToLdap() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('bind') @@ -40,7 +40,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUsernameFailsIfNoLdapEntries() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -56,7 +56,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase */ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') @@ -78,7 +78,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase public function testSuccessfulLoadUserByUsername() { - $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface'); + $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock(); $ldap ->expects($this->once()) ->method('escape') diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index 3224fee78d..dee7ad1695 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -31,8 +31,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testHandleSuccess() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $providerKey = 'my_firewall'; $credentials = array('username' => 'weaverryan', 'password' => 'all_your_base'); @@ -81,8 +81,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testHandleSuccessStopsAfterResponseIsSet() { - $authenticator1 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticator2 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator1 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticator2 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); // mock the first authenticator to fail, and set a Response $authenticator1 @@ -111,8 +111,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testHandleSuccessWithRememberMe() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $providerKey = 'my_firewall_with_rememberme'; $authenticator @@ -154,7 +154,7 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testHandleCatchesAuthenticationException() { - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $providerKey = 'my_firewall2'; $authException = new AuthenticationException('Get outta here crazy user with a bad password!'); @@ -186,8 +186,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testReturnNullToSkipAuth() { - $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $providerKey = 'my_firewall3'; $authenticatorA @@ -240,8 +240,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->method('getRequest') ->will($this->returnValue($this->request)); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->rememberMeServices = $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface'); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index 6f36702df1..58a3e1790e 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -123,11 +123,11 @@ class GuardAuthenticatorHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $this->request = new Request(array(), array(), array(), array(), array(), array()); - $this->guardAuthenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $this->guardAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index bfcf24b770..e7e323a178 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -27,9 +27,9 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase { $providerKey = 'my_cool_firewall'; - $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); - $authenticatorC = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticatorC = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); $authenticators = array($authenticatorA, $authenticatorB, $authenticatorC); // called 2 times - for authenticator A and B (stops on B because of match) @@ -52,7 +52,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $authenticatorC->expects($this->never()) ->method('getUser'); - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) @@ -63,7 +63,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase ->with($enteredCredentials, $mockedUser) // authentication works! ->will($this->returnValue(true)); - $authedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) @@ -89,7 +89,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase { $providerKey = 'my_uncool_firewall'; - $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); // make sure the authenticator is used $this->preAuthenticationToken->expects($this->any()) @@ -101,7 +101,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase ->method('getCredentials') ->will($this->returnValue('non-null-value')); - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticator->expects($this->once()) ->method('getUser') ->will($this->returnValue($mockedUser)); @@ -124,7 +124,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase // create a token and mark it as NOT authenticated anymore // this mimics what would happen if a user "changed" between request - $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $token = new PostAuthenticationGuardToken($mockedUser, $providerKey, array('ROLE_USER')); $token->setAuthenticated(false); @@ -134,8 +134,8 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index d99b56239f..ba740c4157 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -18,30 +18,30 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase { public function testHandleWithTokenStorageHavingAToken() { - $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($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $tokenStorage ->expects($this->never()) ->method('setToken') ; - $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') ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandleWithTokenStorageHavingNoToken() { - $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') @@ -50,7 +50,7 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $anonymousToken = new AnonymousToken('TheSecret', 'anon.', array()); - $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') @@ -67,21 +67,21 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandledEventIsLogged() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('info') ->with('Populated the TokenStorage with an anonymous Token.') ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php index 80b2dc4134..2a29db7012 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php @@ -34,12 +34,12 @@ class DigestAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $entryPoint = new DigestAuthenticationEntryPoint($realm, $secret); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->method('getPassword')->willReturn($password); $providerKey = 'TheProviderKey'; - $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('getToken') @@ -51,12 +51,12 @@ class DigestAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo(new UsernamePasswordToken($user, $password, $providerKey))) ; - $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $userProvider->method('loadUserByUsername')->willReturn($user); $listener = new DigestAuthenticationListener($tokenStorage, $userProvider, $providerKey, $entryPoint); - $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/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index adf91b1c4d..90ce1e6f24 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -42,7 +42,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->token)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -79,7 +79,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo(null)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -99,20 +99,20 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->getMock() ; - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->request = new Request(array(), array(), array(), array(), array(), array()); - $this->event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $this->event ->expects($this->any()) ->method('getRequest') ->will($this->returnValue($this->request)) ; - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } protected function tearDown() diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php index 23014f300e..5edb223577 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php @@ -28,7 +28,7 @@ class ArrayDenormalizerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializer = $this->getMock('Symfony\Component\Serializer\Serializer'); + $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')->getMock(); $this->denormalizer = new ArrayDenormalizer(); $this->denormalizer->setSerializer($this->serializer); } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 75093580b4..3726ccfdc0 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -95,7 +95,7 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase $catalogue->addResource(new StaleResource()); // better use a helper class than a mock, because it gets serialized in the cache and re-loaded /** @var LoaderInterface|\PHPUnit_Framework_MockObject_MockObject $loader */ - $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader ->expects($this->exactly(2)) ->method('load') @@ -228,8 +228,8 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase public function testRefreshCacheWhenResourcesAreNoLongerFresh() { - $resource = $this->getMock('Symfony\Component\Config\Resource\SelfCheckingResourceInterface'); - $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock(); + $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $resource->method('isFresh')->will($this->returnValue(false)); $loader ->expects($this->exactly(2)) @@ -272,7 +272,7 @@ class TranslatorCacheTest extends \PHPUnit_Framework_TestCase */ private function createFailingLoader() { - $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/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 61510abc37..420fb70576 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -224,7 +224,7 @@ class ExpressionValidatorTest extends AbstractConstraintValidatorTest 'expression' => 'false', )); - $expressionLanguage = $this->getMock('Symfony\Component\ExpressionLanguage\ExpressionLanguage'); + $expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock(); $used = false;