fixed obsolete getMock() usage

This commit is contained in:
Fabien Potencier 2016-12-19 10:02:29 +01:00
parent f1675c2ddd
commit 71d059cad1
272 changed files with 1192 additions and 1286 deletions

View File

@ -139,7 +139,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
->method('getDatabasePlatform') ->method('getDatabasePlatform')
->will($this->returnValue(new MySqlPlatform())); ->will($this->returnValue(new MySqlPlatform()));
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry $registry
->expects($this->any()) ->expects($this->any())
->method('getConnectionNames') ->method('getConnectionNames')
@ -152,7 +152,7 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
->method('getConnection') ->method('getConnection')
->will($this->returnValue($connection)); ->will($this->returnValue($connection));
$logger = $this->getMock('Doctrine\DBAL\Logging\DebugStack'); $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
$logger->queries = $queries; $logger->queries = $queries;
$collector = new DoctrineDataCollector($registry); $collector = new DoctrineDataCollector($registry);

View File

@ -18,7 +18,7 @@ class ContainerAwareLoaderTest extends \PHPUnit_Framework_TestCase
{ {
public function testShouldSetContainerOnContainerAwareFixture() public function testShouldSetContainerOnContainerAwareFixture()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$loader = new ContainerAwareLoader($container); $loader = new ContainerAwareLoader($container);
$fixture = new ContainerAwareFixture(); $fixture = new ContainerAwareFixture();

View File

@ -17,7 +17,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
{ {
public function testFetch() public function testFetch()
{ {
$doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache'); $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock); $parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock->expects($this->once()) $doctrineCacheMock->expects($this->once())
@ -31,7 +31,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
public function testFetchUnexisting() public function testFetchUnexisting()
{ {
$doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache'); $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock); $parserCache = new DoctrineParserCache($doctrineCacheMock);
$doctrineCacheMock $doctrineCacheMock
@ -44,7 +44,7 @@ class DoctrineParserCacheTest extends \PHPUnit_Framework_TestCase
public function testSave() public function testSave()
{ {
$doctrineCacheMock = $this->getMock('Doctrine\Common\Cache\Cache'); $doctrineCacheMock = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$parserCache = new DoctrineParserCache($doctrineCacheMock); $parserCache = new DoctrineParserCache($doctrineCacheMock);
$expression = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParsedExpression') $expression = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParsedExpression')

View File

@ -72,14 +72,14 @@ class DoctrineChoiceLoaderTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface'); $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); $this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$this->repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository'); $this->repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$this->class = 'stdClass'; $this->class = 'stdClass';
$this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader') $this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->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->obj1 = (object) array('name' => 'A');
$this->obj2 = (object) array('name' => 'B'); $this->obj2 = (object) array('name' => 'B');
$this->obj3 = (object) array('name' => 'C'); $this->obj3 = (object) array('name' => 'C');

View File

@ -86,10 +86,10 @@ class DoctrineOrmTypeGuesserTest extends \PHPUnit_Framework_TestCase
private function getGuesser(ClassMetadata $classMetadata) 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)); $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))); $registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em)));
return new DoctrineOrmTypeGuesser($registry); return new DoctrineOrmTypeGuesser($registry);

View File

@ -32,7 +32,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
protected function getExtensions() protected function getExtensions()
{ {
$manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); $manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any()) $manager->expects($this->any())
->method('getManager') ->method('getManager')

View File

@ -1300,7 +1300,7 @@ class EntityTypeTest extends TypeTestCase
protected function createRegistryMock($name, $em) protected function createRegistryMock($name, $em)
{ {
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->any()) $registry->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo($name)) ->with($this->equalTo($name))

View File

@ -20,7 +20,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLog($sql, $params, $logParams) public function testLog($sql, $params, $logParams)
{ {
$logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@ -52,7 +52,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogNonUtf8() public function testLogNonUtf8()
{ {
$logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@ -75,7 +75,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogNonUtf8Array() public function testLogNonUtf8Array()
{ {
$logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@ -106,7 +106,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
public function testLogLongString() public function testLogLongString()
{ {
$logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
@ -137,7 +137,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLogUTF8LongString() public function testLogUTF8LongString()
{ {
$logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')

View File

@ -150,7 +150,7 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
private function getManager($em, $name = null) 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()) $manager->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo($name)) ->with($this->equalTo($name))

View File

@ -63,7 +63,7 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
protected function createRegistryMock(ObjectManager $em = null) 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()) $registry->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo(self::EM_NAME)) ->with($this->equalTo(self::EM_NAME))
@ -92,7 +92,7 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
->will($this->returnValue($repositoryMock)) ->will($this->returnValue($repositoryMock))
; ;
$classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$classMetadata $classMetadata
->expects($this->any()) ->expects($this->any())
->method('hasField') ->method('hasField')

View File

@ -45,7 +45,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
*/ */
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array()) 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 $output
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('getVerbosity') ->method('getVerbosity')
@ -80,7 +80,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
public function testVerbosityChanged() public function testVerbosityChanged()
{ {
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output $output
->expects($this->at(0)) ->expects($this->at(0))
->method('getVerbosity') ->method('getVerbosity')
@ -110,7 +110,7 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
public function testWritingAndFormatting() public function testWritingAndFormatting()
{ {
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$output $output
->expects($this->any()) ->expects($this->any())
->method('getVerbosity') ->method('getVerbosity')
@ -165,12 +165,12 @@ class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
$logger->addInfo('After terminate message.'); $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); $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
$this->assertContains('Before command message.', $out = $output->fetch()); $this->assertContains('Before command message.', $out = $output->fetch());
$this->assertContains('After command message.', $out); $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); $dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$this->assertContains('Before terminate message.', $out = $output->fetch()); $this->assertContains('Before terminate message.', $out = $output->fetch());
$this->assertContains('After terminate message.', $out); $this->assertContains('After terminate message.', $out);

View File

@ -37,7 +37,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
public function testInstantiateProxy() public function testInstantiateProxy()
{ {
$instance = new \stdClass(); $instance = new \stdClass();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$definition = new Definition('stdClass'); $definition = new Definition('stdClass');
$instantiator = function () use ($instance) { $instantiator = function () use ($instance) {
return $instance; return $instance;

View File

@ -45,7 +45,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetSession() 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()); $request->method('getSession')->willReturn($session = new Session());
$this->setRequestStack($request); $this->setRequestStack($request);
@ -69,7 +69,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUser() 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()); $this->assertEquals($user, $this->appVariable->getUser());
} }
@ -83,7 +83,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUserWithNoToken() 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->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getUser()); $this->assertNull($this->appVariable->getUser());
@ -131,7 +131,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setRequestStack($request) protected function setRequestStack($request)
{ {
$requestStackMock = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackMock->method('getCurrentRequest')->willReturn($request); $requestStackMock->method('getCurrentRequest')->willReturn($request);
$this->appVariable->setRequestStack($requestStackMock); $this->appVariable->setRequestStack($requestStackMock);
@ -139,10 +139,10 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setTokenStorage($user) 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); $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); $tokenStorage->method('getToken')->willReturn($token);
$token->method('getUser')->willReturn($user); $token->method('getUser')->willReturn($user);

View File

@ -63,7 +63,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase
public function testDump($context, $args, $expectedOutput, $debug = true) public function testDump($context, $args, $expectedOutput, $debug = true)
{ {
$extension = new DumpExtension(new VarCloner()); $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, 'debug' => $debug,
'cache' => false, 'cache' => false,
'optimizations' => 0, 'optimizations' => 0,

View File

@ -39,7 +39,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
'bootstrap_3_horizontal_layout.html.twig', 'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.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); $this->extension = new FormExtension($renderer);

View File

@ -39,7 +39,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig', 'bootstrap_3_layout.html.twig',
'custom_widgets.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); $this->extension = new FormExtension($renderer);

View File

@ -40,7 +40,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig', 'form_div_layout.html.twig',
'custom_widgets.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); $this->extension = new FormExtension($renderer);

View File

@ -39,7 +39,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig', 'form_table_layout.html.twig',
'custom_widgets.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); $this->extension = new FormExtension($renderer);

View File

@ -51,7 +51,7 @@ class HttpKernelExtensionTest extends \PHPUnit_Framework_TestCase
protected function getFragmentHandler($return) 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('getName')->will($this->returnValue('inline'));
$strategy->expects($this->once())->method('render')->will($return); $strategy->expects($this->once())->method('render')->will($return);

View File

@ -20,8 +20,8 @@ class RoutingExtensionTest extends \PHPUnit_Framework_TestCase
*/ */
public function testEscaping($template, $mustBeEscaped) public function testEscaping($template, $mustBeEscaped)
{ {
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
$twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'))); $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()));
$nodes = $twig->parse($twig->tokenize(new \Twig_Source($template, ''))); $nodes = $twig->parse($twig->tokenize(new \Twig_Source($template, '')));

View File

@ -53,7 +53,7 @@ class StopwatchExtensionTest extends \PHPUnit_Framework_TestCase
protected function getStopwatch($events = array()) protected function getStopwatch($events = array())
{ {
$events = is_array($events) ? $events : array($events); $events = is_array($events) ? $events : array($events);
$stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch'); $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$i = -1; $i = -1;
foreach ($events as $eventName) { foreach ($events as $eventName) {

View File

@ -19,7 +19,7 @@ class DumpNodeTest extends \PHPUnit_Framework_TestCase
{ {
$node = new DumpNode('bar', null, 7); $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); $compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -43,7 +43,7 @@ EOTXT;
{ {
$node = new DumpNode('bar', null, 7); $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); $compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -70,7 +70,7 @@ EOTXT;
)); ));
$node = new DumpNode('bar', $vars, 7); $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); $compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -99,7 +99,7 @@ EOTXT;
)); ));
$node = new DumpNode('bar', $vars, 7); $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); $compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'

View File

@ -41,7 +41,7 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase
$node = new FormThemeNode($form, $resources, 0); $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( $this->assertEquals(
sprintf( sprintf(

View File

@ -23,7 +23,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -46,7 +46,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -66,7 +66,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -86,7 +86,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // 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); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // 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); $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( $this->assertEquals(
sprintf( sprintf(
@ -153,7 +153,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // 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); $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( $this->assertEquals(
sprintf( sprintf(
@ -210,7 +210,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // 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); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.

View File

@ -24,7 +24,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
$vars = new \Twig_Node_Expression_Name('foo', 0); $vars = new \Twig_Node_Expression_Name('foo', 0);
$node = new TransNode($body, null, null, $vars); $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); $compiler = new \Twig_Compiler($env);
$this->assertEquals( $this->assertEquals(

View File

@ -22,7 +22,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */ /** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(\Twig_Node $node) 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(); $visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag // visit trans_default_domain tag
@ -48,7 +48,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */ /** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node) 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(); $visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag // visit trans_default_domain tag

View File

@ -18,7 +18,7 @@ class TranslationNodeVisitorTest extends \PHPUnit_Framework_TestCase
/** @dataProvider getMessagesExtractionTestData */ /** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages) 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 = new TranslationNodeVisitor();
$visitor->enable(); $visitor->enable();
$visitor->enterNode($node, $env); $visitor->enterNode($node, $env);

View File

@ -21,7 +21,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase
*/ */
public function testCompile($source, $expected) 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()); $env->addTokenParser(new FormThemeTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, '')); $stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env); $parser = new \Twig_Parser($env);

View File

@ -22,14 +22,14 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testExtract($template, $messages) public function testExtract($template, $messages)
{ {
$loader = $this->getMock('Twig_LoaderInterface'); $loader = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
$twig = new \Twig_Environment($loader, array( $twig = new \Twig_Environment($loader, array(
'strict_variables' => true, 'strict_variables' => true,
'debug' => true, 'debug' => true,
'cache' => false, 'cache' => false,
'autoescape' => 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 = new TwigExtractor($twig);
$extractor->setPrefix('prefix'); $extractor->setPrefix('prefix');
@ -77,8 +77,8 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testExtractSyntaxError($resources) public function testExtractSyntaxError($resources)
{ {
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$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 = new TwigExtractor($twig);
@ -120,7 +120,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
'cache' => false, 'cache' => false,
'autoescape' => 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 = new TwigExtractor($twig);
$catalogue = new MessageCatalogue('en'); $catalogue = new MessageCatalogue('en');

View File

@ -71,7 +71,7 @@ class TwigEngineTest extends \PHPUnit_Framework_TestCase
'index' => 'foo', 'index' => 'foo',
'error' => '{{ foo }', 'error' => '{{ foo }',
))); )));
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
return new TwigEngine($twig, $parser); return new TwigEngine($twig, $parser);
} }

View File

@ -63,7 +63,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
{ {
$routeCollection = new RouteCollection(); $routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo')); $routeCollection->add('foo', new Route('foo'));
$router = $this->getMock('Symfony\Component\Routing\RouterInterface'); $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router $router
->expects($this->any()) ->expects($this->any())
->method('getRouteCollection') ->method('getRouteCollection')
@ -74,7 +74,7 @@ class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
->method('has') ->method('has')

View File

@ -62,7 +62,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
$routeCollection = new RouteCollection(); $routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo')); $routeCollection->add('foo', new Route('foo'));
$requestContext = new RequestContext(); $requestContext = new RequestContext();
$router = $this->getMock('Symfony\Component\Routing\RouterInterface'); $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router $router
->expects($this->any()) ->expects($this->any())
->method('getRouteCollection') ->method('getRouteCollection')
@ -78,7 +78,7 @@ class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
->method('has') ->method('has')

View File

@ -64,7 +64,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
public function testDebugCustomDirectory() public function testDebugCustomDirectory()
{ {
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once()) $kernel->expects($this->once())
->method('getBundle') ->method('getBundle')
->with($this->equalTo($this->translationDir)) ->with($this->equalTo($this->translationDir))
@ -82,7 +82,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
*/ */
public function testDebugInvalidDirectory() public function testDebugInvalidDirectory()
{ {
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once()) $kernel->expects($this->once())
->method('getBundle') ->method('getBundle')
->with($this->equalTo('dir')) ->with($this->equalTo('dir'))
@ -130,7 +130,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
->method('getFallbackLocales') ->method('getFallbackLocales')
->will($this->returnValue(array('en'))); ->will($this->returnValue(array('en')));
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface'); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->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 $loader
->expects($this->any()) ->expects($this->any())
->method('loadMessages') ->method('loadMessages')
@ -151,7 +151,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
); );
if (null === $kernel) { if (null === $kernel) {
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -166,7 +166,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
->method('getRootDir') ->method('getRootDir')
->will($this->returnValue($this->translationDir)); ->will($this->returnValue($this->translationDir));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
@ -182,7 +182,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
private function getBundle($path) private function getBundle($path)
{ {
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface'); $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')

View File

@ -68,7 +68,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
->method('getFallbackLocales') ->method('getFallbackLocales')
->will($this->returnValue(array('en'))); ->will($this->returnValue(array('en')));
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface'); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->method('extract')
@ -78,7 +78,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 $loader
->expects($this->any()) ->expects($this->any())
->method('loadMessages') ->method('loadMessages')
@ -88,7 +88,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 $writer
->expects($this->any()) ->expects($this->any())
->method('getFormats') ->method('getFormats')
@ -97,7 +97,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
); );
if (null === $kernel) { if (null === $kernel) {
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -112,7 +112,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
->method('getRootDir') ->method('getRootDir')
->will($this->returnValue($this->translationDir)); ->will($this->returnValue($this->translationDir));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
@ -129,7 +129,7 @@ class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
private function getBundle($path) private function getBundle($path)
{ {
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface'); $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')

View File

@ -22,7 +22,7 @@ class ApplicationTest extends TestCase
{ {
public function testBundleInterfaceImplementation() 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); $kernel = $this->getKernel(array($bundle), true);
@ -117,10 +117,10 @@ class ApplicationTest extends TestCase
private function getKernel(array $bundles, $useDispatcher = false) private function getKernel(array $bundles, $useDispatcher = false)
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
if ($useDispatcher) { if ($useDispatcher) {
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher $dispatcher
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('dispatch') ->method('dispatch')
@ -145,7 +145,7 @@ class ApplicationTest extends TestCase
->will($this->returnValue(array())) ->will($this->returnValue(array()))
; ;
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundles') ->method('getBundles')
@ -162,7 +162,7 @@ class ApplicationTest extends TestCase
private function createBundleMock(array $commands) private function createBundleMock(array $commands)
{ {
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
$bundle $bundle
->expects($this->once()) ->expects($this->once())
->method('registerCommands') ->method('registerCommands')

View File

@ -147,7 +147,7 @@ class ControllerNameParserTest extends TestCase
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')), '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 $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -178,7 +178,7 @@ class ControllerNameParserTest extends TestCase
private function getBundle($namespace, $name) 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('getName')->will($this->returnValue($name));
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace)); $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));

View File

@ -175,12 +175,12 @@ class ControllerResolverTest extends BaseControllerResolverTest
protected function createMockParser() 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() protected function createMockContainer()
{ {
return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
} }
} }

View File

@ -33,12 +33,12 @@ class ControllerTest extends TestCase
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push($request); $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) { $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale()); 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(0))->method('get')->will($this->returnValue($requestStack));
$container->expects($this->at(1))->method('get')->will($this->returnValue($kernel)); $container->expects($this->at(1))->method('get')->will($this->returnValue($kernel));
@ -84,7 +84,7 @@ class ControllerTest extends TestCase
*/ */
public function testGetUserWithEmptyContainer() public function testGetUserWithEmptyContainer()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
->method('has') ->method('has')
@ -104,13 +104,13 @@ class ControllerTest extends TestCase
*/ */
private function getContainerWithTokenStorage($token = null) 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 $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
->will($this->returnValue($token)); ->will($this->returnValue($token));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
->method('has') ->method('has')
@ -128,10 +128,10 @@ class ControllerTest extends TestCase
public function testRedirectToRoute() 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'); $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)); $container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new TestController(); $controller = new TestController();
@ -146,10 +146,10 @@ class ControllerTest extends TestCase
public function testAddFlash() public function testAddFlash()
{ {
$flashBag = new FlashBag(); $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); $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(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($session)); $container->expects($this->at(1))->method('get')->will($this->returnValue($session));
@ -169,10 +169,10 @@ class ControllerTest extends TestCase
public function testIsCsrfTokenValid() 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); $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(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($tokenManager)); $container->expects($this->at(1))->method('get')->will($this->returnValue($tokenManager));
@ -184,10 +184,10 @@ class ControllerTest extends TestCase
public function testGenerateUrl() 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'); $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)); $container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new Controller(); $controller = new Controller();
@ -208,10 +208,10 @@ class ControllerTest extends TestCase
public function testRenderViewTemplating() 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'); $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('get')->will($this->returnValue($templating)); $container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller(); $controller = new Controller();
@ -222,10 +222,10 @@ class ControllerTest extends TestCase
public function testRenderTemplating() 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')); $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('get')->will($this->returnValue($templating)); $container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller(); $controller = new Controller();
@ -236,9 +236,9 @@ class ControllerTest extends TestCase
public function testStreamTemplating() 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('get')->will($this->returnValue($templating)); $container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller(); $controller = new Controller();
@ -256,12 +256,12 @@ class ControllerTest extends TestCase
public function testCreateForm() 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); $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)); $container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new Controller(); $controller = new Controller();
@ -272,12 +272,12 @@ class ControllerTest extends TestCase
public function testCreateFormBuilder() 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); $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)); $container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new Controller(); $controller = new Controller();
@ -288,9 +288,9 @@ class ControllerTest extends TestCase
public function testGetDoctrine() 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(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine)); $container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine));

View File

@ -66,14 +66,14 @@ class RedirectControllerTest extends TestCase
$request->attributes = new ParameterBag($attributes); $request->attributes = new ParameterBag($attributes);
$router = $this->getMock('Symfony\Component\Routing\RouterInterface'); $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router $router
->expects($this->once()) ->expects($this->once())
->method('generate') ->method('generate')
->with($this->equalTo($route), $this->equalTo($expectedAttributes)) ->with($this->equalTo($route), $this->equalTo($expectedAttributes))
->will($this->returnValue($url)); ->will($this->returnValue($url));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
@ -230,7 +230,7 @@ class RedirectControllerTest extends TestCase
private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '') private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '')
{ {
$request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request $request
->expects($this->any()) ->expects($this->any())
->method('getScheme') ->method('getScheme')
@ -257,7 +257,7 @@ class RedirectControllerTest extends TestCase
private function createRedirectController($httpPort = null, $httpsPort = null) 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) { if (null !== $httpPort) {
$container $container

View File

@ -24,11 +24,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
'my_cache_warmer_service3' => array(), 'my_cache_warmer_service3' => array(),
); );
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
);
$container->expects($this->atLeastOnce()) $container->expects($this->atLeastOnce())
->method('findTaggedServiceIds') ->method('findTaggedServiceIds')
@ -56,11 +53,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition() public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$container->expects($this->never())->method('findTaggedServiceIds'); $container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition'); $container->expects($this->never())->method('getDefinition');
@ -76,11 +70,8 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
public function testThatCacheWarmersMightBeNotDefined() public function testThatCacheWarmersMightBeNotDefined()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$container->expects($this->atLeastOnce()) $container->expects($this->atLeastOnce())
->method('findTaggedServiceIds') ->method('findTaggedServiceIds')

View File

@ -20,14 +20,11 @@ class AddConstraintValidatorsPassTest extends \PHPUnit_Framework_TestCase
'my_constraint_validator_service2' => array(), 'my_constraint_validator_service2' => array(),
); );
$validatorFactoryDefinition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $validatorFactoryDefinition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
);
$validatorDefinition1 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass')); $validatorDefinition1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
$validatorDefinition2 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass')); $validatorDefinition2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
$validatorDefinition1->expects($this->atLeastOnce()) $validatorDefinition1->expects($this->atLeastOnce())
->method('getClass') ->method('getClass')
@ -67,11 +64,8 @@ class AddConstraintValidatorsPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition() public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$container->expects($this->never())->method('findTaggedServiceIds'); $container->expects($this->never())->method('findTaggedServiceIds');
$container->expects($this->never())->method('getDefinition'); $container->expects($this->never())->method('getDefinition');

View File

@ -33,15 +33,12 @@ class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(), 'my_content_renderer' => array(),
); );
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce()) $definition->expects($this->atLeastOnce())
->method('getClass') ->method('getClass')
->will($this->returnValue('stdClass')); ->will($this->returnValue('stdClass'));
$builder = $this->getMock( $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any()) $builder->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -65,22 +62,19 @@ class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(), 'my_content_renderer' => array(),
); );
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$renderer $renderer
->expects($this->once()) ->expects($this->once())
->method('addMethodCall') ->method('addMethodCall')
->with('addRenderer', array(new Reference('my_content_renderer'))) ->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()) $definition->expects($this->atLeastOnce())
->method('getClass') ->method('getClass')
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService')); ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\RendererService'));
$builder = $this->getMock( $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any()) $builder->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -17,9 +17,9 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
{ {
public function testProcess() public function testProcess()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface'); $parameterBag = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface')->getMock();
$container->expects($this->exactly(2)) $container->expects($this->exactly(2))
->method('hasAlias') ->method('hasAlias')
@ -60,7 +60,7 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition() public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->once()) $container->expects($this->once())
->method('hasAlias') ->method('hasAlias')
->will($this->returnValue(false)); ->will($this->returnValue(false));
@ -71,7 +71,7 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition() public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$container->expects($this->at(0)) $container->expects($this->at(0))
->method('hasAlias') ->method('hasAlias')
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -75,10 +75,7 @@ class ProfilerPassTest extends \PHPUnit_Framework_TestCase
private function createContainerMock($services) private function createContainerMock($services)
{ {
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'setParameter')
);
$container->expects($this->any()) $container->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->with($this->equalTo('profiler')) ->with($this->equalTo('profiler'))

View File

@ -23,7 +23,7 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
{ {
public function testThrowExceptionWhenNoNormalizers() 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()) $container->expects($this->once())
->method('hasDefinition') ->method('hasDefinition')
@ -43,11 +43,8 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
public function testThrowExceptionWhenNoEncoders() public function testThrowExceptionWhenNoEncoders()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$container->expects($this->once()) $container->expects($this->once())
->method('hasDefinition') ->method('hasDefinition')
@ -85,7 +82,7 @@ class SerializerPassTest extends \PHPUnit_Framework_TestCase
new Reference('n3'), 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->atLeastOnce()) $container->expects($this->atLeastOnce())
->method('findTaggedServiceIds') ->method('findTaggedServiceIds')

View File

@ -18,7 +18,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
{ {
public function testValidCollector() public function testValidCollector()
{ {
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->at(0)) $definition->expects($this->at(0))
->method('addMethodCall') ->method('addMethodCall')
->with('addLoader', array('xliff', new Reference('xliff'))); ->with('addLoader', array('xliff', new Reference('xliff')));
@ -26,10 +26,7 @@ class TranslatorPassTest extends \PHPUnit_Framework_TestCase
->method('addMethodCall') ->method('addMethodCall')
->with('addLoader', array('xlf', new Reference('xliff'))); ->with('addLoader', array('xlf', new Reference('xliff')));
$container = $this->getMock( $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'getDefinition', 'findTaggedServiceIds', 'findDefinition')
);
$container->expects($this->any()) $container->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->will($this->returnValue(true)); ->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'))))); ->will($this->returnValue(array('xliff' => array(array('alias' => 'xliff', 'legacy-alias' => 'xlf')))));
$container->expects($this->once()) $container->expects($this->once())
->method('findDefinition') ->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 = new TranslatorPass();
$pass->process($container); $pass->process($container);
} }

View File

@ -22,7 +22,7 @@ class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase
{ {
public function testRender() public function testRender()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->once()) $container->expects($this->once())
->method('get') ->method('get')
->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock())) ->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock()))

View File

@ -214,7 +214,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
*/ */
private function getServiceContainer(RouteCollection $routes) private function getServiceContainer(RouteCollection $routes)
{ {
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
@ -222,7 +222,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($routes)) ->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 $sc
->expects($this->once()) ->expects($this->once())

View File

@ -85,7 +85,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getEngineMock($template, $supports) private function getEngineMock($template, $supports)
{ {
$engine = $this->getMock('Symfony\Component\Templating\EngineInterface'); $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
$engine->expects($this->once()) $engine->expects($this->once())
->method('supports') ->method('supports')
@ -97,7 +97,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getFrameworkEngineMock($template, $supports) 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()) $engine->expects($this->once())
->method('supports') ->method('supports')
@ -109,7 +109,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getContainerMock($services) private function getContainerMock($services)
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$i = 0; $i = 0;
foreach ($services as $id => $service) { foreach ($services as $id => $service) {

View File

@ -31,7 +31,7 @@ class GlobalVariablesTest extends TestCase
*/ */
public function testLegacyGetSecurity() 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->assertNull($this->globals->getSecurity());
$this->container->set('security.context', $securityContext); $this->container->set('security.context', $securityContext);
@ -45,7 +45,7 @@ class GlobalVariablesTest extends TestCase
public function testGetUserNoToken() 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->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getUser()); $this->assertNull($this->globals->getUser());
} }
@ -55,8 +55,8 @@ class GlobalVariablesTest extends TestCase
*/ */
public function testGetUser($user, $expectedUser) public function testGetUser($user, $expectedUser)
{ {
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage); $this->container->set('security.token_storage', $tokenStorage);
@ -75,9 +75,9 @@ class GlobalVariablesTest extends TestCase
public function getUserProvider() 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(); $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( return array(
array($user, $user), array($user, $user),

View File

@ -17,7 +17,7 @@ class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
{ {
public function testDevEnvironment() public function testDevEnvironment()
{ {
$stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch'); $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('start') ->method('start')
->with('foo'); ->with('foo');

View File

@ -22,7 +22,7 @@ class TemplateNameParserTest extends TestCase
protected function setUp() protected function setUp()
{ {
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')

View File

@ -44,7 +44,7 @@ class TimedPhpEngineTest extends TestCase
*/ */
private function getContainer() 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() private function getTemplateNameParser()
{ {
$templateReference = $this->getMock('Symfony\Component\Templating\TemplateReferenceInterface'); $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock();
$templateNameParser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any()) $templateNameParser->expects($this->any())
->method('parse') ->method('parse')
->will($this->returnValue($templateReference)); ->will($this->returnValue($templateReference));
@ -111,6 +111,6 @@ class TimedPhpEngineTest extends TestCase
*/ */
private function getStopwatch() private function getStopwatch()
{ {
return $this->getMock('Symfony\Component\Stopwatch\Stopwatch'); return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
} }
} }

View File

@ -76,7 +76,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
// do it another time as the cache is primed now // 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'); $loader->expects($this->never())->method('load');
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
@ -96,7 +96,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function testTransWithCachingWithInvalidLocale() 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 = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
$translator->setLocale('invalid locale'); $translator->setLocale('invalid locale');
@ -121,7 +121,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function testGetDefaultLocale() public function testGetDefaultLocale()
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->once()) ->expects($this->once())
->method('getParameter') ->method('getParameter')
@ -149,7 +149,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
protected function getLoader() protected function getLoader()
{ {
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader $loader
->expects($this->at(0)) ->expects($this->at(0))
->method('load') ->method('load')
@ -207,7 +207,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
protected function getContainer($loader) protected function getContainer($loader)
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container $container
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
@ -248,7 +248,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$translator->setFallbackLocales(array('fr')); $translator->setFallbackLocales(array('fr'));
$translator->warmup($this->tmpDir); $translator->warmup($this->tmpDir);
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$loader $loader
->expects($this->never()) ->expects($this->never())
->method('load'); ->method('load');

View File

@ -21,7 +21,7 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
{ {
$class = get_class($this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator')); $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 $constraint
->expects($this->once()) ->expects($this->once())
->method('validatedBy') ->method('validatedBy')
@ -46,14 +46,14 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
$validator = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator'); $validator = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintValidator');
// mock ContainerBuilder b/c it implements TaggedContainerInterface // 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 $container
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with($service) ->with($service)
->will($this->returnValue($validator)); ->will($this->returnValue($validator));
$constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint'); $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint $constraint
->expects($this->once()) ->expects($this->once())
->method('validatedBy') ->method('validatedBy')
@ -68,7 +68,7 @@ class ConstraintValidatorFactoryTest extends \PHPUnit_Framework_TestCase
*/ */
public function testGetInstanceInvalidValidatorClass() public function testGetInstanceInvalidValidatorClass()
{ {
$constraint = $this->getMock('Symfony\\Component\\Validator\\Constraint'); $constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint $constraint
->expects($this->once()) ->expects($this->once())
->method('validatedBy') ->method('validatedBy')

View File

@ -54,7 +54,7 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLegacyCollectWhenAuthenticationTokenIsNull() 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 = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
$collector->collect($this->getRequest(), $this->getResponse()); $collector->collect($this->getRequest(), $this->getResponse());

View File

@ -28,7 +28,7 @@ class PreviewErrorControllerTest extends TestCase
$code = 123; $code = 123;
$logicalControllerName = 'foo:bar:baz'; $logicalControllerName = 'foo:bar:baz';
$kernel = $this->getMock('\Symfony\Component\HttpKernel\HttpKernelInterface'); $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel $kernel
->expects($this->once()) ->expects($this->once())
->method('handle') ->method('handle')

View File

@ -31,10 +31,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->builder = $this->getMock( $this->builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'setAlias', 'getDefinition')
);
$this->chainLoader = new Definition('loader'); $this->chainLoader = new Definition('loader');
$this->pass = new TwigLoaderPass(); $this->pass = new TwigLoaderPass();
} }

View File

@ -84,7 +84,7 @@ class LegacyAssetsExtensionTest extends TestCase
private function createContainerMock($helper) private function createContainerMock($helper)
{ {
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->any()) $container->expects($this->any())
->method('get') ->method('get')
->with('templating.helper.assets') ->with('templating.helper.assets')

View File

@ -19,8 +19,8 @@ class FilesystemLoaderTest extends TestCase
{ {
public function testGetSourceContext() public function testGetSourceContext()
{ {
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
@ -39,8 +39,8 @@ class FilesystemLoaderTest extends TestCase
public function testExists() public function testExists()
{ {
// should return true for templates that Twig does not find, but Symfony does // should return true for templates that Twig does not find, but Symfony does
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
@ -56,7 +56,7 @@ class FilesystemLoaderTest extends TestCase
*/ */
public function testTwigErrorIfLocatorThrowsInvalid() public function testTwigErrorIfLocatorThrowsInvalid()
{ {
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$parser $parser
->expects($this->once()) ->expects($this->once())
->method('parse') ->method('parse')
@ -64,7 +64,7 @@ class FilesystemLoaderTest extends TestCase
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
; ;
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
@ -80,7 +80,7 @@ class FilesystemLoaderTest extends TestCase
*/ */
public function testTwigErrorIfLocatorReturnsFalse() public function testTwigErrorIfLocatorReturnsFalse()
{ {
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$parser $parser
->expects($this->once()) ->expects($this->once())
->method('parse') ->method('parse')
@ -88,7 +88,7 @@ class FilesystemLoaderTest extends TestCase
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine')))
; ;
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
@ -105,8 +105,8 @@ class FilesystemLoaderTest extends TestCase
*/ */
public function testTwigErrorIfTemplateDoesNotExist() public function testTwigErrorIfTemplateDoesNotExist()
{ {
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views');
@ -118,8 +118,8 @@ class FilesystemLoaderTest extends TestCase
public function testTwigSoftErrorIfTemplateDoesNotExist() public function testTwigSoftErrorIfTemplateDoesNotExist()
{ {
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface'); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface'); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views');

View File

@ -25,7 +25,7 @@ class LegacyRenderTokenParserTest extends TestCase
*/ */
public function testCompile($source, $expected) 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()); $env->addTokenParser(new RenderTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, '')); $stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env); $parser = new \Twig_Parser($env);

View File

@ -22,7 +22,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
*/ */
public function testEmptyToken($token) 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(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
@ -46,7 +46,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testReturns404onTokenNotFound() 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(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
@ -74,7 +74,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testSearchResult() 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(); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')

View File

@ -46,7 +46,7 @@ class WebProfilerExtensionTest extends TestCase
{ {
parent::setUp(); 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 = new ContainerBuilder();
$this->container->addScope(new Scope('request')); $this->container->addScope(new Scope('request'));

View File

@ -246,11 +246,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true)
{ {
$request = $this->getMock( $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock();
'Symfony\Component\HttpFoundation\Request',
array('getSession', 'isXmlHttpRequest', 'getRequestFormat'),
array(), '', false
);
$request->expects($this->any()) $request->expects($this->any())
->method('isXmlHttpRequest') ->method('isXmlHttpRequest')
->will($this->returnValue($isXmlHttpRequest)); ->will($this->returnValue($isXmlHttpRequest));
@ -259,7 +255,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($requestFormat)); ->will($this->returnValue($requestFormat));
if ($hasSession) { 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()) $request->expects($this->any())
->method('getSession') ->method('getSession')
->will($this->returnValue($session)); ->will($this->returnValue($session));
@ -270,7 +266,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getTwigMock($render = 'WDT') protected function getTwigMock($render = 'WDT')
{ {
$templating = $this->getMock('Twig_Environment', array(), array(), '', false); $templating = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$templating->expects($this->any()) $templating->expects($this->any())
->method('render') ->method('render')
->will($this->returnValue($render)); ->will($this->returnValue($render));
@ -280,11 +276,11 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
protected function getUrlGeneratorMock() protected function getUrlGeneratorMock()
{ {
return $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
} }
protected function getKernelMock() protected function getKernelMock()
{ {
return $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false); return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
} }
} }

View File

@ -136,9 +136,9 @@ class TemplateManagerTest extends TestCase
->will($this->returnValue('loadedTemplate')); ->will($this->returnValue('loadedTemplate'));
if (interface_exists('\Twig_SourceContextLoaderInterface')) { if (interface_exists('\Twig_SourceContextLoaderInterface')) {
$loader = $this->getMock('\Twig_SourceContextLoaderInterface'); $loader = $this->getMockBuilder('\Twig_SourceContextLoaderInterface')->getMock();
} else { } else {
$loader = $this->getMock('\Twig_LoaderInterface'); $loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock();
} }
$this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));

View File

@ -17,7 +17,7 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
{ {
public function testGetBasePathEmpty() public function testGetBasePathEmpty()
{ {
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackContext = new RequestStackContext($requestStack); $requestStackContext = new RequestStackContext($requestStack);
$this->assertEmpty($requestStackContext->getBasePath()); $this->assertEmpty($requestStackContext->getBasePath());
@ -27,10 +27,10 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
{ {
$testBasePath = 'test-path'; $testBasePath = 'test-path';
$request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('getBasePath') $request->method('getBasePath')
->willReturn($testBasePath); ->willReturn($testBasePath);
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->method('getMasterRequest') $requestStack->method('getMasterRequest')
->willReturn($request); ->willReturn($request);
@ -41,7 +41,7 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
public function testIsSecureFalse() public function testIsSecureFalse()
{ {
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackContext = new RequestStackContext($requestStack); $requestStackContext = new RequestStackContext($requestStack);
$this->assertFalse($requestStackContext->isSecure()); $this->assertFalse($requestStackContext->isSecure());
@ -49,10 +49,10 @@ class RequestStackContextTest extends \PHPUnit_Framework_TestCase
public function testIsSecureTrue() public function testIsSecureTrue()
{ {
$request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('isSecure') $request->method('isSecure')
->willReturn(true); ->willReturn(true);
$requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->method('getMasterRequest') $requestStack->method('getMasterRequest')
->willReturn($request); ->willReturn($request);

View File

@ -20,8 +20,8 @@ class PackagesTest extends \PHPUnit_Framework_TestCase
public function testGetterSetters() public function testGetterSetters()
{ {
$packages = new Packages(); $packages = new Packages();
$packages->setDefaultPackage($default = $this->getMock('Symfony\Component\Asset\PackageInterface')); $packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
$packages->addPackage('a', $a = $this->getMock('Symfony\Component\Asset\PackageInterface')); $packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
$this->assertEquals($default, $packages->getPackage()); $this->assertEquals($default, $packages->getPackage());
$this->assertEquals($a, $packages->getPackage('a')); $this->assertEquals($a, $packages->getPackage('a'));

View File

@ -76,7 +76,7 @@ class PathPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($basePath) 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)); $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath));
return $context; return $context;

View File

@ -94,7 +94,7 @@ class UrlPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($secure) 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)); $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure));
return $context; return $context;

View File

@ -33,12 +33,12 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
public function testSupports() 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)); $loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $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)); $loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1))); $loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); $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() 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('supports')->will($this->returnValue(true));
$loader->expects($this->once())->method('load'); $loader->expects($this->once())->method('load');
$resolver = new LoaderResolver(array($loader)); $resolver = new LoaderResolver(array($loader));
@ -60,7 +60,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() 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)); $loader->expects($this->once())->method('supports')->will($this->returnValue(false));
$resolver = new LoaderResolver(array($loader)); $resolver = new LoaderResolver(array($loader));
$loader = new DelegatingLoader($resolver); $loader = new DelegatingLoader($resolver);

View File

@ -18,9 +18,9 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
{ {
public function testImportWithFileLocatorDelegation() 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( $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
array('path/to/file1'), // Default array('path/to/file1'), // Default
array('path/to/file1', 'path/to/file2'), // First is imported array('path/to/file1', 'path/to/file2'), // First is imported

View File

@ -18,7 +18,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testConstructor() public function testConstructor()
{ {
$resolver = new LoaderResolver(array( $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'); $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() 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)); $resolver = new LoaderResolver(array($loader));
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $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)); $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$resolver = new LoaderResolver(array($loader)); $resolver = new LoaderResolver(array($loader));
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); $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() public function testLoaders()
{ {
$resolver = new LoaderResolver(); $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'); $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
} }

View File

@ -17,7 +17,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
{ {
public function testGetSetResolver() public function testGetSetResolver()
{ {
$resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$loader = new ProjectLoader1(); $loader = new ProjectLoader1();
$loader->setResolver($resolver); $loader->setResolver($resolver);
@ -27,9 +27,9 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testResolve() 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()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo.xml') ->with('foo.xml')
@ -47,7 +47,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
*/ */
public function testResolveWhenResolverCannotFindLoader() public function testResolveWhenResolverCannotFindLoader()
{ {
$resolver = $this->getMock('Symfony\Component\Config\Loader\LoaderResolverInterface'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('FOOBAR') ->with('FOOBAR')
@ -61,13 +61,13 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testImport() public function testImport()
{ {
$resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once()) $resolvedLoader->expects($this->once())
->method('load') ->method('load')
->with('foo') ->with('foo')
->will($this->returnValue('yes')); ->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()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo') ->with('foo')
@ -81,13 +81,13 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testImportWithType() public function testImportWithType()
{ {
$resolvedLoader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once()) $resolvedLoader->expects($this->once())
->method('load') ->method('load')
->with('foo', 'bar') ->with('foo', 'bar')
->will($this->returnValue('yes')); ->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()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo', 'bar') ->with('foo', 'bar')

View File

@ -47,7 +47,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
$this->assertContains('XSD file or callable', $e->getMessage()); $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)); $mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true));
try { try {

View File

@ -447,7 +447,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() 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()) $application->expects($this->once())
->method('getNamespaces') ->method('getNamespaces')
->will($this->returnValue(array('foo:sublong', 'bar:sub'))); ->will($this->returnValue(array('foo:sublong', 'bar:sub')));
@ -469,7 +469,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testSetCatchExceptions() 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->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
@ -516,7 +516,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderException() 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->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
@ -540,7 +540,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); $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'); $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->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
@ -556,7 +556,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
*/ */
public function testRenderExceptionWithDoubleWidthCharacters() 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->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
@ -572,7 +572,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo'), array('decorated' => true)); $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'); $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->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
@ -706,7 +706,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{ {
$exception = new \Exception('', 4); $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->setAutoExit(false);
$application->expects($this->once()) $application->expects($this->once())
->method('doRun') ->method('doRun')
@ -721,7 +721,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{ {
$exception = new \Exception('', 0); $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->setAutoExit(false);
$application->expects($this->once()) $application->expects($this->once())
->method('doRun') ->method('doRun')

View File

@ -273,7 +273,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$exitCode = $command->run(new StringInput(''), new NullOutput()); $exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); $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()) $command->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue('2.3')); ->will($this->returnValue('2.3'));

View File

@ -109,7 +109,7 @@ class HelperSetTest extends \PHPUnit_Framework_TestCase
private function getGenericMockHelper($name, HelperSet $helperset = null) 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()) $mock_helper->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($name)); ->will($this->returnValue($name));

View File

@ -142,7 +142,7 @@ class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency() 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)) $progress->expects($this->exactly(4))
->method('display'); ->method('display');

View File

@ -294,7 +294,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency() 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->expects($this->exactly(4))->method('display');
$bar->setRedrawFrequency(2); $bar->setRedrawFrequency(2);
@ -307,7 +307,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven() 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->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0); $bar->setRedrawFrequency(0);
@ -317,7 +317,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven() 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->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0.9); $bar->setRedrawFrequency(0.9);

View File

@ -388,7 +388,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
' [<info>żółw </info>] bar', ' [<info>żółw </info>] bar',
' [<info>łabądź</info>] baz', ' [<info>łabądź</info>] baz',
); );
$output = $this->getMock('\Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
$output->method('getFormatter')->willReturn(new OutputFormatter()); $output->method('getFormatter')->willReturn(new OutputFormatter());
$dialog = new QuestionHelper(); $dialog = new QuestionHelper();
@ -449,7 +449,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
protected function createInputInterfaceMock($interactive = true) 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()) $mock->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue($interactive)); ->will($this->returnValue($interactive));

View File

@ -132,7 +132,7 @@ class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
protected function createInputInterfaceMock($interactive = true) 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()) $mock->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue($interactive)); ->will($this->returnValue($interactive));

View File

@ -133,7 +133,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
try { try {
$handler = ErrorHandler::register(); $handler = ErrorHandler::register();
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler->setDefaultLogger($logger, E_NOTICE); $handler->setDefaultLogger($logger, E_NOTICE);
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL)); $handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
@ -212,7 +212,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler(); restore_error_handler();
restore_exception_handler(); restore_exception_handler();
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this; $that = $this;
$warnArgCheck = function ($logLevel, $message, $context) use ($that) { $warnArgCheck = function ($logLevel, $message, $context) use ($that) {
@ -237,7 +237,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler(); restore_error_handler();
restore_exception_handler(); restore_exception_handler();
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this; $that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) { $logArgCheck = function ($level, $message, $context) use ($that) {
@ -278,7 +278,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$that->assertArrayHasKey('stack', $context); $that->assertArrayHasKey('stack', $context);
}; };
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
@ -297,7 +297,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$exception = new \Exception('foo'); $exception = new \Exception('foo');
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this; $that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) { $logArgCheck = function ($level, $message, $context) use ($that) {
@ -344,7 +344,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$handler = ErrorHandler::register(); $handler = ErrorHandler::register();
$handler->screamAt(E_USER_WARNING); $handler->screamAt(E_USER_WARNING);
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger $logger
->expects($this->exactly(2)) ->expects($this->exactly(2))
@ -384,7 +384,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
'line' => 123, 'line' => 123,
); );
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this; $that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) { $logArgCheck = function ($level, $message, $context) use ($that) {
@ -436,7 +436,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
try { try {
$handler = ErrorHandler::register(); $handler = ErrorHandler::register();
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
@ -489,7 +489,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
restore_error_handler(); restore_error_handler();
restore_exception_handler(); restore_exception_handler();
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$that = $this; $that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) { $logArgCheck = function ($level, $message, $context) use ($that) {

View File

@ -100,7 +100,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{ {
$exception = new \Exception('foo'); $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 $handler
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('sendPhpResponse'); ->method('sendPhpResponse');
@ -119,7 +119,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{ {
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__); $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 $handler
->expects($this->once()) ->expects($this->once())
->method('sendPhpResponse'); ->method('sendPhpResponse');

View File

@ -23,7 +23,7 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$this->pass = new ExtensionCompilerPass(); $this->pass = new ExtensionCompilerPass();
} }
@ -46,10 +46,10 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
private function createExtensionMock($hasInlineCompile) private function createExtensionMock($hasInlineCompile)
{ {
return $this->getMock('Symfony\Component\DependencyInjection\\'.( return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
$hasInlineCompile $hasInlineCompile
? 'Compiler\CompilerPassInterface' ? 'Compiler\CompilerPassInterface'
: 'Extension\ExtensionInterface' : 'Extension\ExtensionInterface'
)); ))->getMock();
} }
} }

View File

@ -21,7 +21,7 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
{ {
$tmpProviders = array(); $tmpProviders = array();
$extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface'); $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->any()) $extension->expects($this->any())
->method('getXsdValidationBasePath') ->method('getXsdValidationBasePath')
->will($this->returnValue(false)); ->will($this->returnValue(false));
@ -37,7 +37,7 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
$tmpProviders = $container->getExpressionLanguageProviders(); $tmpProviders = $container->getExpressionLanguageProviders();
})); }));
$provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface'); $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
$container = new ContainerBuilder(new ParameterBag()); $container = new ContainerBuilder(new ParameterBag());
$container->registerExtension($extension); $container->registerExtension($extension);
$container->prependExtensionConfig('foo', array('bar' => true)); $container->prependExtensionConfig('foo', array('bar' => true));

View File

@ -249,7 +249,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$builder = new ContainerBuilder(); $builder = new ContainerBuilder();
$builder->setResourceTracking(false); $builder->setResourceTracking(false);
$builderCompilerPasses = $builder->getCompiler()->getPassConfig()->getPasses(); $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); $this->assertCount(count($builder->getCompiler()->getPassConfig()->getPasses()) - 1, $builderCompilerPasses);
} }
@ -620,7 +620,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredButNotLoadedExtension() 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->once())->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->never())->method('load'); $extension->expects($this->never())->method('load');
@ -632,7 +632,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredAndLoadedExtension() 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->exactly(2))->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->once())->method('load')->with(array(array('foo' => 'bar'))); $extension->expects($this->once())->method('load')->with(array(array('foo' => 'bar')));

View File

@ -25,7 +25,7 @@ class RealServiceInstantiatorTest extends \PHPUnit_Framework_TestCase
{ {
$instantiator = new RealServiceInstantiator(); $instantiator = new RealServiceInstantiator();
$instance = new \stdClass(); $instance = new \stdClass();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$callback = function () use ($instance) { $callback = function () use ($instance) {
return $instance; return $instance;
}; };

View File

@ -30,7 +30,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{ {
$event = new Event(); $event = new Event();
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service $service
->expects($this->once()) ->expects($this->once())
@ -51,7 +51,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{ {
$event = new Event(); $event = new Event();
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock();
$service $service
->expects($this->once()) ->expects($this->once())
@ -86,7 +86,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{ {
$event = new Event(); $event = new Event();
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service $service
->expects($this->once()) ->expects($this->once())
@ -109,7 +109,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
*/ */
public function testTriggerAListenerServiceOutOfScope() public function testTriggerAListenerServiceOutOfScope()
{ {
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$scope = new Scope('scope'); $scope = new Scope('scope');
$container = new Container(); $container = new Container();
@ -129,7 +129,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{ {
$event = new Event(); $event = new Event();
$service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service1 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service1 $service1
->expects($this->exactly(2)) ->expects($this->exactly(2))
@ -148,7 +148,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
$dispatcher->dispatch('onEvent', $event); $dispatcher->dispatch('onEvent', $event);
$service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service2 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$service2 $service2
->expects($this->once()) ->expects($this->once())
@ -170,7 +170,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
{ {
$event = new Event(); $event = new Event();
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container(); $container = new Container();
$container->set('service.listener', $service); $container->set('service.listener', $service);
@ -196,7 +196,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testGetListenersOnLazyLoad() public function testGetListenersOnLazyLoad()
{ {
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container(); $container = new Container();
$container->set('service.listener', $service); $container->set('service.listener', $service);
@ -213,7 +213,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testRemoveAfterDispatch() public function testRemoveAfterDispatch()
{ {
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container(); $container = new Container();
$container->set('service.listener', $service); $container->set('service.listener', $service);
@ -228,7 +228,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
public function testRemoveBeforeDispatch() public function testRemoveBeforeDispatch()
{ {
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
$container = new Container(); $container = new Container();
$container->set('service.listener', $service); $container->set('service.listener', $service);

View File

@ -103,7 +103,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLogger() public function testLogger()
{ {
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$dispatcher = new EventDispatcher(); $dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
@ -118,7 +118,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
public function testLoggerWithStoppedEvent() public function testLoggerWithStoppedEvent()
{ {
$logger = $this->getMock('Psr\Log\LoggerInterface'); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$dispatcher = new EventDispatcher(); $dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);

View File

@ -29,7 +29,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
'my_event_subscriber' => array(0 => array()), '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()) $definition->expects($this->atLeastOnce())
->method('isPublic') ->method('isPublic')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -37,10 +37,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
->method('getClass') ->method('getClass')
->will($this->returnValue('stdClass')); ->will($this->returnValue('stdClass'));
$builder = $this->getMock( $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder->expects($this->any()) $builder->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -64,7 +61,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
'my_event_subscriber' => array(0 => array()), '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()) $definition->expects($this->atLeastOnce())
->method('isPublic') ->method('isPublic')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -72,10 +69,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
->method('getClass') ->method('getClass')
->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'));
$builder = $this->getMock( $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition'))->getMock();
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition')
);
$builder->expects($this->any()) $builder->expects($this->any())
->method('hasDefinition') ->method('hasDefinition')
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -31,7 +31,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
protected function setUp() 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); $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
} }
@ -80,7 +80,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/ */
public function testAddSubscriberDisallowed() public function testAddSubscriberDisallowed()
{ {
$subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->addSubscriber($subscriber); $this->dispatcher->addSubscriber($subscriber);
} }
@ -98,7 +98,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/ */
public function testRemoveSubscriberDisallowed() public function testRemoveSubscriberDisallowed()
{ {
$subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->removeSubscriber($subscriber); $this->dispatcher->removeSubscriber($subscriber);
} }

View File

@ -18,7 +18,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
{ {
public function testCachedParse() public function testCachedParse()
{ {
$cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface'); $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$savedParsedExpression = null; $savedParsedExpression = null;
$expressionLanguage = new ExpressionLanguage($cacheMock); $expressionLanguage = new ExpressionLanguage($cacheMock);
@ -116,7 +116,7 @@ class ExpressionLanguageTest extends \PHPUnit_Framework_TestCase
public function testCachingWithDifferentNamesOrder() public function testCachingWithDifferentNamesOrder()
{ {
$cacheMock = $this->getMock('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface'); $cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock); $expressionLanguage = new ExpressionLanguage($cacheMock);
$savedParsedExpressions = array(); $savedParsedExpressions = array();
$cacheMock $cacheMock

View File

@ -37,7 +37,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
// We need an actual dispatcher to use the deprecated // We need an actual dispatcher to use the deprecated
// bindRequest() method // bindRequest() method
$this->dispatcher = new EventDispatcher(); $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(); $this->form = $this->createForm();
} }
@ -73,8 +73,8 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/ */
protected function getMockForm($name = 'name') protected function getMockForm($name = 'name')
{ {
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
$form->expects($this->any()) $form->expects($this->any())
->method('getName') ->method('getName')
@ -91,7 +91,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/ */
protected function getDataMapper() 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() 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() protected function getFormValidator()
{ {
return $this->getMock('Symfony\Component\Form\FormValidatorInterface'); return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock();
} }
} }

View File

@ -28,7 +28,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
\Locale::setDefault('en'); \Locale::setDefault('en');
$this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); $this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
parent::setUp(); parent::setUp();
} }

View File

@ -37,10 +37,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->serverParams = $this->getMock( $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock();
'Symfony\Component\Form\Util\ServerParams',
array('getNormalizedIniPostMaxSize', 'getContentLength')
);
$this->requestHandler = $this->getRequestHandler(); $this->requestHandler = $this->getRequestHandler();
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory(); $this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
$this->request = null; $this->request = null;
@ -363,7 +360,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm($name, $method = null, $compound = true) 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()) $config->expects($this->any())
->method('getMethod') ->method('getMethod')
->will($this->returnValue($method)); ->will($this->returnValue($method));
@ -371,7 +368,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
->method('getCompound') ->method('getCompound')
->will($this->returnValue($compound)); ->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()) $form->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($name)); ->will($this->returnValue($name));

View File

@ -25,8 +25,8 @@ class ButtonTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
} }
/** /**

View File

@ -30,7 +30,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
protected function setUp() 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); $this->factory = new CachingFactoryDecorator($this->decoratedFactory);
} }
@ -295,7 +295,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderSameLoader() 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(); $list = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -309,8 +309,8 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderDifferentLoader() public function testCreateFromLoaderDifferentLoader()
{ {
$loader1 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); $loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$loader2 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); $loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$list1 = new \stdClass(); $list1 = new \stdClass();
$list2 = new \stdClass(); $list2 = new \stdClass();
@ -329,7 +329,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderSameValueClosure() 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(); $list = new \stdClass();
$closure = function () {}; $closure = function () {};
@ -344,7 +344,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderDifferentValueClosure() 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(); $list1 = new \stdClass();
$list2 = new \stdClass(); $list2 = new \stdClass();
$closure1 = function () {}; $closure1 = function () {};
@ -366,7 +366,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSamePreferredChoices() public function testCreateViewSamePreferredChoices()
{ {
$preferred = array('a'); $preferred = array('a');
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -382,7 +382,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$preferred1 = array('a'); $preferred1 = array('a');
$preferred2 = array('b'); $preferred2 = array('b');
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -402,7 +402,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSamePreferredChoicesClosure() public function testCreateViewSamePreferredChoicesClosure()
{ {
$preferred = function () {}; $preferred = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -418,7 +418,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$preferred1 = function () {}; $preferred1 = function () {};
$preferred2 = function () {}; $preferred2 = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -438,7 +438,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameLabelClosure() public function testCreateViewSameLabelClosure()
{ {
$labels = function () {}; $labels = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -454,7 +454,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$labels1 = function () {}; $labels1 = function () {};
$labels2 = function () {}; $labels2 = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -474,7 +474,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameIndexClosure() public function testCreateViewSameIndexClosure()
{ {
$index = function () {}; $index = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -490,7 +490,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$index1 = function () {}; $index1 = function () {};
$index2 = function () {}; $index2 = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -510,7 +510,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameGroupByClosure() public function testCreateViewSameGroupByClosure()
{ {
$groupBy = function () {}; $groupBy = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -526,7 +526,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$groupBy1 = function () {}; $groupBy1 = function () {};
$groupBy2 = function () {}; $groupBy2 = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -546,7 +546,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameAttributes() public function testCreateViewSameAttributes()
{ {
$attr = array('class' => 'foobar'); $attr = array('class' => 'foobar');
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -562,7 +562,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$attr1 = array('class' => 'foobar1'); $attr1 = array('class' => 'foobar1');
$attr2 = array('class' => 'foobar2'); $attr2 = array('class' => 'foobar2');
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();
@ -582,7 +582,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewSameAttributesClosure() public function testCreateViewSameAttributesClosure()
{ {
$attr = function () {}; $attr = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view = new \stdClass(); $view = new \stdClass();
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
@ -598,7 +598,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$attr1 = function () {}; $attr1 = function () {};
$attr2 = function () {}; $attr2 = function () {};
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$view1 = new \stdClass(); $view1 = new \stdClass();
$view2 = new \stdClass(); $view2 = new \stdClass();

View File

@ -332,7 +332,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoader() 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); $list = $this->factory->createListFromLoader($loader);
@ -341,7 +341,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderWithValues() public function testCreateFromLoaderWithValues()
{ {
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$value = function () {}; $value = function () {};
$list = $this->factory->createListFromLoader($loader, $value); $list = $this->factory->createListFromLoader($loader, $value);
@ -771,7 +771,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$preferred = array(new LegacyChoiceView('x', 'x', 'Preferred')); $preferred = array(new LegacyChoiceView('x', 'x', 'Preferred'));
$other = array(new LegacyChoiceView('y', 'y', 'Other')); $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()) $list->expects($this->once())
->method('getPreferredViews') ->method('getPreferredViews')
@ -798,7 +798,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
new LegacyChoiceView('z', 'z', 'Other one'), 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()) $list->expects($this->once())
->method('getPreferredViews') ->method('getPreferredViews')

View File

@ -31,7 +31,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
protected function setUp() 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); $this->factory = new PropertyAccessDecorator($this->decoratedFactory);
} }
@ -84,7 +84,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
@ -114,7 +114,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494 // https://github.com/symfony/symfony/issues/5494
public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable() 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()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
@ -128,7 +128,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
@ -142,7 +142,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -159,7 +159,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -177,7 +177,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494 // https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -194,7 +194,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -212,7 +212,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -230,7 +230,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -249,7 +249,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -268,7 +268,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -288,7 +288,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -309,7 +309,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494 // https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -329,7 +329,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPath() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
@ -350,7 +350,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPathInstance() 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()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')

View File

@ -37,8 +37,8 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->innerList = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); $this->innerList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface'); $this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->value = function () {}; $this->value = function () {};
$this->list = new LazyChoiceList($this->loader, $this->value); $this->list = new LazyChoiceList($this->loader, $this->value);
} }

Some files were not shown because too many files have changed in this diff Show More