fixed obsolete getMock() usage

This commit is contained in:
Fabien Potencier 2016-12-19 17:00:11 +01:00
parent 7ae26ed5f1
commit a3058245db
42 changed files with 197 additions and 206 deletions

View File

@ -117,7 +117,7 @@ class DoctrineChoiceLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyLoadChoiceList()
{
$factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
$factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$loader = new DoctrineChoiceLoader(
$factory,
$this->om,

View File

@ -31,7 +31,7 @@ class MergeDoctrineCollectionListenerTest extends \PHPUnit_Framework_TestCase
{
$this->collection = new ArrayCollection(array('test'));
$this->dispatcher = new EventDispatcher();
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->form = $this->getBuilder()
->getForm();
}

View File

@ -132,7 +132,7 @@ class ControllerTest extends TestCase
public function testJson()
{
$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
@ -149,14 +149,14 @@ class ControllerTest extends TestCase
public function testJsonWithSerializer()
{
$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
->with('serializer')
->will($this->returnValue(true));
$serializer = $this->getMock(SerializerInterface::class);
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
$serializer
->expects($this->once())
->method('serialize')
@ -179,14 +179,14 @@ class ControllerTest extends TestCase
public function testJsonWithSerializerContextOverride()
{
$container = $this->getMock(ContainerInterface::class);
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container
->expects($this->once())
->method('has')
->with('serializer')
->will($this->returnValue(true));
$serializer = $this->getMock(SerializerInterface::class);
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
$serializer
->expects($this->once())
->method('serialize')

View File

@ -25,7 +25,7 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase
);
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')
@ -50,7 +50,7 @@ class ConfigCachePassTest extends \PHPUnit_Framework_TestCase
public function testThatCheckersCanBeMissing()
{
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds'))->getMock();
$container->expects($this->atLeastOnce())
->method('findTaggedServiceIds')

View File

@ -33,7 +33,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());
}
@ -43,8 +43,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);
@ -63,9 +63,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

@ -454,7 +454,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock();
$application->expects($this->once())
->method('getNamespaces')
->will($this->returnValue(array('foo:sublong', 'bar:sub')));
@ -476,7 +476,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testSetCatchExceptions()
{
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
@ -514,7 +514,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')
@ -546,7 +546,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo3:bar'), array('decorated' => true, 'capture_stderr_separately' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getErrorOutput(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')
@ -559,7 +559,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')
@ -575,7 +575,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'foo'), array('decorated' => true, 'capture_stderr_separately' => true));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getErrorOutput(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')
@ -709,7 +709,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')
@ -724,7 +724,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

@ -124,7 +124,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));
@ -198,7 +198,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();
$warnArgCheck = function ($logLevel, $message, $context) {
$this->assertEquals('info', $logLevel);
@ -222,7 +222,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();
$logArgCheck = function ($level, $message, $context) {
$this->assertEquals('Undefined variable: undefVar', $message);
@ -283,7 +283,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$this->assertArrayHasKey('stack', $context);
};
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger
->expects($this->once())
->method('log')
@ -302,7 +302,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$exception = new \Exception('foo');
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logArgCheck = function ($level, $message, $context) {
$this->assertEquals('Uncaught Exception: foo', $message);
@ -342,7 +342,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))
@ -400,7 +400,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]);
$mockLogger = $this->getMock('Psr\Log\LoggerInterface');
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$mockLogger->expects($this->once())
->method('log')
->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]);
@ -420,7 +420,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
'line' => 123,
);
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logArgCheck = function ($level, $message, $context) {
$this->assertEquals('Fatal Parse Error: foo', $message);
@ -471,7 +471,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')

View File

@ -29,7 +29,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())
@ -50,7 +50,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())
@ -85,7 +85,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())
@ -107,7 +107,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);
@ -130,7 +130,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);
@ -147,7 +147,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);
@ -162,7 +162,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

@ -120,7 +120,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);
@ -135,7 +135,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

@ -193,7 +193,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);
@ -202,7 +202,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);

View File

@ -97,7 +97,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateFromLoaderPropertyPathWithCallableString()
{
$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')
@ -173,7 +173,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateViewPreferredChoicesAsPropertyPathWithCallableString()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -244,7 +244,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateViewLabelsAsPropertyPathWithCallableString()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -300,7 +300,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateViewIndicesAsPropertyPathWithCallableString()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -359,7 +359,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateViewGroupsAsPropertyPathWithCallableString()
{
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
$this->decoratedFactory->expects($this->once())
->method('createView')
@ -442,7 +442,7 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateViewAttrAsPropertyPathWithCallableString()
{
$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

@ -38,8 +38,8 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->loadedList = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
$this->loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
$this->loadedList = $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);
}

View File

@ -45,12 +45,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
protected function setUp()
{
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$this->serverParams = $this->getMock(
'Symfony\Component\Form\Extension\Validator\Util\ServerParams',
array('getNormalizedIniPostMaxSize', 'getContentLength')
);
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock();
parent::setUp();
}
@ -62,7 +59,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidate()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => array('group1', 'group2'));
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@ -78,7 +75,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidateConstraints()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
$constraint2 = new NotBlank(array('groups' => 'group2'));
@ -105,7 +102,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidateChildIfValidConstraint()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent')
->setCompound(true)
@ -129,7 +126,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfParentWithoutValidConstraint()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent', null)
->setCompound(true)
@ -163,7 +160,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testValidateConstraintsOptionEvenIfNoValidConstraint()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
$constraint2 = new NotBlank(array('groups' => 'group2'));
@ -190,7 +187,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfNoValidationGroups()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'validation_groups' => array(),
@ -209,9 +206,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateConstraintsIfNoValidationGroups()
{
$object = $this->getMock('\stdClass');
$constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
$constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
$object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$options = array(
'validation_groups' => array(),
@ -233,7 +230,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateIfNotSynchronized()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'invalid_message' => 'invalid_message_key',
@ -267,7 +264,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testAddInvalidErrorEvenIfNoValidationGroups()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass', array(
'invalid_message' => 'invalid_message_key',
@ -302,9 +299,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontValidateConstraintsIfNotSynchronized()
{
$object = $this->getMock('\stdClass');
$constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
$constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
$object = $this->getMockBuilder('\stdClass')->getMock();
$constraint1 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$constraint2 = $this->getMockBuilder('Symfony\Component\Validator\Constraint')->getMock();
$options = array(
'invalid_message' => 'invalid_message_key',
@ -337,7 +334,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
// https://github.com/symfony/symfony/issues/4359
public function testDontMarkInvalidIfAnyChildIsNotSynchronized()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$failingTransformer = new CallbackTransformer(
function ($data) { return $data; },
@ -367,7 +364,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testHandleCallbackValidationGroups()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => array($this, 'getValidationGroups'));
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@ -383,7 +380,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontExecuteFunctionNames()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => 'header');
$form = $this->getBuilder('name', '\stdClass', $options)
->setData($object)
@ -398,7 +395,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testHandleClosureValidationGroups()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$options = array('validation_groups' => function (FormInterface $form) {
return array('group1', 'group2');
});
@ -416,7 +413,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseValidationGroupOfClickedButton()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent')
->setCompound(true)
@ -443,7 +440,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testDontUseValidationGroupOfUnclickedButton()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parent = $this->getBuilder('parent')
->setCompound(true)
@ -470,7 +467,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedValidationGroup()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array('validation_groups' => 'group');
$parent = $this->getBuilder('parent', null, $parentOptions)
@ -492,7 +489,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedCallbackValidationGroup()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array('validation_groups' => array($this, 'getValidationGroups'));
$parent = $this->getBuilder('parent', null, $parentOptions)
@ -514,7 +511,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testUseInheritedClosureValidationGroup()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$parentOptions = array(
'validation_groups' => function (FormInterface $form) {
@ -540,7 +537,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
public function testAppendPropertyPath()
{
$object = $this->getMock('\stdClass');
$object = $this->getMockBuilder('\stdClass')->getMock();
$form = $this->getBuilder('name', '\stdClass')
->setData($object)
->getForm();
@ -618,9 +615,9 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
private function getMockExecutionContext()
{
$context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
$context = $this->getMockBuilder('Symfony\Component\Validator\Context\ExecutionContextInterface')->getMock();
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
$validator->expects($this->any())
->method('inContext')
@ -668,6 +665,6 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
*/
private function getDataMapper()
{
return $this->getMock('Symfony\Component\Form\DataMapperInterface');
return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
}

View File

@ -54,10 +54,10 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$this->validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface');
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$this->violationMapper = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface')->getMock();
$this->listener = new ValidationListener($this->validator, $this->violationMapper);
$this->message = 'Message';
$this->messageTemplate = 'Message template';
@ -87,7 +87,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase
private function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
return $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
}
// More specific mapping tests can be found in ViolationMapperTest
@ -161,7 +161,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase
public function testValidatorInterface()
{
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$listener = new ValidationListener($validator, $this->violationMapper);
$this->assertAttributeSame($validator, 'validator', $listener);

View File

@ -47,7 +47,7 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
public function testValidatorInterface()
{
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$formTypeValidatorExtension = new FormTypeValidatorExtension($validator);
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension);

View File

@ -26,7 +26,7 @@ class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase
$this->registry = $factory->getProperty('registry');
$this->registry->setAccessible(true);
$this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
$this->guesser = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
$this->type = new FooType();
}

View File

@ -69,9 +69,9 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
$this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface');
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
$this->parentType = $this->getMockFormType();
$this->type = $this->getMockFormType();
$this->extension1 = $this->getMockFormTypeExtension();
@ -125,7 +125,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
{
$givenOptions = array('a' => 'a_custom', 'c' => 'c_custom');
$resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default');
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock();
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType))
@ -153,7 +153,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
{
$givenOptions = array('data_class' => 'Foo');
$resolvedOptions = array('data_class' => '\stdClass');
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock();
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType))
@ -190,7 +190,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
};
$options = array('a' => 'Foo', 'b' => 'Bar');
$builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
$builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock();
// First the form is built for the super type
$this->parentType->expects($this->once())
@ -220,7 +220,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
public function testCreateView()
{
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$view = $this->resolvedType->createView($form);
@ -230,8 +230,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
public function testCreateViewWithParent()
{
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$parentView = $this->getMock('Symfony\Component\Form\FormView');
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$view = $this->resolvedType->createView($form, $parentView);
@ -242,8 +242,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
public function testBuildView()
{
$options = array('a' => '1', 'b' => '2');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$view = $this->getMock('Symfony\Component\Form\FormView');
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$i = 0;
@ -284,8 +284,8 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
public function testFinishView()
{
$options = array('a' => '1', 'b' => '2');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$view = $this->getMock('Symfony\Component\Form\FormView');
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();
$i = 0;
@ -361,7 +361,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
*/
private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType')
{
return $this->getMock($typeClass, array('getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'));
return $this->getMockBuilder($typeClass)->setMethods(array('getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock();
}
/**
@ -369,7 +369,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
*/
private function getMockFormTypeExtension()
{
return $this->getMock('Symfony\Component\Form\AbstractTypeExtension', array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'));
return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(array('getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'))->getMock();
}
/**
@ -377,7 +377,7 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase
*/
private function getMockFormFactory()
{
return $this->getMock('Symfony\Component\Form\FormFactoryInterface');
return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
}
/**

View File

@ -190,7 +190,7 @@ class ArgumentResolverTest extends \PHPUnit_Framework_TestCase
public function testGetArgumentWithoutArray()
{
$factory = new ArgumentMetadataFactory();
$valueResolver = $this->getMock(ArgumentValueResolverInterface::class);
$valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock();
$resolver = new ArgumentResolver($factory, array($valueResolver));
$valueResolver->expects($this->any())->method('supports')->willReturn(true);

View File

@ -58,7 +58,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
public function testKernelResponseDoesNotStartSession()
{
$kernel = $this->getMock(HttpKernelInterface::class);
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = new Request();
$session = new Session(new MockArraySessionStorage());
$request->setSession($session);
@ -233,8 +233,8 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
protected function injectController($collector, $controller, $request)
{
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMock(ArgumentResolverInterface::class));
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock());
$event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
$collector->onKernelController($event);
}

View File

@ -110,9 +110,9 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
protected function getHttpKernel($dispatcher, $controller)
{
$controllerResolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface');
$controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock();
$controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller));
$argumentResolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface');
$argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock();
$argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue(array()));
return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver);

View File

@ -30,12 +30,9 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(array('alias' => 'foo')),
);
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));
@ -59,14 +56,14 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
'my_content_renderer' => array(array('alias' => 'foo')),
);
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$renderer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$renderer
->expects($this->once())
->method('addMethodCall')
->with('addRendererService', array('foo', 'my_content_renderer'))
;
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
$definition->expects($this->atLeastOnce())
->method('getClass')
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
@ -76,10 +73,7 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(true))
;
$builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder',
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
);
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
$builder->expects($this->any())
->method('hasDefinition')
->will($this->returnValue(true));

View File

@ -38,7 +38,7 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
->method('collect')
->will($this->returnValue($profile));
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
->disableOriginalConstructor()

View File

@ -57,7 +57,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerLegacy()
{
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', array('getController'));
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(array('getController'))->getMock();
$resolver
->expects($this->once())
->method('getController')
@ -78,7 +78,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController()
{
$resolver = $this->getMock(ControllerResolverInterface::class);
$resolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock();
$resolver
->expects($this->once())
->method('getController')
@ -111,7 +111,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
public function testRenderExceptionNoIgnoreErrors()
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher->expects($this->never())->method('dispatch');
$strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
@ -121,7 +121,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testRenderExceptionIgnoreErrors()
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
$dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION);
$strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
@ -141,7 +141,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
private function getKernel($returnValue)
{
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel
->expects($this->any())
->method('handle')
@ -157,7 +157,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
*/
private function getKernelExpectingRequest(Request $request)
{
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel
->expects($this->any())
->method('handle')
@ -169,7 +169,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
{
$controllerResolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$controllerResolver
->expects($this->once())
->method('getController')
@ -180,7 +180,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
}))
;
$argumentResolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface');
$argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock();
$argumentResolver
->expects($this->once())
->method('getArguments')

View File

@ -292,7 +292,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
{
$request = new Request();
$stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop'));
$stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock();
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
$stack->expects($this->at(1))->method('pop');
@ -328,13 +328,13 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
$controller = function () { return new Response('Hello'); };
}
$controllerResolver = $this->getMock(ControllerResolverInterface::class);
$controllerResolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock();
$controllerResolver
->expects($this->any())
->method('getController')
->will($this->returnValue($controller));
$argumentResolver = $this->getMock(ArgumentResolverInterface::class);
$argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock();
$argumentResolver
->expects($this->any())
->method('getArguments')

View File

@ -29,7 +29,7 @@ class LdapClientTest extends LdapTestCase
protected function setUp()
{
$this->ldap = $this->getMock(LdapInterface::class);
$this->ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$this->client = new LdapClient(null, 389, 3, false, false, false, $this->ldap);
}
@ -66,7 +66,7 @@ class LdapClientTest extends LdapTestCase
public function testLdapFind()
{
$collection = $this->getMock(CollectionInterface::class);
$collection = $this->getMockBuilder(CollectionInterface::class)->getMock();
$collection
->expects($this->once())
->method('getIterator')
@ -83,7 +83,7 @@ class LdapClientTest extends LdapTestCase
)),
))))
;
$query = $this->getMock(QueryInterface::class);
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')

View File

@ -26,13 +26,13 @@ class LdapTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->adapter = $this->getMock(AdapterInterface::class);
$this->adapter = $this->getMockBuilder(AdapterInterface::class)->getMock();
$this->ldap = new Ldap($this->adapter);
}
public function testLdapBind()
{
$connection = $this->getMock(ConnectionInterface::class);
$connection = $this->getMockBuilder(ConnectionInterface::class)->getMock();
$connection
->expects($this->once())
->method('bind')

View File

@ -30,9 +30,9 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testEmptyPasswordShouldThrowAnException()
{
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
$ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface');
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock();
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@ -47,14 +47,14 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testBindFailureShouldThrowAnException()
{
$userProvider = $this->getMock(UserProviderInterface::class);
$ldap = $this->getMock(LdapInterface::class);
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('bind')
->will($this->throwException(new ConnectionException()))
;
$userChecker = $this->getMock(UserCheckerInterface::class);
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@ -65,15 +65,15 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUser()
{
$userProvider = $this->getMock(UserProviderInterface::class);
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider
->expects($this->once())
->method('loadUserByUsername')
->with('foo')
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$userChecker = $this->getMock(UserCheckerInterface::class);
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'retrieveUser');

View File

@ -29,7 +29,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
{
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
$this->assertSame($expected, $manager->decide($token, array('ROLE_FOO')));
@ -47,7 +47,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
public function getStrategiesWith2RolesTests()
{
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false),
@ -65,7 +65,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterFor2Roles($token, $vote1, $vote2)
{
$voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
$voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValueMap(array(
@ -130,7 +130,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoter($vote)
{
$voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
$voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValue($vote));

View File

@ -23,7 +23,7 @@ class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
public function testDecideLog($expectedLog, $object)
{
$adm = new DebugAccessDecisionManager(new AccessDecisionManager());
$adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object);
$adm->decide($this->getMockBuilder(TokenInterface::class)->getMock(), array('ATTRIBUTE_1'), $object);
$this->assertSame($expectedLog, $adm->getDecisionLog());
}

View File

@ -45,7 +45,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
foreach ($roles as $i => $role) {
$roles[$i] = new Role($role);
}
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
if ($tokenExpectsGetRoles) {
$token->expects($this->once())
@ -58,7 +58,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true)
{
$mock = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage');
$mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock();
if ($expressionLanguageExpectsEvaluate) {
$mock->expects($this->once())
@ -71,12 +71,12 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createTrustResolver()
{
return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface');
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
}
protected function createRoleHierarchy()
{
return $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface');
return $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock();
}
protected function createExpression()

View File

@ -28,7 +28,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
{
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('bind')
@ -44,8 +44,8 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfNoLdapEntries()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
@ -56,7 +56,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
->method('count')
->will($this->returnValue(0))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
@ -77,8 +77,8 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
@ -89,7 +89,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
->method('count')
->will($this->returnValue(2))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
@ -110,14 +110,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@ -156,14 +156,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@ -198,14 +198,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@ -240,14 +240,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')

View File

@ -69,7 +69,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
{
$event = $this->createEvent(new AuthenticationException());
$entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();
$entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE'));
$listener = $this->createExceptionListener(null, null, null, $entryPoint);

View File

@ -39,7 +39,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
public function testSessionIsMigrated()
{
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())->method('migrate')->with($this->equalTo(true));
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
@ -48,7 +48,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
public function testSessionIsInvalidated()
{
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
$session->expects($this->once())->method('invalidate');
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE);
@ -57,7 +57,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
private function getRequest($session = null)
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
if (null !== $session) {
$request->expects($this->any())->method('getSession')->will($this->returnValue($session));
@ -68,6 +68,6 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
private function getToken()
{
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
}

View File

@ -24,16 +24,16 @@ class UsernamePasswordFormAuthenticationListenerTest extends \PHPUnit_Framework_
public function testHandleWhenUsernameLength($username, $ok)
{
$request = Request::create('/login_check', 'POST', array('_username' => $username));
$request->setSession($this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
$httpUtils
->expects($this->any())
->method('checkRequestPath')
->will($this->returnValue(true))
;
$failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
$failureHandler
->expects($ok ? $this->never() : $this->once())
->method('onAuthenticationFailure')
@ -48,17 +48,17 @@ class UsernamePasswordFormAuthenticationListenerTest extends \PHPUnit_Framework_
;
$listener = new UsernamePasswordFormAuthenticationListener(
$this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
$authenticationManager,
$this->getMock('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface'),
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
$httpUtils,
'TheProviderKey',
$this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'),
$this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
$failureHandler,
array('require_previous_session' => false)
);
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
$event
->expects($this->any())
->method('getRequest')

View File

@ -26,7 +26,7 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
{
$metadata = new ClassMetadata(Dummy::class);
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
$decorated
->expects($this->once())
->method('getMetadataFor')
@ -42,7 +42,7 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
public function testHasMetadataFor()
{
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
$decorated
->expects($this->once())
->method('hasMetadataFor')
@ -59,7 +59,7 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidClassThrowsException()
{
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
$factory->getMetadataFor('Not\Exist');

View File

@ -50,7 +50,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function testCacheExists()
{
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$cache
->expects($this->once())
->method('fetch')
@ -66,7 +66,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function testCacheNotExists()
{
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
$cache->method('fetch')->will($this->returnValue(false));
$cache->method('save');

View File

@ -33,7 +33,7 @@ class JsonSerializableNormalizerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->serializer = $this->getMock(JsonSerializerNormalizer::class);
$this->serializer = $this->getMockBuilder(JsonSerializerNormalizer::class)->getMock();
$this->normalizer = new JsonSerializableNormalizer();
$this->normalizer->setSerializer($this->serializer);
}

View File

@ -319,7 +319,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testNormalizerAware()
{
$normalizerAware = $this->getMock(NormalizerAwareInterface::class);
$normalizerAware = $this->getMockBuilder(NormalizerAwareInterface::class)->getMock();
$normalizerAware->expects($this->once())
->method('setNormalizer')
->with($this->isInstanceOf(NormalizerInterface::class));
@ -329,7 +329,7 @@ class SerializerTest extends \PHPUnit_Framework_TestCase
public function testDenormalizerAware()
{
$denormalizerAware = $this->getMock(DenormalizerAwareInterface::class);
$denormalizerAware = $this->getMockBuilder(DenormalizerAwareInterface::class)->getMock();
$denormalizerAware->expects($this->once())
->method('setDenormalizer')
->with($this->isInstanceOf(DenormalizerInterface::class));

View File

@ -19,7 +19,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testGetSetLogger()
{
$loader = new ProjectTemplateLoader4();
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$loader->setLogger($logger);
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
}

View File

@ -91,9 +91,9 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
protected function createContext()
{
$translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
$context = new ExecutionContext($validator, $this->root, $translator);
$context->setGroup($this->group);

View File

@ -603,8 +603,8 @@ abstract class AbstractTest extends AbstractValidatorTest
$entity->initialized = false;
// prepare initializers that set "initialized" to true
$initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
$initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface');
$initializer1 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
$initializer2 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock();
$initializer1->expects($this->once())
->method('initialize')

View File

@ -42,7 +42,7 @@ class RecursiveValidatorTest extends AbstractTest
$childB->name = 'fake';
$entity->childA = array($childA);
$entity->childB = array($childB);
$validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
$validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
$validatorContext
->expects($this->once())
->method('validate')