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

View File

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

View File

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

View File

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

View File

@ -86,10 +86,10 @@ class DoctrineOrmTypeGuesserTest extends \PHPUnit_Framework_TestCase
private function getGuesser(ClassMetadata $classMetadata)
{
$em = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em)));
return new DoctrineOrmTypeGuesser($registry);

View File

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

View File

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

View File

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

View File

@ -150,7 +150,7 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
private function getManager($em, $name = null)
{
$manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$manager->expects($this->any())
->method('getManager')
->with($this->equalTo($name))

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetSession()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
$request->method('getSession')->willReturn($session = new Session());
$this->setRequestStack($request);
@ -69,7 +69,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUser()
{
$this->setTokenStorage($user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
$this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$this->assertEquals($user, $this->appVariable->getUser());
}
@ -83,7 +83,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
public function testGetUserWithNoToken()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getUser());
@ -131,7 +131,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setRequestStack($request)
{
$requestStackMock = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
$requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStackMock->method('getCurrentRequest')->willReturn($request);
$this->appVariable->setRequestStack($requestStackMock);
@ -139,10 +139,10 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase
protected function setTokenStorage($user)
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->appVariable->setTokenStorage($tokenStorage);
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->method('getToken')->willReturn($token);
$token->method('getUser')->willReturn($user);

View File

@ -63,7 +63,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase
public function testDump($context, $args, $expectedOutput, $debug = true)
{
$extension = new DumpExtension(new VarCloner());
$twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
$twig = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
'debug' => $debug,
'cache' => false,
'optimizations' => 0,

View File

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

View File

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

View File

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

View File

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

View File

@ -51,7 +51,7 @@ class HttpKernelExtensionTest extends \PHPUnit_Framework_TestCase
protected function getFragmentHandler($return)
{
$strategy = $this->getMock('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface');
$strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock();
$strategy->expects($this->once())->method('getName')->will($this->returnValue('inline'));
$strategy->expects($this->once())->method('render')->will($return);

View File

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

View File

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

View File

@ -19,7 +19,7 @@ class DumpNodeTest extends \PHPUnit_Framework_TestCase
{
$node = new DumpNode('bar', null, 7);
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@ -43,7 +43,7 @@ EOTXT;
{
$node = new DumpNode('bar', null, 7);
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@ -70,7 +70,7 @@ EOTXT;
));
$node = new DumpNode('bar', $vars, 7);
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
@ -99,7 +99,7 @@ EOTXT;
));
$node = new DumpNode('bar', $vars, 7);
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'

View File

@ -41,7 +41,7 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase
$node = new FormThemeNode($form, $resources, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(

View File

@ -23,7 +23,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@ -46,7 +46,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@ -66,7 +66,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@ -86,7 +86,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -108,7 +108,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -129,7 +129,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@ -153,7 +153,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -182,7 +182,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
$this->assertEquals(
sprintf(
@ -210,7 +210,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -247,7 +247,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface')));
$compiler = new \Twig_Compiler(new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.

View File

@ -24,7 +24,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
$vars = new \Twig_Node_Expression_Name('foo', 0);
$node = new TransNode($body, null, null, $vars);
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true));
$compiler = new \Twig_Compiler($env);
$this->assertEquals(

View File

@ -22,7 +22,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(\Twig_Node $node)
{
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
@ -48,7 +48,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node)
{
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag

View File

@ -18,7 +18,7 @@ class TranslationNodeVisitorTest extends \PHPUnit_Framework_TestCase
/** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages)
{
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationNodeVisitor();
$visitor->enable();
$visitor->enterNode($node, $env);

View File

@ -21,7 +21,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase
*/
public function testCompile($source, $expected)
{
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env->addTokenParser(new FormThemeTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -147,7 +147,7 @@ class ControllerNameParserTest extends TestCase
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
);
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@ -178,7 +178,7 @@ class ControllerNameParserTest extends TestCase
private function getBundle($namespace, $name)
{
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));

View File

@ -175,12 +175,12 @@ class ControllerResolverTest extends BaseControllerResolverTest
protected function createMockParser()
{
return $this->getMock('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', array(), array(), '', false);
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock();
}
protected function createMockContainer()
{
return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
}
}

View File

@ -33,12 +33,12 @@ class ControllerTest extends TestCase
$requestStack = new RequestStack();
$requestStack->push($request);
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale());
}));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($requestStack));
$container->expects($this->at(1))->method('get')->will($this->returnValue($kernel));
@ -84,7 +84,7 @@ class ControllerTest extends TestCase
*/
public function testGetUserWithEmptyContainer()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
@ -104,13 +104,13 @@ class ControllerTest extends TestCase
*/
private function getContainerWithTokenStorage($token = null)
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock();
$tokenStorage
->expects($this->once())
->method('getToken')
->will($this->returnValue($token));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->once())
->method('has')
@ -128,10 +128,10 @@ class ControllerTest extends TestCase
public function testRedirectToRoute()
{
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo');
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new TestController();
@ -146,10 +146,10 @@ class ControllerTest extends TestCase
public function testAddFlash()
{
$flashBag = new FlashBag();
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session');
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($session));
@ -169,10 +169,10 @@ class ControllerTest extends TestCase
public function testIsCsrfTokenValid()
{
$tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
$tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($tokenManager));
@ -184,10 +184,10 @@ class ControllerTest extends TestCase
public function testGenerateUrl()
{
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo');
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new Controller();
@ -208,10 +208,10 @@ class ControllerTest extends TestCase
public function testRenderViewTemplating()
{
$templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$templating->expects($this->once())->method('render')->willReturn('bar');
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller();
@ -222,10 +222,10 @@ class ControllerTest extends TestCase
public function testRenderTemplating()
{
$templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$templating->expects($this->once())->method('renderResponse')->willReturn(new Response('bar'));
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller();
@ -236,9 +236,9 @@ class ControllerTest extends TestCase
public function testStreamTemplating()
{
$templating = $this->getMock('Symfony\Component\Routing\RouterInterface');
$templating = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($templating));
$controller = new Controller();
@ -256,12 +256,12 @@ class ControllerTest extends TestCase
public function testCreateForm()
{
$form = $this->getMock('Symfony\Component\Form\FormInterface');
$form = $this->getMockBuilder('Symfony\Component\Form\FormInterface')->getMock();
$formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$formFactory->expects($this->once())->method('create')->willReturn($form);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new Controller();
@ -272,12 +272,12 @@ class ControllerTest extends TestCase
public function testCreateFormBuilder()
{
$formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
$formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock();
$formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory));
$controller = new Controller();
@ -288,9 +288,9 @@ class ControllerTest extends TestCase
public function testGetDoctrine()
{
$doctrine = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
$doctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->at(0))->method('has')->will($this->returnValue(true));
$container->expects($this->at(1))->method('get')->will($this->returnValue($doctrine));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,7 +54,7 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCollectWhenAuthenticationTokenIsNull()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')->getMock();
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
$collector->collect($this->getRequest(), $this->getResponse());

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ class LegacyRenderTokenParserTest extends TestCase
*/
public function testCompile($source, $expected)
{
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env = new \Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$env->addTokenParser(new RenderTokenParser());
$stream = $env->tokenize(new \Twig_Source($source, ''));
$parser = new \Twig_Parser($env);

View File

@ -22,7 +22,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
*/
public function testEmptyToken($token)
{
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
$twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
@ -46,7 +46,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testReturns404onTokenNotFound()
{
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
$twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
@ -74,7 +74,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
public function testSearchResult()
{
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
$twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')

View File

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

View File

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

View File

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

View File

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

View File

@ -76,7 +76,7 @@ class PathPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($basePath)
{
$context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface');
$context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
$context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath));
return $context;

View File

@ -94,7 +94,7 @@ class UrlPackageTest extends \PHPUnit_Framework_TestCase
private function getContext($secure)
{
$context = $this->getMock('Symfony\Component\Asset\Context\ContextInterface');
$context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
$context->expects($this->any())->method('isSecure')->will($this->returnValue($secure));
return $context;

View File

@ -33,12 +33,12 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
public function testSupports()
{
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
@ -46,7 +46,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
public function testLoad()
{
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader->expects($this->once())->method('load');
$resolver = new LoaderResolver(array($loader));
@ -60,7 +60,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
{
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(false));
$resolver = new LoaderResolver(array($loader));
$loader = new DelegatingLoader($resolver);

View File

@ -18,9 +18,9 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testImportWithFileLocatorDelegation()
{
$locatorMock = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locatorMockForAdditionalLoader = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
$locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
array('path/to/file1'), // Default
array('path/to/file1', 'path/to/file2'), // First is imported

View File

@ -18,7 +18,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testConstructor()
{
$resolver = new LoaderResolver(array(
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'),
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(),
));
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
@ -26,11 +26,11 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testResolve()
{
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolver = new LoaderResolver(array($loader));
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$resolver = new LoaderResolver(array($loader));
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
@ -39,7 +39,7 @@ class LoaderResolverTest extends \PHPUnit_Framework_TestCase
public function testLoaders()
{
$resolver = new LoaderResolver();
$resolver->addLoader($loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'));
$resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock());
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
}

View File

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

View File

@ -47,7 +47,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
$this->assertContains('XSD file or callable', $e->getMessage());
}
$mock = $this->getMock(__NAMESPACE__.'\Validator');
$mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock();
$mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true));
try {

View File

@ -447,7 +447,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock();
$application->expects($this->once())
->method('getNamespaces')
->will($this->returnValue(array('foo:sublong', 'bar:sub')));
@ -469,7 +469,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testSetCatchExceptions()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -516,7 +516,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderException()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -540,7 +540,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo3:bar'), array('decorated' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -556,7 +556,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
*/
public function testRenderExceptionWithDoubleWidthCharacters()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -572,7 +572,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo'), array('decorated' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -706,7 +706,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('', 4);
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')
@ -721,7 +721,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('', 0);
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
$application->setAutoExit(false);
$application->expects($this->once())
->method('doRun')

View File

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

View File

@ -109,7 +109,7 @@ class HelperSetTest extends \PHPUnit_Framework_TestCase
private function getGenericMockHelper($name, HelperSet $helperset = null)
{
$mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface');
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
$mock_helper->expects($this->any())
->method('getName')
->will($this->returnValue($name));

View File

@ -142,7 +142,7 @@ class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency()
{
$progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display'));
$progress = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressHelper')->setMethods(array('display'))->getMock();
$progress->expects($this->exactly(4))
->method('display');

View File

@ -294,7 +294,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequency()
{
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6));
$bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream(), 6))->getMock();
$bar->expects($this->exactly(4))->method('display');
$bar->setRedrawFrequency(2);
@ -307,7 +307,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
{
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
$bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock();
$bar->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0);
@ -317,7 +317,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
{
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
$bar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')->setMethods(array('display'))->setConstructorArgs(array($this->getOutputStream()))->getMock();
$bar->expects($this->exactly(2))->method('display');
$bar->setRedrawFrequency(0.9);

View File

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

View File

@ -132,7 +132,7 @@ class SymfonyQuestionHelperTest extends \PHPUnit_Framework_TestCase
protected function createInputInterfaceMock($interactive = true)
{
$mock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any())
->method('isInteractive')
->will($this->returnValue($interactive));

View File

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

View File

@ -100,7 +100,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
$exception = new \Exception('foo');
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
$handler
->expects($this->exactly(2))
->method('sendPhpResponse');
@ -119,7 +119,7 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock();
$handler
->expects($this->once())
->method('sendPhpResponse');

View File

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

View File

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

View File

@ -249,7 +249,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$builder = new ContainerBuilder();
$builder->setResourceTracking(false);
$builderCompilerPasses = $builder->getCompiler()->getPassConfig()->getPasses();
$builder->addCompilerPass($this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'));
$builder->addCompilerPass($this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock());
$this->assertCount(count($builder->getCompiler()->getPassConfig()->getPasses()) - 1, $builderCompilerPasses);
}
@ -620,7 +620,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredButNotLoadedExtension()
{
$extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface');
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->once())->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->never())->method('load');
@ -632,7 +632,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testRegisteredAndLoadedExtension()
{
$extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface');
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project'));
$extension->expects($this->once())->method('load')->with(array(array('foo' => 'bar')));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->factory = new PropertyAccessDecorator($this->decoratedFactory);
}
@ -84,7 +84,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPath()
{
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@ -114,7 +114,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable()
{
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@ -128,7 +128,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateFromLoaderPropertyPathInstance()
{
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
@ -142,7 +142,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPath()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -159,7 +159,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewPreferredChoicesAsPropertyPathInstance()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -177,7 +177,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -194,7 +194,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPath()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -212,7 +212,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewLabelsAsPropertyPathInstance()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -230,7 +230,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPath()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -249,7 +249,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewIndicesAsPropertyPathInstance()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -268,7 +268,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPath()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -288,7 +288,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewGroupsAsPropertyPathInstance()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -309,7 +309,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
// https://github.com/symfony/symfony/issues/5494
public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -329,7 +329,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPath()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -350,7 +350,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
public function testCreateViewAttrAsPropertyPathInstance()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')

View File

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

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