Merge branch '4.3' into 4.4

* 4.3:
  Use willReturn() instead of will(returnValue()).
This commit is contained in:
Nicolas Grekas 2019-05-30 18:10:19 +02:00
commit c62032a730
196 changed files with 1187 additions and 1189 deletions

View File

@ -18,8 +18,6 @@ return PhpCsFixer\Config::create()
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
// Part of @Symfony:risky in PHP-CS-Fixer 2.15.0. Incompatible with PHPUnit 4 that is required for Symfony 3.4
'php_unit_mock_short_will_return' => false,
]) ])
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder( ->setFinder(

View File

@ -166,20 +166,20 @@ class DoctrineDataCollectorTest extends TestCase
->getMock(); ->getMock();
$connection->expects($this->any()) $connection->expects($this->any())
->method('getDatabasePlatform') ->method('getDatabasePlatform')
->will($this->returnValue(new MySqlPlatform())); ->willReturn(new MySqlPlatform());
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry $registry
->expects($this->any()) ->expects($this->any())
->method('getConnectionNames') ->method('getConnectionNames')
->will($this->returnValue(['default' => 'doctrine.dbal.default_connection'])); ->willReturn(['default' => 'doctrine.dbal.default_connection']);
$registry $registry
->expects($this->any()) ->expects($this->any())
->method('getManagerNames') ->method('getManagerNames')
->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager'])); ->willReturn(['default' => 'doctrine.orm.default_entity_manager']);
$registry->expects($this->any()) $registry->expects($this->any())
->method('getConnection') ->method('getConnection')
->will($this->returnValue($connection)); ->willReturn($connection);
$logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
$logger->queries = $queries; $logger->queries = $queries;

View File

@ -44,9 +44,9 @@ class DoctrineExtensionTest extends TestCase
$this->extension->expects($this->any()) $this->extension->expects($this->any())
->method('getObjectManagerElementName') ->method('getObjectManagerElementName')
->will($this->returnCallback(function ($name) { ->willReturnCallback(function ($name) {
return 'doctrine.orm.'.$name; return 'doctrine.orm.'.$name;
})); });
} }
/** /**

View File

@ -34,47 +34,47 @@ class DoctrineOrmTypeGuesserTest extends TestCase
// Simple field, not nullable // Simple field, not nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->fieldMappings['field'] = true; $classMetadata->fieldMappings['field'] = true;
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// Simple field, nullable // Simple field, nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->fieldMappings['field'] = true; $classMetadata->fieldMappings['field'] = true;
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
// One-to-one, nullable (by default) // One-to-one, nullable (by default)
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [[]]]; $mapping = ['joinColumns' => [[]]];
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, nullable (explicit) // One-to-one, nullable (explicit)
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => true]]]; $mapping = ['joinColumns' => [['nullable' => true]]];
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, not nullable // One-to-one, not nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => false]]]; $mapping = ['joinColumns' => [['nullable' => false]]];
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// One-to-many, no clue // One-to-many, no clue
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
$return[] = [$classMetadata, null]; $return[] = [$classMetadata, null];
@ -84,10 +84,10 @@ class DoctrineOrmTypeGuesserTest extends TestCase
private function getGuesser(ClassMetadata $classMetadata) private function getGuesser(ClassMetadata $classMetadata)
{ {
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata)); $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em])); $registry->expects($this->once())->method('getManagers')->willReturn([$em]);
return new DoctrineOrmTypeGuesser($registry); return new DoctrineOrmTypeGuesser($registry);
} }

View File

@ -38,11 +38,11 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
$manager->expects($this->any()) $manager->expects($this->any())
->method('getManager') ->method('getManager')
->will($this->returnValue($this->em)); ->willReturn($this->em);
$manager->expects($this->any()) $manager->expects($this->any())
->method('getManagerForClass') ->method('getManagerForClass')
->will($this->returnValue($this->em)); ->willReturn($this->em);
return [ return [
new CoreExtension(), new CoreExtension(),

View File

@ -1087,7 +1087,7 @@ class EntityTypeTest extends BaseTypeTest
$this->emRegistry->expects($this->once()) $this->emRegistry->expects($this->once())
->method('getManagerForClass') ->method('getManagerForClass')
->with(self::SINGLE_IDENT_CLASS) ->with(self::SINGLE_IDENT_CLASS)
->will($this->returnValue($this->em)); ->willReturn($this->em);
$this->factory->createNamed('name', static::TESTED_TYPE, null, [ $this->factory->createNamed('name', static::TESTED_TYPE, null, [
'class' => self::SINGLE_IDENT_CLASS, 'class' => self::SINGLE_IDENT_CLASS,
@ -1237,7 +1237,7 @@ class EntityTypeTest extends BaseTypeTest
$registry->expects($this->any()) $registry->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo($name)) ->with($this->equalTo($name))
->will($this->returnValue($em)); ->willReturn($em);
return $registry; return $registry;
} }

View File

@ -188,7 +188,7 @@ class EntityUserProviderTest extends TestCase
$manager->expects($this->any()) $manager->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo($name)) ->with($this->equalTo($name))
->will($this->returnValue($em)); ->willReturn($em);
return $manager; return $manager;
} }

View File

@ -82,7 +82,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$registry->expects($this->any()) $registry->expects($this->any())
->method('getManager') ->method('getManager')
->with($this->equalTo(self::EM_NAME)) ->with($this->equalTo(self::EM_NAME))
->will($this->returnValue($em)); ->willReturn($em);
return $registry; return $registry;
} }
@ -104,14 +104,14 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
; ;
$em->expects($this->any()) $em->expects($this->any())
->method('getRepository') ->method('getRepository')
->will($this->returnValue($repositoryMock)) ->willReturn($repositoryMock)
; ;
$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock(); $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$classMetadata $classMetadata
->expects($this->any()) ->expects($this->any())
->method('hasField') ->method('hasField')
->will($this->returnValue(true)) ->willReturn(true)
; ;
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -125,12 +125,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$refl $refl
->expects($this->any()) ->expects($this->any())
->method('getValue') ->method('getValue')
->will($this->returnValue(true)) ->willReturn(true)
; ;
$classMetadata->reflFields = ['name' => $refl]; $classMetadata->reflFields = ['name' => $refl];
$em->expects($this->any()) $em->expects($this->any())
->method('getClassMetadata') ->method('getClassMetadata')
->will($this->returnValue($classMetadata)) ->willReturn($classMetadata)
; ;
return $em; return $em;
@ -366,7 +366,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$repository = $this->createRepositoryMock(); $repository = $this->createRepositoryMock();
$repository->expects($this->once()) $repository->expects($this->once())
->method('findByCustom') ->method('findByCustom')
->will($this->returnValue([])) ->willReturn([])
; ;
$this->em = $this->createEntityManagerMock($repository); $this->em = $this->createEntityManagerMock($repository);
$this->registry = $this->createRegistryMock($this->em); $this->registry = $this->createRegistryMock($this->em);
@ -394,15 +394,15 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$repository = $this->createRepositoryMock(); $repository = $this->createRepositoryMock();
$repository->expects($this->once()) $repository->expects($this->once())
->method('findByCustom') ->method('findByCustom')
->will( ->willReturnCallback(
$this->returnCallback(function () use ($entity) { function () use ($entity) {
$returnValue = [ $returnValue = [
$entity, $entity,
]; ];
next($returnValue); next($returnValue);
return $returnValue; return $returnValue;
}) }
) )
; ;
$this->em = $this->createEntityManagerMock($repository); $this->em = $this->createEntityManagerMock($repository);
@ -430,7 +430,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$repository = $this->createRepositoryMock(); $repository = $this->createRepositoryMock();
$repository->expects($this->once()) $repository->expects($this->once())
->method('findByCustom') ->method('findByCustom')
->will($this->returnValue($result)) ->willReturn($result)
; ;
$this->em = $this->createEntityManagerMock($repository); $this->em = $this->createEntityManagerMock($repository);
$this->registry = $this->createRegistryMock($this->em); $this->registry = $this->createRegistryMock($this->em);
@ -564,7 +564,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$repository->expects($this->once()) $repository->expects($this->once())
->method('findByCustom') ->method('findByCustom')
->will($this->returnValue([$entity1])) ->willReturn([$entity1])
; ;
$this->em->persist($entity1); $this->em->persist($entity1);
@ -635,7 +635,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
$repository = $this->createRepositoryMock(); $repository = $this->createRepositoryMock();
$repository $repository
->method('find') ->method('find')
->will($this->returnValue(null)) ->willReturn(null)
; ;
$this->em = $this->createEntityManagerMock($repository); $this->em = $this->createEntityManagerMock($repository);

View File

@ -50,7 +50,7 @@ class ConsoleHandlerTest extends TestCase
$output $output
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('getVerbosity') ->method('getVerbosity')
->will($this->returnValue($verbosity)) ->willReturn($verbosity)
; ;
$handler = new ConsoleHandler($output, true, $map); $handler = new ConsoleHandler($output, true, $map);
$this->assertSame($isHandling, $handler->isHandling(['level' => $level]), $this->assertSame($isHandling, $handler->isHandling(['level' => $level]),
@ -114,12 +114,12 @@ class ConsoleHandlerTest extends TestCase
$output $output
->expects($this->at(0)) ->expects($this->at(0))
->method('getVerbosity') ->method('getVerbosity')
->will($this->returnValue(OutputInterface::VERBOSITY_QUIET)) ->willReturn(OutputInterface::VERBOSITY_QUIET)
; ;
$output $output
->expects($this->at(1)) ->expects($this->at(1))
->method('getVerbosity') ->method('getVerbosity')
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) ->willReturn(OutputInterface::VERBOSITY_DEBUG)
; ;
$handler = new ConsoleHandler($output); $handler = new ConsoleHandler($output);
$this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]), $this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]),
@ -144,7 +144,7 @@ class ConsoleHandlerTest extends TestCase
$output $output
->expects($this->any()) ->expects($this->any())
->method('getVerbosity') ->method('getVerbosity')
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) ->willReturn(OutputInterface::VERBOSITY_DEBUG)
; ;
$output $output
->expects($this->once()) ->expects($this->once())

View File

@ -93,10 +93,10 @@ class WebProcessorTest extends TestCase
->getMock(); ->getMock();
$event->expects($this->any()) $event->expects($this->any())
->method('isMasterRequest') ->method('isMasterRequest')
->will($this->returnValue(true)); ->willReturn(true);
$event->expects($this->any()) $event->expects($this->any())
->method('getRequest') ->method('getRequest')
->will($this->returnValue($request)); ->willReturn($request);
return [$event, $server]; return [$event, $server];
} }

View File

@ -62,7 +62,7 @@ class HttpKernelExtensionTest extends TestCase
protected function getFragmentHandler($return) protected function getFragmentHandler($return)
{ {
$strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock(); $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock();
$strategy->expects($this->once())->method('getName')->will($this->returnValue('inline')); $strategy->expects($this->once())->method('getName')->willReturn('inline');
$strategy->expects($this->once())->method('render')->will($return); $strategy->expects($this->once())->method('render')->will($return);
$context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')
@ -70,7 +70,7 @@ class HttpKernelExtensionTest extends TestCase
->getMock() ->getMock()
; ;
$context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); $context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
return new FragmentHandler($context, [$strategy], false); return new FragmentHandler($context, [$strategy], false);
} }
@ -82,9 +82,9 @@ class HttpKernelExtensionTest extends TestCase
$twig->addExtension(new HttpKernelExtension()); $twig->addExtension(new HttpKernelExtension());
$loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap([ $loader->expects($this->any())->method('load')->willReturnMap([
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
])); ]);
$twig->addRuntimeLoader($loader); $twig->addRuntimeLoader($loader);
return $twig->render('index'); return $twig->render('index');

View File

@ -37,7 +37,7 @@ class TemplateFinderTest extends TestCase
$kernel $kernel
->expects($this->once()) ->expects($this->once())
->method('getBundles') ->method('getBundles')
->will($this->returnValue(['BaseBundle' => new BaseBundle()])) ->willReturn(['BaseBundle' => new BaseBundle()])
; ;
$parser = new TemplateFilenameParser(); $parser = new TemplateFilenameParser();

View File

@ -71,13 +71,13 @@ class TemplatePathsCacheWarmerTest extends TestCase
$this->templateFinder $this->templateFinder
->expects($this->once()) ->expects($this->once())
->method('findAllTemplates') ->method('findAllTemplates')
->will($this->returnValue([$template])); ->willReturn([$template]);
$this->fileLocator $this->fileLocator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->with($template->getPath()) ->with($template->getPath())
->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig')); ->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig');
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
$warmer->warmUp($this->tmpDir); $warmer->warmUp($this->tmpDir);
@ -90,7 +90,7 @@ class TemplatePathsCacheWarmerTest extends TestCase
$this->templateFinder $this->templateFinder
->expects($this->once()) ->expects($this->once())
->method('findAllTemplates') ->method('findAllTemplates')
->will($this->returnValue([])); ->willReturn([]);
$this->fileLocator $this->fileLocator
->expects($this->never()) ->expects($this->never())

View File

@ -62,11 +62,11 @@ class RouterMatchCommandTest extends TestCase
$router $router
->expects($this->any()) ->expects($this->any())
->method('getRouteCollection') ->method('getRouteCollection')
->will($this->returnValue($routeCollection)); ->willReturn($routeCollection);
$router $router
->expects($this->any()) ->expects($this->any())
->method('getContext') ->method('getContext')
->will($this->returnValue($requestContext)); ->willReturn($requestContext);
return $router; return $router;
} }
@ -77,9 +77,9 @@ class RouterMatchCommandTest extends TestCase
$container $container
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('has') ->method('has')
->will($this->returnCallback(function ($id) { ->willReturnCallback(function ($id) {
return 'console.command_loader' !== $id; return 'console.command_loader' !== $id;
})) })
; ;
$container $container
->expects($this->any()) ->expects($this->any())

View File

@ -154,26 +154,26 @@ class TranslationDebugCommandTest extends TestCase
$translator $translator
->expects($this->any()) ->expects($this->any())
->method('getFallbackLocales') ->method('getFallbackLocales')
->will($this->returnValue(['en'])); ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->method('extract')
->will( ->willReturnCallback(
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { function ($path, $catalogue) use ($extractedMessages) {
$catalogue->add($extractedMessages); $catalogue->add($extractedMessages);
}) }
); );
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('read') ->method('read')
->will( ->willReturnCallback(
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { function ($path, $catalogue) use ($loadedMessages) {
$catalogue->add($loadedMessages); $catalogue->add($loadedMessages);
}) }
); );
if (null === $kernel) { if (null === $kernel) {
@ -191,13 +191,13 @@ class TranslationDebugCommandTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
->will($this->returnValueMap($returnValues)); ->willReturnMap($returnValues);
} }
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundles') ->method('getBundles')
->will($this->returnValue([])); ->willReturn([]);
$container = new Container(); $container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir); $container->setParameter('kernel.root_dir', $this->translationDir);
@ -205,7 +205,7 @@ class TranslationDebugCommandTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getContainer') ->method('getContainer')
->will($this->returnValue($container)); ->willReturn($container);
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths); $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
@ -221,7 +221,7 @@ class TranslationDebugCommandTest extends TestCase
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')
->will($this->returnValue($path)) ->willReturn($path)
; ;
return $bundle; return $bundle;

View File

@ -130,36 +130,36 @@ class TranslationUpdateCommandTest extends TestCase
$translator $translator
->expects($this->any()) ->expects($this->any())
->method('getFallbackLocales') ->method('getFallbackLocales')
->will($this->returnValue(['en'])); ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->method('extract')
->will( ->willReturnCallback(
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { function ($path, $catalogue) use ($extractedMessages) {
foreach ($extractedMessages as $domain => $messages) { foreach ($extractedMessages as $domain => $messages) {
$catalogue->add($messages, $domain); $catalogue->add($messages, $domain);
} }
}) }
); );
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('read') ->method('read')
->will( ->willReturnCallback(
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { function ($path, $catalogue) use ($loadedMessages) {
$catalogue->add($loadedMessages); $catalogue->add($loadedMessages);
}) }
); );
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
$writer $writer
->expects($this->any()) ->expects($this->any())
->method('getFormats') ->method('getFormats')
->will( ->willReturn(
$this->returnValue(['xlf', 'yml', 'yaml']) ['xlf', 'yml', 'yaml']
); );
if (null === $kernel) { if (null === $kernel) {
@ -177,25 +177,25 @@ class TranslationUpdateCommandTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
->will($this->returnValueMap($returnValues)); ->willReturnMap($returnValues);
} }
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getRootDir') ->method('getRootDir')
->will($this->returnValue($this->translationDir)); ->willReturn($this->translationDir);
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundles') ->method('getBundles')
->will($this->returnValue([])); ->willReturn([]);
$container = new Container(); $container = new Container();
$container->setParameter('kernel.root_dir', $this->translationDir); $container->setParameter('kernel.root_dir', $this->translationDir);
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getContainer') ->method('getContainer')
->will($this->returnValue($container)); ->willReturn($container);
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths); $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
@ -211,7 +211,7 @@ class TranslationUpdateCommandTest extends TestCase
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')
->will($this->returnValue($path)) ->willReturn($path)
; ;
return $bundle; return $bundle;

View File

@ -271,7 +271,7 @@ class ApplicationTest extends TestCase
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('get') ->method('get')
->with($this->equalTo('event_dispatcher')) ->with($this->equalTo('event_dispatcher'))
->will($this->returnValue($dispatcher)); ->willReturn($dispatcher);
} }
$container $container
@ -292,12 +292,12 @@ class ApplicationTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundles') ->method('getBundles')
->will($this->returnValue($bundles)) ->willReturn($bundles)
; ;
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getContainer') ->method('getContainer')
->will($this->returnValue($container)) ->willReturn($container)
; ;
return $kernel; return $kernel;
@ -309,9 +309,9 @@ class ApplicationTest extends TestCase
$bundle $bundle
->expects($this->once()) ->expects($this->once())
->method('registerCommands') ->method('registerCommands')
->will($this->returnCallback(function (Application $application) use ($commands) { ->willReturnCallback(function (Application $application) use ($commands) {
$application->addCommands($commands); $application->addCommands($commands);
})) })
; ;
return $bundle; return $bundle;

View File

@ -155,13 +155,13 @@ class ControllerNameParserTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
->will($this->returnCallback(function ($bundle) use ($bundles) { ->willReturnCallback(function ($bundle) use ($bundles) {
if (!isset($bundles[$bundle])) { if (!isset($bundles[$bundle])) {
throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle)); throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle));
} }
return $bundles[$bundle]; return $bundles[$bundle];
})) })
; ;
$bundles = [ $bundles = [
@ -172,7 +172,7 @@ class ControllerNameParserTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundles') ->method('getBundles')
->will($this->returnValue($bundles)) ->willReturn($bundles)
; ;
return new ControllerNameParser($kernel); return new ControllerNameParser($kernel);
@ -181,8 +181,8 @@ class ControllerNameParserTest extends TestCase
private function getBundle($namespace, $name) private function getBundle($namespace, $name)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name)); $bundle->expects($this->any())->method('getName')->willReturn($name);
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace)); $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
return $bundle; return $bundle;
} }

View File

@ -60,7 +60,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$parser->expects($this->once()) $parser->expects($this->once())
->method('parse') ->method('parse')
->with($shortName) ->with($shortName)
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')) ->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')
; ;
$resolver = $this->createControllerResolver(null, null, $parser); $resolver = $this->createControllerResolver(null, null, $parser);

View File

@ -44,9 +44,9 @@ abstract class ControllerTraitTest extends TestCase
$requestStack->push($request); $requestStack->push($request);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale()); return new Response($request->getRequestFormat().'--'.$request->getLocale());
})); });
$container = new Container(); $container = new Container();
$container->set('request_stack', $requestStack); $container->set('request_stack', $requestStack);
@ -111,7 +111,7 @@ abstract class ControllerTraitTest extends TestCase
$tokenStorage $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
->will($this->returnValue($token)); ->willReturn($token);
$container = new Container(); $container = new Container();
$container->set('security.token_storage', $tokenStorage); $container->set('security.token_storage', $tokenStorage);
@ -138,7 +138,7 @@ abstract class ControllerTraitTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('serialize') ->method('serialize')
->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS]) ->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS])
->will($this->returnValue('[]')); ->willReturn('[]');
$container->set('serializer', $serializer); $container->set('serializer', $serializer);
@ -159,7 +159,7 @@ abstract class ControllerTraitTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('serialize') ->method('serialize')
->with([], 'json', ['json_encode_options' => 0, 'other' => 'context']) ->with([], 'json', ['json_encode_options' => 0, 'other' => 'context'])
->will($this->returnValue('[]')); ->willReturn('[]');
$container->set('serializer', $serializer); $container->set('serializer', $serializer);

View File

@ -74,7 +74,7 @@ class RedirectControllerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('generate') ->method('generate')
->with($this->equalTo($route), $this->equalTo($expectedAttributes)) ->with($this->equalTo($route), $this->equalTo($expectedAttributes))
->will($this->returnValue($url)); ->willReturn($url);
$controller = new RedirectController($router); $controller = new RedirectController($router);
@ -247,7 +247,7 @@ class RedirectControllerTest extends TestCase
$request->query = new ParameterBag(['base' => 'zaza']); $request->query = new ParameterBag(['base' => 'zaza']);
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]); $request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
$urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zaza&base2=zaza'))->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL); $urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zaza&base2=zaza')->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
$controller = new RedirectController($urlGenerator); $controller = new RedirectController($urlGenerator);
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zaza&base2=zaza'); $this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zaza&base2=zaza');
@ -264,7 +264,7 @@ class RedirectControllerTest extends TestCase
$request->query = new ParameterBag(['base' => 'zaza']); $request->query = new ParameterBag(['base' => 'zaza']);
$request->attributes = new ParameterBag(['_route_params' => ['base' => 'zouzou']]); $request->attributes = new ParameterBag(['_route_params' => ['base' => 'zouzou']]);
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
$urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zouzou'))->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL); $urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zouzou')->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
$controller = new RedirectController($urlGenerator); $controller = new RedirectController($urlGenerator);
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zouzou'); $this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zouzou');
@ -276,23 +276,23 @@ class RedirectControllerTest extends TestCase
$request $request
->expects($this->any()) ->expects($this->any())
->method('getScheme') ->method('getScheme')
->will($this->returnValue($scheme)); ->willReturn($scheme);
$request $request
->expects($this->any()) ->expects($this->any())
->method('getHost') ->method('getHost')
->will($this->returnValue($host)); ->willReturn($host);
$request $request
->expects($this->any()) ->expects($this->any())
->method('getPort') ->method('getPort')
->will($this->returnValue($port)); ->willReturn($port);
$request $request
->expects($this->any()) ->expects($this->any())
->method('getBaseUrl') ->method('getBaseUrl')
->will($this->returnValue($baseUrl)); ->willReturn($baseUrl);
$request $request
->expects($this->any()) ->expects($this->any())
->method('getQueryString') ->method('getQueryString')
->will($this->returnValue($queryString)); ->willReturn($queryString);
return $request; return $request;
} }

View File

@ -506,7 +506,7 @@ class RouterTest extends TestCase
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('load') ->method('load')
->will($this->returnValue($routes)) ->willReturn($routes)
; ;
$sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock();
@ -514,7 +514,7 @@ class RouterTest extends TestCase
$sc $sc
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->will($this->returnValue($loader)) ->willReturn($loader)
; ;
return $sc; return $sc;
@ -527,7 +527,7 @@ class RouterTest extends TestCase
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('load') ->method('load')
->will($this->returnValue($routes)) ->willReturn($routes)
; ;
$sc = $this->getMockBuilder(ContainerInterface::class)->getMock(); $sc = $this->getMockBuilder(ContainerInterface::class)->getMock();
@ -535,7 +535,7 @@ class RouterTest extends TestCase
$sc $sc
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->will($this->returnValue($loader)) ->willReturn($loader)
; ;
return $sc; return $sc;
@ -547,9 +547,9 @@ class RouterTest extends TestCase
$bag $bag
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
->will($this->returnCallback(function ($key) use ($params) { ->willReturnCallback(function ($key) use ($params) {
return isset($params[$key]) ? $params[$key] : null; return isset($params[$key]) ? $params[$key] : null;
})) })
; ;
return $bag; return $bag;

View File

@ -70,7 +70,7 @@ class DelegatingEngineTest extends TestCase
$engine->expects($this->once()) $engine->expects($this->once())
->method('renderResponse') ->method('renderResponse')
->with('template.php', ['foo' => 'bar']) ->with('template.php', ['foo' => 'bar'])
->will($this->returnValue($response)); ->willReturn($response);
$container = $this->getContainerMock(['engine' => $engine]); $container = $this->getContainerMock(['engine' => $engine]);
$delegatingEngine = new DelegatingEngine($container, ['engine']); $delegatingEngine = new DelegatingEngine($container, ['engine']);
@ -94,7 +94,7 @@ class DelegatingEngineTest extends TestCase
$engine->expects($this->once()) $engine->expects($this->once())
->method('supports') ->method('supports')
->with($template) ->with($template)
->will($this->returnValue($supports)); ->willReturn($supports);
return $engine; return $engine;
} }
@ -106,7 +106,7 @@ class DelegatingEngineTest extends TestCase
$engine->expects($this->once()) $engine->expects($this->once())
->method('supports') ->method('supports')
->with($template) ->with($template)
->will($this->returnValue($supports)); ->willReturn($supports);
return $engine; return $engine;
} }
@ -120,7 +120,7 @@ class DelegatingEngineTest extends TestCase
$container->expects($this->at($i++)) $container->expects($this->at($i++))
->method('get') ->method('get')
->with($id) ->with($id)
->will($this->returnValue($service)); ->willReturn($service);
} }
return $container; return $container;

View File

@ -50,7 +50,7 @@ class GlobalVariablesTest extends TestCase
$tokenStorage $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
->will($this->returnValue('token')); ->willReturn('token');
$this->assertSame('token', $this->globals->getToken()); $this->assertSame('token', $this->globals->getToken());
} }
@ -80,12 +80,12 @@ class GlobalVariablesTest extends TestCase
$token $token
->expects($this->once()) ->expects($this->once())
->method('getUser') ->method('getUser')
->will($this->returnValue($user)); ->willReturn($user);
$tokenStorage $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
->will($this->returnValue($token)); ->willReturn($token);
$this->assertSame($expectedUser, $this->globals->getUser()); $this->assertSame($expectedUser, $this->globals->getUser());
} }

View File

@ -30,7 +30,7 @@ class TemplateLocatorTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->with($template->getPath()) ->with($template->getPath())
->will($this->returnValue('/path/to/template')) ->willReturn('/path/to/template')
; ;
$locator = new TemplateLocator($fileLocator); $locator = new TemplateLocator($fileLocator);

View File

@ -29,13 +29,13 @@ class TemplateNameParserTest extends TestCase
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
->will($this->returnCallback(function ($bundle) { ->willReturnCallback(function ($bundle) {
if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) { if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) {
return true; return true;
} }
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
})) })
; ;
$this->parser = new TemplateNameParser($kernel); $this->parser = new TemplateNameParser($kernel);
} }

View File

@ -34,7 +34,7 @@ class TimedPhpEngineTest extends TestCase
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('start') ->method('start')
->with('template.php (index.php)', 'template') ->with('template.php (index.php)', 'template')
->will($this->returnValue($stopwatchEvent)); ->willReturn($stopwatchEvent);
$stopwatchEvent->expects($this->once())->method('stop'); $stopwatchEvent->expects($this->once())->method('stop');
@ -59,7 +59,7 @@ class TimedPhpEngineTest extends TestCase
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any()) $templateNameParser->expects($this->any())
->method('parse') ->method('parse')
->will($this->returnValue($templateReference)); ->willReturn($templateReference);
return $templateNameParser; return $templateNameParser;
} }
@ -94,7 +94,7 @@ class TimedPhpEngineTest extends TestCase
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
$loader->expects($this->once()) $loader->expects($this->once())
->method('load') ->method('load')
->will($this->returnValue($storage)); ->willReturn($storage);
return $loader; return $loader;
} }

View File

@ -238,7 +238,7 @@ class WebTestCaseTest extends TestCase
private function getResponseTester(Response $response): WebTestCase private function getResponseTester(Response $response): WebTestCase
{ {
$client = $this->createMock(KernelBrowser::class); $client = $this->createMock(KernelBrowser::class);
$client->expects($this->any())->method('getResponse')->will($this->returnValue($response)); $client->expects($this->any())->method('getResponse')->willReturn($response);
return $this->getTester($client); return $this->getTester($client);
} }
@ -246,7 +246,7 @@ class WebTestCaseTest extends TestCase
private function getCrawlerTester(Crawler $crawler): WebTestCase private function getCrawlerTester(Crawler $crawler): WebTestCase
{ {
$client = $this->createMock(KernelBrowser::class); $client = $this->createMock(KernelBrowser::class);
$client->expects($this->any())->method('getCrawler')->will($this->returnValue($crawler)); $client->expects($this->any())->method('getCrawler')->willReturn($crawler);
return $this->getTester($client); return $this->getTester($client);
} }
@ -256,7 +256,7 @@ class WebTestCaseTest extends TestCase
$client = $this->createMock(KernelBrowser::class); $client = $this->createMock(KernelBrowser::class);
$jar = new CookieJar(); $jar = new CookieJar();
$jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com')); $jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com'));
$client->expects($this->any())->method('getCookieJar')->will($this->returnValue($jar)); $client->expects($this->any())->method('getCookieJar')->willReturn($jar);
return $this->getTester($client); return $this->getTester($client);
} }
@ -267,7 +267,7 @@ class WebTestCaseTest extends TestCase
$request = new Request(); $request = new Request();
$request->attributes->set('foo', 'bar'); $request->attributes->set('foo', 'bar');
$request->attributes->set('_route', 'homepage'); $request->attributes->set('_route', 'homepage');
$client->expects($this->any())->method('getRequest')->will($this->returnValue($request)); $client->expects($this->any())->method('getRequest')->willReturn($request);
return $this->getTester($client); return $this->getTester($client);
} }

View File

@ -267,53 +267,53 @@ class TranslatorTest extends TestCase
$loader $loader
->expects($this->at(0)) ->expects($this->at(0))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('fr', [ ->willReturn($this->getCatalogue('fr', [
'foo' => 'foo (FR)', 'foo' => 'foo (FR)',
]))) ]))
; ;
$loader $loader
->expects($this->at(1)) ->expects($this->at(1))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('en', [ ->willReturn($this->getCatalogue('en', [
'foo' => 'foo (EN)', 'foo' => 'foo (EN)',
'bar' => 'bar (EN)', 'bar' => 'bar (EN)',
'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)', 'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)',
]))) ]))
; ;
$loader $loader
->expects($this->at(2)) ->expects($this->at(2))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('es', [ ->willReturn($this->getCatalogue('es', [
'foobar' => 'foobar (ES)', 'foobar' => 'foobar (ES)',
]))) ]))
; ;
$loader $loader
->expects($this->at(3)) ->expects($this->at(3))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('pt-PT', [ ->willReturn($this->getCatalogue('pt-PT', [
'foobarfoo' => 'foobarfoo (PT-PT)', 'foobarfoo' => 'foobarfoo (PT-PT)',
]))) ]))
; ;
$loader $loader
->expects($this->at(4)) ->expects($this->at(4))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('pt_BR', [ ->willReturn($this->getCatalogue('pt_BR', [
'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)',
]))) ]))
; ;
$loader $loader
->expects($this->at(5)) ->expects($this->at(5))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('fr.UTF-8', [ ->willReturn($this->getCatalogue('fr.UTF-8', [
'foobarbaz' => 'foobarbaz (fr.UTF-8)', 'foobarbaz' => 'foobarbaz (fr.UTF-8)',
]))) ]))
; ;
$loader $loader
->expects($this->at(6)) ->expects($this->at(6))
->method('load') ->method('load')
->will($this->returnValue($this->getCatalogue('sr@latin', [ ->willReturn($this->getCatalogue('sr@latin', [
'foobarbax' => 'foobarbax (sr@latin)', 'foobarbax' => 'foobarbax (sr@latin)',
]))) ]))
; ;
return $loader; return $loader;
@ -325,7 +325,7 @@ class TranslatorTest extends TestCase
$container $container
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
->will($this->returnValue($loader)) ->willReturn($loader)
; ;
return $container; return $container;

View File

@ -132,17 +132,17 @@ class AbstractFactoryTest extends TestCase
$factory $factory
->expects($this->once()) ->expects($this->once())
->method('createAuthProvider') ->method('createAuthProvider')
->will($this->returnValue('auth_provider')) ->willReturn('auth_provider')
; ;
$factory $factory
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('getListenerId') ->method('getListenerId')
->will($this->returnValue('abstract_listener')) ->willReturn('abstract_listener')
; ;
$factory $factory
->expects($this->any()) ->expects($this->any())
->method('getKey') ->method('getKey')
->will($this->returnValue('abstract_factory')) ->willReturn('abstract_factory')
; ;
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -44,7 +44,7 @@ class PreviewErrorControllerTest extends TestCase
}), }),
$this->equalTo(HttpKernelInterface::SUB_REQUEST) $this->equalTo(HttpKernelInterface::SUB_REQUEST)
) )
->will($this->returnValue($response)); ->willReturn($response);
$controller = new PreviewErrorController($kernel, $logicalControllerName); $controller = new PreviewErrorController($kernel, $logicalControllerName);

View File

@ -24,7 +24,7 @@ class FilesystemLoaderTest extends TestCase
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')) ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')
; ;
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates', 'namespace'); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates', 'namespace');
@ -44,7 +44,7 @@ class FilesystemLoaderTest extends TestCase
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')) ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/templates/layout.html.twig')
; ;
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);
@ -61,7 +61,7 @@ class FilesystemLoaderTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('parse') ->method('parse')
->with('name.format.engine') ->with('name.format.engine')
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine'))
; ;
$locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
@ -85,14 +85,14 @@ class FilesystemLoaderTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('parse') ->method('parse')
->with('name.format.engine') ->with('name.format.engine')
->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine'))
; ;
$locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->will($this->returnValue(false)) ->willReturn(false)
; ;
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);

View File

@ -18,13 +18,13 @@ class TemplateIteratorTest extends TestCase
public function testGetIterator() public function testGetIterator()
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); $bundle->expects($this->any())->method('getName')->willReturn('BarBundle');
$bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
$kernel->expects($this->any())->method('getBundles')->will($this->returnValue([ $kernel->expects($this->any())->method('getBundles')->willReturn([
$bundle, $bundle,
])); ]);
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates');
$sorted = iterator_to_array($iterator); $sorted = iterator_to_array($iterator);

View File

@ -97,11 +97,11 @@ class ProfilerControllerTest extends TestCase
$profiler $profiler
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('loadProfile') ->method('loadProfile')
->will($this->returnCallback(function ($token) { ->willReturnCallback(function ($token) {
if ('found' == $token) { if ('found' == $token) {
return new Profile($token); return new Profile($token);
} }
})) })
; ;
$controller = $this->createController($profiler, $twig, $withCsp); $controller = $this->createController($profiler, $twig, $withCsp);
@ -149,7 +149,7 @@ class ProfilerControllerTest extends TestCase
$profiler $profiler
->expects($this->once()) ->expects($this->once())
->method('find') ->method('find')
->will($this->returnValue($tokens)); ->willReturn($tokens);
$request = Request::create('/_profiler/empty/search/results', 'GET', [ $request = Request::create('/_profiler/empty/search/results', 'GET', [
'limit' => 2, 'limit' => 2,

View File

@ -200,7 +200,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
$generator->expects($this->any()) $generator->expects($this->any())
->method('generate') ->method('generate')
->will($this->returnValue($value)); ->willReturn($value);
return $generator; return $generator;
} }

View File

@ -244,7 +244,7 @@ class WebDebugToolbarListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('generate') ->method('generate')
->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL) ->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL)
->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx')) ->willReturn('http://mydomain.com/_profiler/xxxxxxxx')
; ;
$event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $event = new ResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
@ -302,10 +302,10 @@ class WebDebugToolbarListenerTest extends TestCase
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock();
$request->expects($this->any()) $request->expects($this->any())
->method('isXmlHttpRequest') ->method('isXmlHttpRequest')
->will($this->returnValue($isXmlHttpRequest)); ->willReturn($isXmlHttpRequest);
$request->expects($this->any()) $request->expects($this->any())
->method('getRequestFormat') ->method('getRequestFormat')
->will($this->returnValue($requestFormat)); ->willReturn($requestFormat);
$request->headers = new HeaderBag(); $request->headers = new HeaderBag();
@ -313,7 +313,7 @@ class WebDebugToolbarListenerTest extends TestCase
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
$request->expects($this->any()) $request->expects($this->any())
->method('getSession') ->method('getSession')
->will($this->returnValue($session)); ->willReturn($session);
} }
return $request; return $request;
@ -324,7 +324,7 @@ class WebDebugToolbarListenerTest extends TestCase
$templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
$templating->expects($this->any()) $templating->expects($this->any())
->method('render') ->method('render')
->will($this->returnValue($render)); ->willReturn($render);
return $templating; return $templating;
} }

View File

@ -69,7 +69,7 @@ class TemplateManagerTest extends TestCase
$this->profiler->expects($this->any()) $this->profiler->expects($this->any())
->method('has') ->method('has')
->withAnyParameters() ->withAnyParameters()
->will($this->returnCallback([$this, 'profilerHasCallback'])); ->willReturnCallback([$this, 'profilerHasCallback']);
$this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo')); $this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo'));
} }
@ -107,14 +107,14 @@ class TemplateManagerTest extends TestCase
$this->twigEnvironment->expects($this->any()) $this->twigEnvironment->expects($this->any())
->method('loadTemplate') ->method('loadTemplate')
->will($this->returnValue('loadedTemplate')); ->willReturn('loadedTemplate');
if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) { if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) {
$loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock(); $loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock();
} else { } else {
$loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock();
} }
$this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); $this->twigEnvironment->expects($this->any())->method('getLoader')->willReturn($loader);
return $this->twigEnvironment; return $this->twigEnvironment;
} }

View File

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

View File

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

View File

@ -47,7 +47,7 @@ class BrowserCookieValueSameTest extends TestCase
$browser = $this->createMock(AbstractBrowser::class); $browser = $this->createMock(AbstractBrowser::class);
$jar = new CookieJar(); $jar = new CookieJar();
$jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com')); $jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com'));
$browser->expects($this->any())->method('getCookieJar')->will($this->returnValue($jar)); $browser->expects($this->any())->method('getCookieJar')->willReturn($jar);
return $browser; return $browser;
} }

View File

@ -77,7 +77,7 @@ class BrowserHasCookieTest extends TestCase
$browser = $this->createMock(AbstractBrowser::class); $browser = $this->createMock(AbstractBrowser::class);
$jar = new CookieJar(); $jar = new CookieJar();
$jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com')); $jar->set(new Cookie('foo', 'bar', null, '/path', 'example.com'));
$browser->expects($this->any())->method('getCookieJar')->will($this->returnValue($jar)); $browser->expects($this->any())->method('getCookieJar')->willReturn($jar);
return $browser; return $browser;
} }

View File

@ -84,7 +84,7 @@ class ChainAdapterTest extends AdapterTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(true)); ->willReturn(true);
return $pruneable; return $pruneable;
} }
@ -101,7 +101,7 @@ class ChainAdapterTest extends AdapterTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(false)); ->willReturn(false);
return $pruneable; return $pruneable;
} }

View File

@ -76,7 +76,7 @@ class TagAwareAdapterTest extends AdapterTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(true)); ->willReturn(true);
return $pruneable; return $pruneable;
} }
@ -93,7 +93,7 @@ class TagAwareAdapterTest extends AdapterTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(false)); ->willReturn(false);
return $pruneable; return $pruneable;
} }

View File

@ -79,7 +79,7 @@ class ChainCacheTest extends CacheTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(true)); ->willReturn(true);
return $pruneable; return $pruneable;
} }
@ -96,7 +96,7 @@ class ChainCacheTest extends CacheTestCase
$pruneable $pruneable
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('prune') ->method('prune')
->will($this->returnValue(false)); ->willReturn(false);
return $pruneable; return $pruneable;
} }

View File

@ -35,12 +35,12 @@ class DelegatingLoaderTest extends TestCase
public function testSupports() public function testSupports()
{ {
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader1->expects($this->once())->method('supports')->willReturn(true);
$loader = new DelegatingLoader(new LoaderResolver([$loader1])); $loader = new DelegatingLoader(new LoaderResolver([$loader1]));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); $loader1->expects($this->once())->method('supports')->willReturn(false);
$loader = new DelegatingLoader(new LoaderResolver([$loader1])); $loader = new DelegatingLoader(new LoaderResolver([$loader1]));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
} }
@ -48,7 +48,7 @@ class DelegatingLoaderTest extends TestCase
public function testLoad() public function testLoad()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader->expects($this->once())->method('supports')->willReturn(true);
$loader->expects($this->once())->method('load'); $loader->expects($this->once())->method('load');
$resolver = new LoaderResolver([$loader]); $resolver = new LoaderResolver([$loader]);
$loader = new DelegatingLoader($resolver); $loader = new DelegatingLoader($resolver);
@ -62,7 +62,7 @@ class DelegatingLoaderTest extends TestCase
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(false)); $loader->expects($this->once())->method('supports')->willReturn(false);
$resolver = new LoaderResolver([$loader]); $resolver = new LoaderResolver([$loader]);
$loader = new DelegatingLoader($resolver); $loader = new DelegatingLoader($resolver);

View File

@ -32,7 +32,7 @@ class LoaderResolverTest extends TestCase
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader->expects($this->once())->method('supports')->willReturn(true);
$resolver = new LoaderResolver([$loader]); $resolver = new LoaderResolver([$loader]);
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
} }

View File

@ -34,7 +34,7 @@ class LoaderTest extends TestCase
$resolver->expects($this->once()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo.xml') ->with('foo.xml')
->will($this->returnValue($resolvedLoader)); ->willReturn($resolvedLoader);
$loader = new ProjectLoader1(); $loader = new ProjectLoader1();
$loader->setResolver($resolver); $loader->setResolver($resolver);
@ -52,7 +52,7 @@ class LoaderTest extends TestCase
$resolver->expects($this->once()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('FOOBAR') ->with('FOOBAR')
->will($this->returnValue(false)); ->willReturn(false);
$loader = new ProjectLoader1(); $loader = new ProjectLoader1();
$loader->setResolver($resolver); $loader->setResolver($resolver);
@ -66,13 +66,13 @@ class LoaderTest extends TestCase
$resolvedLoader->expects($this->once()) $resolvedLoader->expects($this->once())
->method('load') ->method('load')
->with('foo') ->with('foo')
->will($this->returnValue('yes')); ->willReturn('yes');
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo') ->with('foo')
->will($this->returnValue($resolvedLoader)); ->willReturn($resolvedLoader);
$loader = new ProjectLoader1(); $loader = new ProjectLoader1();
$loader->setResolver($resolver); $loader->setResolver($resolver);
@ -86,13 +86,13 @@ class LoaderTest extends TestCase
$resolvedLoader->expects($this->once()) $resolvedLoader->expects($this->once())
->method('load') ->method('load')
->with('foo', 'bar') ->with('foo', 'bar')
->will($this->returnValue('yes')); ->willReturn('yes');
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once()) $resolver->expects($this->once())
->method('resolve') ->method('resolve')
->with('foo', 'bar') ->with('foo', 'bar')
->will($this->returnValue($resolvedLoader)); ->willReturn($resolvedLoader);
$loader = new ProjectLoader1(); $loader = new ProjectLoader1();
$loader->setResolver($resolver); $loader->setResolver($resolver);

View File

@ -709,7 +709,7 @@ class ApplicationTest extends TestCase
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock(); $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock();
$application->expects($this->once()) $application->expects($this->once())
->method('getNamespaces') ->method('getNamespaces')
->will($this->returnValue(['foo:sublong', 'bar:sub'])); ->willReturn(['foo:sublong', 'bar:sub']);
$this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); $this->assertEquals('foo:sublong', $application->findNamespace('f:sub'));
} }
@ -853,7 +853,7 @@ class ApplicationTest extends TestCase
$application->setAutoExit(false); $application->setAutoExit(false);
$application->expects($this->any()) $application->expects($this->any())
->method('getTerminalWidth') ->method('getTerminalWidth')
->will($this->returnValue(120)); ->willReturn(120);
$application->register('foo')->setCode(function () { $application->register('foo')->setCode(function () {
throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n");
}); });

View File

@ -321,7 +321,7 @@ class CommandTest extends TestCase
$command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock(); $command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock();
$command->expects($this->once()) $command->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue('2.3')); ->willReturn('2.3');
$exitCode = $command->run(new StringInput(''), new NullOutput()); $exitCode = $command->run(new StringInput(''), new NullOutput());
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
} }

View File

@ -21,7 +21,7 @@ abstract class AbstractQuestionHelperTest extends TestCase
$mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock(); $mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock();
$mock->expects($this->any()) $mock->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue($interactive)); ->willReturn($interactive);
if ($stream) { if ($stream) {
$mock->expects($this->any()) $mock->expects($this->any())

View File

@ -114,7 +114,7 @@ class HelperSetTest extends TestCase
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock(); $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
$mock_helper->expects($this->any()) $mock_helper->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($name)); ->willReturn($name);
if ($helperset) { if ($helperset) {
$mock_helper->expects($this->any()) $mock_helper->expects($this->any())

View File

@ -760,7 +760,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any()) $mock->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue($interactive)); ->willReturn($interactive);
return $mock; return $mock;
} }

View File

@ -154,7 +154,7 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$mock->expects($this->any()) $mock->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue($interactive)); ->willReturn($interactive);
return $mock; return $mock;
} }

View File

@ -166,7 +166,7 @@ class ConsoleLoggerTest extends TestCase
} else { } else {
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']); $dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
} }
$dummy->method('__toString')->will($this->returnValue('DUMMY')); $dummy->method('__toString')->willReturn('DUMMY');
$this->getLogger()->warning($dummy); $this->getLogger()->warning($dummy);

View File

@ -234,7 +234,7 @@ class ErrorHandlerTest extends TestCase
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
->will($this->returnCallback($warnArgCheck)) ->willReturnCallback($warnArgCheck)
; ;
$handler = ErrorHandler::register(); $handler = ErrorHandler::register();
@ -262,7 +262,7 @@ class ErrorHandlerTest extends TestCase
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
->will($this->returnCallback($logArgCheck)) ->willReturnCallback($logArgCheck)
; ;
$handler = ErrorHandler::register(); $handler = ErrorHandler::register();
@ -318,7 +318,7 @@ class ErrorHandlerTest extends TestCase
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
->will($this->returnCallback($logArgCheck)) ->willReturnCallback($logArgCheck)
; ;
$handler = new ErrorHandler(); $handler = new ErrorHandler();
@ -346,7 +346,7 @@ class ErrorHandlerTest extends TestCase
$logger $logger
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('log') ->method('log')
->will($this->returnCallback($logArgCheck)) ->willReturnCallback($logArgCheck)
; ;
$handler->setDefaultLogger($logger, E_ERROR); $handler->setDefaultLogger($logger, E_ERROR);
@ -462,7 +462,7 @@ class ErrorHandlerTest extends TestCase
$logger $logger
->expects($this->once()) ->expects($this->once())
->method('log') ->method('log')
->will($this->returnCallback($logArgCheck)) ->willReturnCallback($logArgCheck)
; ;
$handler->setDefaultLogger($logger, E_PARSE); $handler->setDefaultLogger($logger, E_PARSE);

View File

@ -30,18 +30,18 @@ class MergeExtensionConfigurationPassTest extends TestCase
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->any()) $extension->expects($this->any())
->method('getXsdValidationBasePath') ->method('getXsdValidationBasePath')
->will($this->returnValue(false)); ->willReturn(false);
$extension->expects($this->any()) $extension->expects($this->any())
->method('getNamespace') ->method('getNamespace')
->will($this->returnValue('http://example.org/schema/dic/foo')); ->willReturn('http://example.org/schema/dic/foo');
$extension->expects($this->any()) $extension->expects($this->any())
->method('getAlias') ->method('getAlias')
->will($this->returnValue('foo')); ->willReturn('foo');
$extension->expects($this->once()) $extension->expects($this->once())
->method('load') ->method('load')
->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { ->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
$tmpProviders = $container->getExpressionLanguageProviders(); $tmpProviders = $container->getExpressionLanguageProviders();
})); });
$provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
$container = new ContainerBuilder(new ParameterBag()); $container = new ContainerBuilder(new ParameterBag());
@ -76,7 +76,7 @@ class MergeExtensionConfigurationPassTest extends TestCase
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock(); $extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock();
$extension->expects($this->exactly(2)) $extension->expects($this->exactly(2))
->method('getConfiguration') ->method('getConfiguration')
->will($this->returnValue(new FooConfiguration())); ->willReturn(new FooConfiguration());
$container = new ContainerBuilder(new ParameterBag()); $container = new ContainerBuilder(new ParameterBag());
$container->registerExtension($extension); $container->registerExtension($extension);

View File

@ -67,10 +67,10 @@ class ContainerParametersResourceCheckerTest extends TestCase
[$this->equalTo('locales')], [$this->equalTo('locales')],
[$this->equalTo('default_locale')] [$this->equalTo('default_locale')]
) )
->will($this->returnValueMap([ ->willReturnMap([
['locales', ['fr', 'en']], ['locales', ['fr', 'en']],
['default_locale', 'fr'], ['default_locale', 'fr'],
])) ])
; ;
}, true]; }, true];
} }

View File

@ -1066,7 +1066,7 @@ class ContainerBuilderTest extends TestCase
public function testRegisteredButNotLoadedExtension() public function testRegisteredButNotLoadedExtension()
{ {
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->once())->method('getAlias')->will($this->returnValue('project')); $extension->expects($this->once())->method('getAlias')->willReturn('project');
$extension->expects($this->never())->method('load'); $extension->expects($this->never())->method('load');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
@ -1078,7 +1078,7 @@ class ContainerBuilderTest extends TestCase
public function testRegisteredAndLoadedExtension() public function testRegisteredAndLoadedExtension()
{ {
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
$extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project')); $extension->expects($this->exactly(2))->method('getAlias')->willReturn('project');
$extension->expects($this->once())->method('load')->with([['foo' => 'bar']]); $extension->expects($this->once())->method('load')->with([['foo' => 'bar']]);
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -862,13 +862,13 @@ class FormTest extends TestCase
$field $field
->expects($this->any()) ->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($name)) ->willReturn($name)
; ;
$field $field
->expects($this->any()) ->expects($this->any())
->method('getValue') ->method('getValue')
->will($this->returnValue($value)) ->willReturn($value)
; ;
return $field; return $field;

View File

@ -43,7 +43,7 @@ class ImmutableEventDispatcherTest extends TestCase
$this->innerDispatcher->expects($this->once()) $this->innerDispatcher->expects($this->once())
->method('dispatch') ->method('dispatch')
->with($event, 'event') ->with($event, 'event')
->will($this->returnValue('result')); ->willReturn('result');
$this->assertSame('result', $this->dispatcher->dispatch($event, 'event')); $this->assertSame('result', $this->dispatcher->dispatch($event, 'event'));
} }
@ -53,7 +53,7 @@ class ImmutableEventDispatcherTest extends TestCase
$this->innerDispatcher->expects($this->once()) $this->innerDispatcher->expects($this->once())
->method('getListeners') ->method('getListeners')
->with('event') ->with('event')
->will($this->returnValue('result')); ->willReturn('result');
$this->assertSame('result', $this->dispatcher->getListeners('event')); $this->assertSame('result', $this->dispatcher->getListeners('event'));
} }
@ -63,7 +63,7 @@ class ImmutableEventDispatcherTest extends TestCase
$this->innerDispatcher->expects($this->once()) $this->innerDispatcher->expects($this->once())
->method('hasListeners') ->method('hasListeners')
->with('event') ->with('event')
->will($this->returnValue('result')); ->willReturn('result');
$this->assertSame('result', $this->dispatcher->hasListeners('event')); $this->assertSame('result', $this->dispatcher->hasListeners('event'));
} }

View File

@ -36,18 +36,18 @@ class ExpressionLanguageTest extends TestCase
$cacheItemMock $cacheItemMock
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('get') ->method('get')
->will($this->returnCallback(function () use (&$savedParsedExpression) { ->willReturnCallback(function () use (&$savedParsedExpression) {
return $savedParsedExpression; return $savedParsedExpression;
})) })
; ;
$cacheItemMock $cacheItemMock
->expects($this->exactly(1)) ->expects($this->exactly(1))
->method('set') ->method('set')
->with($this->isInstanceOf(ParsedExpression::class)) ->with($this->isInstanceOf(ParsedExpression::class))
->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
$savedParsedExpression = $parsedExpression; $savedParsedExpression = $parsedExpression;
})) })
; ;
$cacheMock $cacheMock
@ -172,18 +172,18 @@ class ExpressionLanguageTest extends TestCase
$cacheItemMock $cacheItemMock
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('get') ->method('get')
->will($this->returnCallback(function () use (&$savedParsedExpression) { ->willReturnCallback(function () use (&$savedParsedExpression) {
return $savedParsedExpression; return $savedParsedExpression;
})) })
; ;
$cacheItemMock $cacheItemMock
->expects($this->exactly(1)) ->expects($this->exactly(1))
->method('set') ->method('set')
->with($this->isInstanceOf(ParsedExpression::class)) ->with($this->isInstanceOf(ParsedExpression::class))
->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
$savedParsedExpression = $parsedExpression; $savedParsedExpression = $parsedExpression;
})) })
; ;
$cacheMock $cacheMock

View File

@ -473,7 +473,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
{ {
$this->csrfTokenManager->expects($this->any()) $this->csrfTokenManager->expects($this->any())
->method('getToken') ->method('getToken')
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); ->willReturn(new CsrfToken('token_id', 'foo&bar'));
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
->add($this->factory ->add($this->factory

View File

@ -312,10 +312,10 @@ abstract class AbstractRequestHandlerTest extends TestCase
{ {
$this->serverParams->expects($this->once()) $this->serverParams->expects($this->once())
->method('getContentLength') ->method('getContentLength')
->will($this->returnValue($contentLength)); ->willReturn($contentLength);
$this->serverParams->expects($this->any()) $this->serverParams->expects($this->any())
->method('getNormalizedIniPostMaxSize') ->method('getNormalizedIniPostMaxSize')
->will($this->returnValue($iniMax)); ->willReturn($iniMax);
$options = ['post_max_size_message' => 'Max {{ max }}!']; $options = ['post_max_size_message' => 'Max {{ max }}!'];
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options); $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);

View File

@ -339,7 +339,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
{ {
$this->csrfTokenManager->expects($this->any()) $this->csrfTokenManager->expects($this->any())
->method('getToken') ->method('getToken')
->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); ->willReturn(new CsrfToken('token_id', 'foo&bar'));
$form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType')
->add($this->factory ->add($this->factory

View File

@ -42,7 +42,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with([]) ->with([])
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices([])); $this->assertSame($list, $this->factory->createListFromChoices([]));
$this->assertSame($list, $this->factory->createListFromChoices([])); $this->assertSame($list, $this->factory->createListFromChoices([]));
@ -58,7 +58,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices2) ->with($choices2)
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices1));
$this->assertSame($list, $this->factory->createListFromChoices($choices2)); $this->assertSame($list, $this->factory->createListFromChoices($choices2));
@ -74,11 +74,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices1) ->with($choices1)
->will($this->returnValue($list1)); ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices2) ->with($choices2)
->will($this->returnValue($list2)); ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list1, $this->factory->createListFromChoices($choices1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices2)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2));
@ -96,7 +96,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices1) ->with($choices1)
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices1));
$this->assertSame($list, $this->factory->createListFromChoices($choices2)); $this->assertSame($list, $this->factory->createListFromChoices($choices2));
@ -115,11 +115,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices1) ->with($choices1)
->will($this->returnValue($list1)); ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices2) ->with($choices2)
->will($this->returnValue($list2)); ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list1, $this->factory->createListFromChoices($choices1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices2)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2));
@ -134,7 +134,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $closure) ->with($choices, $closure)
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure));
$this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure));
@ -151,11 +151,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $closure1) ->with($choices, $closure1)
->will($this->returnValue($list1)); ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $closure2) ->with($choices, $closure2)
->will($this->returnValue($list2)); ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1)); $this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1));
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2)); $this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
@ -169,7 +169,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader) ->with($loader)
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromLoader($loader)); $this->assertSame($list, $this->factory->createListFromLoader($loader));
$this->assertSame($list, $this->factory->createListFromLoader($loader)); $this->assertSame($list, $this->factory->createListFromLoader($loader));
@ -185,11 +185,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader1) ->with($loader1)
->will($this->returnValue($list1)); ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader2) ->with($loader2)
->will($this->returnValue($list2)); ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromLoader($loader1)); $this->assertSame($list1, $this->factory->createListFromLoader($loader1));
$this->assertSame($list2, $this->factory->createListFromLoader($loader2)); $this->assertSame($list2, $this->factory->createListFromLoader($loader2));
@ -204,7 +204,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $closure) ->with($loader, $closure)
->will($this->returnValue($list)); ->willReturn($list);
$this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure));
$this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure));
@ -221,11 +221,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $closure1) ->with($loader, $closure1)
->will($this->returnValue($list1)); ->willReturn($list1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $closure2) ->with($loader, $closure2)
->will($this->returnValue($list2)); ->willReturn($list2);
$this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1)); $this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1));
$this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2)); $this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2));
@ -240,7 +240,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, $preferred) ->with($list, $preferred)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred));
@ -257,11 +257,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, $preferred1) ->with($list, $preferred1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, $preferred2) ->with($list, $preferred2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view1, $this->factory->createView($list, $preferred1));
$this->assertSame($view2, $this->factory->createView($list, $preferred2)); $this->assertSame($view2, $this->factory->createView($list, $preferred2));
@ -276,7 +276,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, $preferred) ->with($list, $preferred)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred));
@ -293,11 +293,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, $preferred1) ->with($list, $preferred1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, $preferred2) ->with($list, $preferred2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view1, $this->factory->createView($list, $preferred1));
$this->assertSame($view2, $this->factory->createView($list, $preferred2)); $this->assertSame($view2, $this->factory->createView($list, $preferred2));
@ -312,7 +312,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, $labels) ->with($list, null, $labels)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, $labels)); $this->assertSame($view, $this->factory->createView($list, null, $labels));
$this->assertSame($view, $this->factory->createView($list, null, $labels)); $this->assertSame($view, $this->factory->createView($list, null, $labels));
@ -329,11 +329,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, null, $labels1) ->with($list, null, $labels1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, null, $labels2) ->with($list, null, $labels2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, $labels1)); $this->assertSame($view1, $this->factory->createView($list, null, $labels1));
$this->assertSame($view2, $this->factory->createView($list, null, $labels2)); $this->assertSame($view2, $this->factory->createView($list, null, $labels2));
@ -348,7 +348,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, $index) ->with($list, null, null, $index)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, $index)); $this->assertSame($view, $this->factory->createView($list, null, null, $index));
$this->assertSame($view, $this->factory->createView($list, null, null, $index)); $this->assertSame($view, $this->factory->createView($list, null, null, $index));
@ -365,11 +365,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, null, null, $index1) ->with($list, null, null, $index1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, null, null, $index2) ->with($list, null, null, $index2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, $index1)); $this->assertSame($view1, $this->factory->createView($list, null, null, $index1));
$this->assertSame($view2, $this->factory->createView($list, null, null, $index2)); $this->assertSame($view2, $this->factory->createView($list, null, null, $index2));
@ -384,7 +384,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, $groupBy) ->with($list, null, null, null, $groupBy)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
@ -401,11 +401,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, null, null, null, $groupBy1) ->with($list, null, null, null, $groupBy1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, null, null, null, $groupBy2) ->with($list, null, null, null, $groupBy2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1)); $this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2));
@ -420,7 +420,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr) ->with($list, null, null, null, null, $attr)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
@ -437,11 +437,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr1) ->with($list, null, null, null, null, $attr1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr2) ->with($list, null, null, null, null, $attr2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2));
@ -456,7 +456,7 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr) ->with($list, null, null, null, null, $attr)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
@ -473,11 +473,11 @@ class CachingFactoryDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->at(0)) $this->decoratedFactory->expects($this->at(0))
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr1) ->with($list, null, null, null, null, $attr1)
->will($this->returnValue($view1)); ->willReturn($view1);
$this->decoratedFactory->expects($this->at(1)) $this->decoratedFactory->expects($this->at(1))
->method('createView') ->method('createView')
->with($list, null, null, null, null, $attr2) ->with($list, null, null, null, null, $attr2)
->will($this->returnValue($view2)); ->willReturn($view2);
$this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2));

View File

@ -43,9 +43,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure')) ->with($choices, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($choices, $callback) { ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices); return array_map($callback, $choices);
})); });
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property')); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property'));
} }
@ -57,9 +57,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure')) ->with($choices, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($choices, $callback) { ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices); return array_map($callback, $choices);
})); });
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property')));
} }
@ -71,9 +71,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure')) ->with($loader, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($loader, $callback) { ->willReturnCallback(function ($loader, $callback) {
return $callback((object) ['property' => 'value']); return $callback((object) ['property' => 'value']);
})); });
$this->assertSame('value', $this->factory->createListFromLoader($loader, 'property')); $this->assertSame('value', $this->factory->createListFromLoader($loader, 'property'));
} }
@ -86,9 +86,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromChoices') ->method('createListFromChoices')
->with($choices, $this->isInstanceOf('\Closure')) ->with($choices, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($choices, $callback) { ->willReturnCallback(function ($choices, $callback) {
return array_map($callback, $choices); return array_map($callback, $choices);
})); });
$this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')); $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property'));
} }
@ -101,9 +101,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure')) ->with($loader, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($loader, $callback) { ->willReturnCallback(function ($loader, $callback) {
return $callback(null); return $callback(null);
})); });
$this->assertNull($this->factory->createListFromLoader($loader, 'property')); $this->assertNull($this->factory->createListFromLoader($loader, 'property'));
} }
@ -115,9 +115,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createListFromLoader') ->method('createListFromLoader')
->with($loader, $this->isInstanceOf('\Closure')) ->with($loader, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($loader, $callback) { ->willReturnCallback(function ($loader, $callback) {
return $callback((object) ['property' => 'value']); return $callback((object) ['property' => 'value']);
})); });
$this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property'))); $this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property')));
} }
@ -129,9 +129,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, $this->isInstanceOf('\Closure')) ->with($list, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred) { ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['property' => true]); return $preferred((object) ['property' => true]);
})); });
$this->assertTrue($this->factory->createView( $this->assertTrue($this->factory->createView(
$list, $list,
@ -146,9 +146,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, $this->isInstanceOf('\Closure')) ->with($list, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred) { ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['property' => true]); return $preferred((object) ['property' => true]);
})); });
$this->assertTrue($this->factory->createView( $this->assertTrue($this->factory->createView(
$list, $list,
@ -164,9 +164,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, $this->isInstanceOf('\Closure')) ->with($list, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred) { ->willReturnCallback(function ($list, $preferred) {
return $preferred((object) ['category' => null]); return $preferred((object) ['category' => null]);
})); });
$this->assertFalse($this->factory->createView( $this->assertFalse($this->factory->createView(
$list, $list,
@ -181,9 +181,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, $this->isInstanceOf('\Closure')) ->with($list, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label) { ->willReturnCallback(function ($list, $preferred, $label) {
return $label((object) ['property' => 'label']); return $label((object) ['property' => 'label']);
})); });
$this->assertSame('label', $this->factory->createView( $this->assertSame('label', $this->factory->createView(
$list, $list,
@ -199,9 +199,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, $this->isInstanceOf('\Closure')) ->with($list, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label) { ->willReturnCallback(function ($list, $preferred, $label) {
return $label((object) ['property' => 'label']); return $label((object) ['property' => 'label']);
})); });
$this->assertSame('label', $this->factory->createView( $this->assertSame('label', $this->factory->createView(
$list, $list,
@ -217,9 +217,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index) { ->willReturnCallback(function ($list, $preferred, $label, $index) {
return $index((object) ['property' => 'index']); return $index((object) ['property' => 'index']);
})); });
$this->assertSame('index', $this->factory->createView( $this->assertSame('index', $this->factory->createView(
$list, $list,
@ -236,9 +236,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index) { ->willReturnCallback(function ($list, $preferred, $label, $index) {
return $index((object) ['property' => 'index']); return $index((object) ['property' => 'index']);
})); });
$this->assertSame('index', $this->factory->createView( $this->assertSame('index', $this->factory->createView(
$list, $list,
@ -255,9 +255,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['property' => 'group']); return $groupBy((object) ['property' => 'group']);
})); });
$this->assertSame('group', $this->factory->createView( $this->assertSame('group', $this->factory->createView(
$list, $list,
@ -275,9 +275,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['property' => 'group']); return $groupBy((object) ['property' => 'group']);
})); });
$this->assertSame('group', $this->factory->createView( $this->assertSame('group', $this->factory->createView(
$list, $list,
@ -296,9 +296,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return $groupBy((object) ['group' => null]); return $groupBy((object) ['group' => null]);
})); });
$this->assertNull($this->factory->createView( $this->assertNull($this->factory->createView(
$list, $list,
@ -316,9 +316,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return $attr((object) ['property' => 'attr']); return $attr((object) ['property' => 'attr']);
})); });
$this->assertSame('attr', $this->factory->createView( $this->assertSame('attr', $this->factory->createView(
$list, $list,
@ -337,9 +337,9 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once()) $this->decoratedFactory->expects($this->once())
->method('createView') ->method('createView')
->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) ->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return $attr((object) ['property' => 'attr']); return $attr((object) ['property' => 'attr']);
})); });
$this->assertSame('attr', $this->factory->createView( $this->assertSame('attr', $this->factory->createView(
$list, $list,

View File

@ -49,12 +49,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
// The same list is returned by the loader // The same list is returned by the loader
$this->loadedList->expects($this->exactly(2)) $this->loadedList->expects($this->exactly(2))
->method('getChoices') ->method('getChoices')
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices());
$this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices());
@ -65,12 +65,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
// The same list is returned by the loader // The same list is returned by the loader
$this->loadedList->expects($this->exactly(2)) $this->loadedList->expects($this->exactly(2))
->method('getValues') ->method('getValues')
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getValues()); $this->assertSame('RESULT', $this->list->getValues());
$this->assertSame('RESULT', $this->list->getValues()); $this->assertSame('RESULT', $this->list->getValues());
@ -81,12 +81,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
// The same list is returned by the loader // The same list is returned by the loader
$this->loadedList->expects($this->exactly(2)) $this->loadedList->expects($this->exactly(2))
->method('getStructuredValues') ->method('getStructuredValues')
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getStructuredValues()); $this->assertSame('RESULT', $this->list->getStructuredValues());
$this->assertSame('RESULT', $this->list->getStructuredValues()); $this->assertSame('RESULT', $this->list->getStructuredValues());
@ -97,12 +97,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
// The same list is returned by the loader // The same list is returned by the loader
$this->loadedList->expects($this->exactly(2)) $this->loadedList->expects($this->exactly(2))
->method('getOriginalKeys') ->method('getOriginalKeys')
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getOriginalKeys()); $this->assertSame('RESULT', $this->list->getOriginalKeys());
$this->assertSame('RESULT', $this->list->getOriginalKeys()); $this->assertSame('RESULT', $this->list->getOriginalKeys());
@ -113,7 +113,7 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoicesForValues') ->method('loadChoicesForValues')
->with(['a', 'b']) ->with(['a', 'b'])
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
@ -124,12 +124,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(1)) $this->loader->expects($this->exactly(1))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadChoicesForValues') ->method('loadChoicesForValues')
->with(['a', 'b']) ->with(['a', 'b'])
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
// load choice list // load choice list
$this->list->getChoices(); $this->list->getChoices();
@ -143,12 +143,12 @@ class LazyChoiceListTest extends TestCase
$this->loader->expects($this->exactly(1)) $this->loader->expects($this->exactly(1))
->method('loadChoiceList') ->method('loadChoiceList')
->with($this->value) ->with($this->value)
->will($this->returnValue($this->loadedList)); ->willReturn($this->loadedList);
$this->loader->expects($this->exactly(2)) $this->loader->expects($this->exactly(2))
->method('loadValuesForChoices') ->method('loadValuesForChoices')
->with(['a', 'b']) ->with(['a', 'b'])
->will($this->returnValue('RESULT')); ->willReturn('RESULT');
// load choice list // load choice list
$this->list->getChoices(); $this->list->getChoices();

View File

@ -179,7 +179,7 @@ class CompoundFormTest extends AbstractFormTest
'bar' => 'baz', 'bar' => 'baz',
'auto_initialize' => false, 'auto_initialize' => false,
]) ])
->will($this->returnValue($child)); ->willReturn($child);
$this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); $this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']);
@ -198,7 +198,7 @@ class CompoundFormTest extends AbstractFormTest
'bar' => 'baz', 'bar' => 'baz',
'auto_initialize' => false, 'auto_initialize' => false,
]) ])
->will($this->returnValue($child)); ->willReturn($child);
// in order to make casting unnecessary // in order to make casting unnecessary
$this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); $this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']);
@ -215,7 +215,7 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamed') ->method('createNamed')
->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->will($this->returnValue($child)); ->willReturn($child);
$this->form->add('foo'); $this->form->add('foo');
@ -236,7 +236,7 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createForProperty') ->method('createForProperty')
->with('\stdClass', 'foo') ->with('\stdClass', 'foo')
->will($this->returnValue($child)); ->willReturn($child);
$this->form->add('foo'); $this->form->add('foo');
@ -260,7 +260,7 @@ class CompoundFormTest extends AbstractFormTest
'bar' => 'baz', 'bar' => 'baz',
'auto_initialize' => false, 'auto_initialize' => false,
]) ])
->will($this->returnValue($child)); ->willReturn($child);
$this->form->add('foo', null, ['bar' => 'baz']); $this->form->add('foo', null, ['bar' => 'baz']);
@ -352,10 +352,10 @@ class CompoundFormTest extends AbstractFormTest
$mapper->expects($this->once()) $mapper->expects($this->once())
->method('mapDataToForms') ->method('mapDataToForms')
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); $this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
})); });
$form->initialize(); $form->initialize();
$form->add($child); $form->add($child);
@ -442,10 +442,10 @@ class CompoundFormTest extends AbstractFormTest
$mapper->expects($this->once()) $mapper->expects($this->once())
->method('mapDataToForms') ->method('mapDataToForms')
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
})); });
$form->setData('foo'); $form->setData('foo');
} }
@ -517,12 +517,12 @@ class CompoundFormTest extends AbstractFormTest
$mapper->expects($this->once()) $mapper->expects($this->once())
->method('mapFormsToData') ->method('mapFormsToData')
->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar')
->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
$this->assertEquals('Bernhard', $child1->getData()); $this->assertEquals('Bernhard', $child1->getData());
$this->assertEquals('Schussek', $child2->getData()); $this->assertEquals('Schussek', $child2->getData());
})); });
$form->submit([ $form->submit([
'firstName' => 'Bernhard', 'firstName' => 'Bernhard',
@ -589,10 +589,10 @@ class CompoundFormTest extends AbstractFormTest
$mapper->expects($this->once()) $mapper->expects($this->once())
->method('mapFormsToData') ->method('mapFormsToData')
->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object)
->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['name' => $child], iterator_to_array($iterator)); $this->assertSame(['name' => $child], iterator_to_array($iterator));
})); });
$form->submit([ $form->submit([
'name' => 'Bernhard', 'name' => 'Bernhard',
@ -957,11 +957,11 @@ class CompoundFormTest extends AbstractFormTest
$field1View = new FormView(); $field1View = new FormView();
$type1 $type1
->method('createView') ->method('createView')
->will($this->returnValue($field1View)); ->willReturn($field1View);
$field2View = new FormView(); $field2View = new FormView();
$type2 $type2
->method('createView') ->method('createView')
->will($this->returnValue($field2View)); ->willReturn($field2View);
$this->form = $this->getBuilder('form', null, null, $options) $this->form = $this->getBuilder('form', null, null, $options)
->setCompound(true) ->setCompound(true)
@ -980,13 +980,13 @@ class CompoundFormTest extends AbstractFormTest
// First create the view // First create the view
$type->expects($this->once()) $type->expects($this->once())
->method('createView') ->method('createView')
->will($this->returnValue($view)); ->willReturn($view);
// Then build it for the form itself // Then build it for the form itself
$type->expects($this->once()) $type->expects($this->once())
->method('buildView') ->method('buildView')
->with($view, $this->form, $options) ->with($view, $this->form, $options)
->will($this->returnCallback($assertChildViewsEqual([]))); ->willReturnCallback($assertChildViewsEqual([]));
$this->assertSame($view, $this->form->createView()); $this->assertSame($view, $this->form->createView());
$this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children); $this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children);
@ -1006,7 +1006,7 @@ class CompoundFormTest extends AbstractFormTest
$button->expects($this->any()) $button->expects($this->any())
->method('isClicked') ->method('isClicked')
->will($this->returnValue(false)); ->willReturn(false);
$parentForm = $this->getBuilder('parent')->getForm(); $parentForm = $this->getBuilder('parent')->getForm();
$nestedForm = $this->getBuilder('nested')->getForm(); $nestedForm = $this->getBuilder('nested')->getForm();
@ -1028,7 +1028,7 @@ class CompoundFormTest extends AbstractFormTest
$button->expects($this->any()) $button->expects($this->any())
->method('isClicked') ->method('isClicked')
->will($this->returnValue(true)); ->willReturn(true);
$this->form->add($button); $this->form->add($button);
$this->form->submit([]); $this->form->submit([]);
@ -1047,7 +1047,7 @@ class CompoundFormTest extends AbstractFormTest
$nestedForm->expects($this->any()) $nestedForm->expects($this->any())
->method('getClickedButton') ->method('getClickedButton')
->will($this->returnValue($button)); ->willReturn($button);
$this->form->add($nestedForm); $this->form->add($nestedForm);
$this->form->submit([]); $this->form->submit([]);
@ -1066,7 +1066,7 @@ class CompoundFormTest extends AbstractFormTest
$parentForm->expects($this->any()) $parentForm->expects($this->any())
->method('getClickedButton') ->method('getClickedButton')
->will($this->returnValue($button)); ->willReturn($button);
$this->form->setParent($parentForm); $this->form->setParent($parentForm);
$this->form->submit([]); $this->form->submit([]);

View File

@ -22,12 +22,12 @@ class DataTransformerChainTest extends TestCase
$transformer1->expects($this->once()) $transformer1->expects($this->once())
->method('transform') ->method('transform')
->with($this->identicalTo('foo')) ->with($this->identicalTo('foo'))
->will($this->returnValue('bar')); ->willReturn('bar');
$transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer2->expects($this->once()) $transformer2->expects($this->once())
->method('transform') ->method('transform')
->with($this->identicalTo('bar')) ->with($this->identicalTo('bar'))
->will($this->returnValue('baz')); ->willReturn('baz');
$chain = new DataTransformerChain([$transformer1, $transformer2]); $chain = new DataTransformerChain([$transformer1, $transformer2]);
@ -40,12 +40,12 @@ class DataTransformerChainTest extends TestCase
$transformer2->expects($this->once()) $transformer2->expects($this->once())
->method('reverseTransform') ->method('reverseTransform')
->with($this->identicalTo('foo')) ->with($this->identicalTo('foo'))
->will($this->returnValue('bar')); ->willReturn('bar');
$transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
$transformer1->expects($this->once()) $transformer1->expects($this->once())
->method('reverseTransform') ->method('reverseTransform')
->with($this->identicalTo('bar')) ->with($this->identicalTo('bar'))
->will($this->returnValue('baz')); ->willReturn('baz');
$chain = new DataTransformerChain([$transformer1, $transformer2]); $chain = new DataTransformerChain([$transformer1, $transformer2]);

View File

@ -124,7 +124,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('getToken') ->method('getToken')
->with('TOKEN_ID') ->with('TOKEN_ID')
->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token'))); ->willReturn(new CsrfToken('TOKEN_ID', 'token'));
$view = $this->factory $view = $this->factory
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -143,7 +143,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('getToken') ->method('getToken')
->with('FORM_NAME') ->with('FORM_NAME')
->will($this->returnValue('token')); ->willReturn('token');
$view = $this->factory $view = $this->factory
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -161,7 +161,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('getToken') ->method('getToken')
->with('Symfony\Component\Form\Extension\Core\Type\FormType') ->with('Symfony\Component\Form\Extension\Core\Type\FormType')
->will($this->returnValue('token')); ->willReturn('token');
$view = $this->factory $view = $this->factory
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -190,7 +190,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('isTokenValid') ->method('isTokenValid')
->with(new CsrfToken('TOKEN_ID', 'token')) ->with(new CsrfToken('TOKEN_ID', 'token'))
->will($this->returnValue($valid)); ->willReturn($valid);
$form = $this->factory $form = $this->factory
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -222,7 +222,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('isTokenValid') ->method('isTokenValid')
->with(new CsrfToken('FORM_NAME', 'token')) ->with(new CsrfToken('FORM_NAME', 'token'))
->will($this->returnValue($valid)); ->willReturn($valid);
$form = $this->factory $form = $this->factory
->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -253,7 +253,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('isTokenValid') ->method('isTokenValid')
->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token')) ->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token'))
->will($this->returnValue($valid)); ->willReturn($valid);
$form = $this->factory $form = $this->factory
->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
@ -369,12 +369,12 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
$this->tokenManager->expects($this->once()) $this->tokenManager->expects($this->once())
->method('isTokenValid') ->method('isTokenValid')
->with($csrfToken) ->with($csrfToken)
->will($this->returnValue(false)); ->willReturn(false);
$this->translator->expects($this->once()) $this->translator->expects($this->once())
->method('trans') ->method('trans')
->with('Foobar') ->with('Foobar')
->will($this->returnValue('[trans]Foobar[/trans]')); ->willReturn('[trans]Foobar[/trans]');
$form = $this->factory $form = $this->factory
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [

View File

@ -84,29 +84,29 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->form) ->with($this->form)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2)) $this->dataExtractor->expects($this->at(2))
->method('extractDefaultData') ->method('extractDefaultData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['default_data' => 'foo'])); ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3)) $this->dataExtractor->expects($this->at(3))
->method('extractDefaultData') ->method('extractDefaultData')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['default_data' => 'bar'])); ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4)) $this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['submitted_data' => 'foo'])); ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5)) $this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['submitted_data' => 'bar'])); ->willReturn(['submitted_data' => 'bar']);
$this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->collectDefaultData($this->form); $this->dataCollector->collectDefaultData($this->form);
@ -150,11 +150,11 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($form1) ->with($form1)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($form2) ->with($form2)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
$this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectConfiguration($form1);
$this->dataCollector->collectConfiguration($form2); $this->dataCollector->collectConfiguration($form2);
@ -200,12 +200,12 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->form) ->with($this->form)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractDefaultData') ->method('extractDefaultData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['default_data' => 'foo'])); ->willReturn(['default_data' => 'foo']);
$this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->buildPreliminaryFormTree($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form);
@ -272,39 +272,39 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->form) ->with($this->form)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2)) $this->dataExtractor->expects($this->at(2))
->method('extractDefaultData') ->method('extractDefaultData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['default_data' => 'foo'])); ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3)) $this->dataExtractor->expects($this->at(3))
->method('extractDefaultData') ->method('extractDefaultData')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['default_data' => 'bar'])); ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4)) $this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['submitted_data' => 'foo'])); ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5)) $this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['submitted_data' => 'bar'])); ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(6)) $this->dataExtractor->expects($this->at(6))
->method('extractViewVariables') ->method('extractViewVariables')
->with($this->view) ->with($this->view)
->will($this->returnValue(['view_vars' => 'foo'])); ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(7)) $this->dataExtractor->expects($this->at(7))
->method('extractViewVariables') ->method('extractViewVariables')
->with($this->childView) ->with($this->childView)
->will($this->returnValue(['view_vars' => 'bar'])); ->willReturn(['view_vars' => 'bar']);
$this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectConfiguration($this->form);
$this->dataCollector->collectDefaultData($this->form); $this->dataCollector->collectDefaultData($this->form);
@ -365,76 +365,76 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($form1) ->with($form1)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($child1) ->with($child1)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(2)) $this->dataExtractor->expects($this->at(2))
->method('extractDefaultData') ->method('extractDefaultData')
->with($form1) ->with($form1)
->will($this->returnValue(['default_data' => 'foo'])); ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(3)) $this->dataExtractor->expects($this->at(3))
->method('extractDefaultData') ->method('extractDefaultData')
->with($child1) ->with($child1)
->will($this->returnValue(['default_data' => 'bar'])); ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(4)) $this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($form1) ->with($form1)
->will($this->returnValue(['submitted_data' => 'foo'])); ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(5)) $this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child1) ->with($child1)
->will($this->returnValue(['submitted_data' => 'bar'])); ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(6)) $this->dataExtractor->expects($this->at(6))
->method('extractViewVariables') ->method('extractViewVariables')
->with($form1View) ->with($form1View)
->will($this->returnValue(['view_vars' => 'foo'])); ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(7)) $this->dataExtractor->expects($this->at(7))
->method('extractViewVariables') ->method('extractViewVariables')
->with($child1View) ->with($child1View)
->will($this->returnValue(['view_vars' => $child1View->vars])); ->willReturn(['view_vars' => $child1View->vars]);
$this->dataExtractor->expects($this->at(8)) $this->dataExtractor->expects($this->at(8))
->method('extractConfiguration') ->method('extractConfiguration')
->with($form2) ->with($form2)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(9)) $this->dataExtractor->expects($this->at(9))
->method('extractConfiguration') ->method('extractConfiguration')
->with($child1) ->with($child1)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
$this->dataExtractor->expects($this->at(10)) $this->dataExtractor->expects($this->at(10))
->method('extractDefaultData') ->method('extractDefaultData')
->with($form2) ->with($form2)
->will($this->returnValue(['default_data' => 'foo'])); ->willReturn(['default_data' => 'foo']);
$this->dataExtractor->expects($this->at(11)) $this->dataExtractor->expects($this->at(11))
->method('extractDefaultData') ->method('extractDefaultData')
->with($child1) ->with($child1)
->will($this->returnValue(['default_data' => 'bar'])); ->willReturn(['default_data' => 'bar']);
$this->dataExtractor->expects($this->at(12)) $this->dataExtractor->expects($this->at(12))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($form2) ->with($form2)
->will($this->returnValue(['submitted_data' => 'foo'])); ->willReturn(['submitted_data' => 'foo']);
$this->dataExtractor->expects($this->at(13)) $this->dataExtractor->expects($this->at(13))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child1) ->with($child1)
->will($this->returnValue(['submitted_data' => 'bar'])); ->willReturn(['submitted_data' => 'bar']);
$this->dataExtractor->expects($this->at(14)) $this->dataExtractor->expects($this->at(14))
->method('extractViewVariables') ->method('extractViewVariables')
->with($form2View) ->with($form2View)
->will($this->returnValue(['view_vars' => 'foo'])); ->willReturn(['view_vars' => 'foo']);
$this->dataExtractor->expects($this->at(15)) $this->dataExtractor->expects($this->at(15))
->method('extractViewVariables') ->method('extractViewVariables')
->with($child1View) ->with($child1View)
->will($this->returnValue(['view_vars' => $child1View->vars])); ->willReturn(['view_vars' => $child1View->vars]);
$this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectConfiguration($form1);
$this->dataCollector->collectDefaultData($form1); $this->dataCollector->collectDefaultData($form1);
@ -518,11 +518,11 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->form) ->with($this->form)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
// explicitly call collectConfiguration(), since $this->childForm is not // explicitly call collectConfiguration(), since $this->childForm is not
// contained in the form tree // contained in the form tree
@ -566,11 +566,11 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->at(0)) $this->dataExtractor->expects($this->at(0))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->form) ->with($this->form)
->will($this->returnValue(['config' => 'foo'])); ->willReturn(['config' => 'foo']);
$this->dataExtractor->expects($this->at(1)) $this->dataExtractor->expects($this->at(1))
->method('extractConfiguration') ->method('extractConfiguration')
->with($this->childForm) ->with($this->childForm)
->will($this->returnValue(['config' => 'bar'])); ->willReturn(['config' => 'bar']);
// explicitly call collectConfiguration(), since $this->childForm is not // explicitly call collectConfiguration(), since $this->childForm is not
// contained in the form tree // contained in the form tree
@ -611,22 +611,22 @@ class FormDataCollectorTest extends TestCase
$form1->add($childForm1); $form1->add($childForm1);
$this->dataExtractor $this->dataExtractor
->method('extractConfiguration') ->method('extractConfiguration')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor $this->dataExtractor
->method('extractDefaultData') ->method('extractDefaultData')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor->expects($this->at(4)) $this->dataExtractor->expects($this->at(4))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($form1) ->with($form1)
->will($this->returnValue(['errors' => ['foo']])); ->willReturn(['errors' => ['foo']]);
$this->dataExtractor->expects($this->at(5)) $this->dataExtractor->expects($this->at(5))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($childForm1) ->with($childForm1)
->will($this->returnValue(['errors' => ['bar', 'bam']])); ->willReturn(['errors' => ['bar', 'bam']]);
$this->dataExtractor->expects($this->at(8)) $this->dataExtractor->expects($this->at(8))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($form2) ->with($form2)
->will($this->returnValue(['errors' => ['baz']])); ->willReturn(['errors' => ['baz']]);
$this->dataCollector->collectSubmittedData($form1); $this->dataCollector->collectSubmittedData($form1);
@ -653,30 +653,30 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor $this->dataExtractor
->method('extractConfiguration') ->method('extractConfiguration')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor $this->dataExtractor
->method('extractDefaultData') ->method('extractDefaultData')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor->expects($this->at(10)) $this->dataExtractor->expects($this->at(10))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($this->form) ->with($this->form)
->will($this->returnValue(['errors' => []])); ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(11)) $this->dataExtractor->expects($this->at(11))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child1Form) ->with($child1Form)
->will($this->returnValue(['errors' => []])); ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(12)) $this->dataExtractor->expects($this->at(12))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child11Form) ->with($child11Form)
->will($this->returnValue(['errors' => ['foo']])); ->willReturn(['errors' => ['foo']]);
$this->dataExtractor->expects($this->at(13)) $this->dataExtractor->expects($this->at(13))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child2Form) ->with($child2Form)
->will($this->returnValue(['errors' => []])); ->willReturn(['errors' => []]);
$this->dataExtractor->expects($this->at(14)) $this->dataExtractor->expects($this->at(14))
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($child21Form) ->with($child21Form)
->will($this->returnValue(['errors' => []])); ->willReturn(['errors' => []]);
$this->dataCollector->collectSubmittedData($this->form); $this->dataCollector->collectSubmittedData($this->form);
$this->dataCollector->buildPreliminaryFormTree($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form);
@ -701,14 +701,14 @@ class FormDataCollectorTest extends TestCase
$this->dataExtractor->expects($this->any()) $this->dataExtractor->expects($this->any())
->method('extractConfiguration') ->method('extractConfiguration')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor->expects($this->any()) $this->dataExtractor->expects($this->any())
->method('extractDefaultData') ->method('extractDefaultData')
->will($this->returnValue([])); ->willReturn([]);
$this->dataExtractor->expects($this->any()) $this->dataExtractor->expects($this->any())
->method('extractSubmittedData') ->method('extractSubmittedData')
->with($form) ->with($form)
->will($this->returnValue(['errors' => ['baz']])); ->willReturn(['errors' => ['baz']]);
$this->dataCollector->buildPreliminaryFormTree($form); $this->dataCollector->buildPreliminaryFormTree($form);
$this->dataCollector->collectSubmittedData($form); $this->dataCollector->collectSubmittedData($form);

View File

@ -56,7 +56,7 @@ class FormDataExtractorTest extends TestCase
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any()) $type->expects($this->any())
->method('getInnerType') ->method('getInnerType')
->will($this->returnValue(new \stdClass())); ->willReturn(new \stdClass());
$form = $this->createBuilder('name') $form = $this->createBuilder('name')
->setType($type) ->setType($type)
@ -77,7 +77,7 @@ class FormDataExtractorTest extends TestCase
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any()) $type->expects($this->any())
->method('getInnerType') ->method('getInnerType')
->will($this->returnValue(new \stdClass())); ->willReturn(new \stdClass());
$options = [ $options = [
'b' => 'foo', 'b' => 'foo',
@ -111,7 +111,7 @@ class FormDataExtractorTest extends TestCase
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any()) $type->expects($this->any())
->method('getInnerType') ->method('getInnerType')
->will($this->returnValue(new \stdClass())); ->willReturn(new \stdClass());
$options = [ $options = [
'b' => 'foo', 'b' => 'foo',
@ -142,7 +142,7 @@ class FormDataExtractorTest extends TestCase
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
$type->expects($this->any()) $type->expects($this->any())
->method('getInnerType') ->method('getInnerType')
->will($this->returnValue(new \stdClass())); ->willReturn(new \stdClass());
$grandParent = $this->createBuilder('grandParent') $grandParent = $this->createBuilder('grandParent')
->setCompound(true) ->setCompound(true)

View File

@ -42,7 +42,7 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
$this->validator->expects($this->once()) $this->validator->expects($this->once())
->method('validate') ->method('validate')
->with($this->equalTo($form)) ->with($this->equalTo($form))
->will($this->returnValue(new ConstraintViolationList())); ->willReturn(new ConstraintViolationList());
// specific data is irrelevant // specific data is irrelevant
$form->submit([]); $form->submit([]);

View File

@ -93,7 +93,7 @@ class FormBuilderTest extends TestCase
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); ->willReturn(new FormBuilder('foo', null, $this->dispatcher, $this->factory));
$this->assertCount(0, $this->builder->all()); $this->assertCount(0, $this->builder->all());
$this->assertFalse($this->builder->has('foo')); $this->assertFalse($this->builder->has('foo'));
@ -188,7 +188,7 @@ class FormBuilderTest extends TestCase
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with($expectedName, $expectedType, null, $expectedOptions) ->with($expectedName, $expectedType, null, $expectedOptions)
->will($this->returnValue($this->getFormBuilder())); ->willReturn($this->getFormBuilder());
$this->builder->add($expectedName, $expectedType, $expectedOptions); $this->builder->add($expectedName, $expectedType, $expectedOptions);
$builder = $this->builder->get($expectedName); $builder = $this->builder->get($expectedName);
@ -204,7 +204,7 @@ class FormBuilderTest extends TestCase
$this->factory->expects($this->once()) $this->factory->expects($this->once())
->method('createBuilderForProperty') ->method('createBuilderForProperty')
->with('stdClass', $expectedName, null, $expectedOptions) ->with('stdClass', $expectedName, null, $expectedOptions)
->will($this->returnValue($this->getFormBuilder())); ->willReturn($this->getFormBuilder());
$this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory);
$this->builder->add($expectedName, null, $expectedOptions); $this->builder->add($expectedName, null, $expectedOptions);
@ -246,7 +246,7 @@ class FormBuilderTest extends TestCase
$mock->expects($this->any()) $mock->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($name)); ->willReturn($name);
return $mock; return $mock;
} }

View File

@ -58,10 +58,10 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->any()) $this->registry->expects($this->any())
->method('getTypeGuesser') ->method('getTypeGuesser')
->will($this->returnValue(new FormTypeGuesserChain([ ->willReturn(new FormTypeGuesserChain([
$this->guesser1, $this->guesser1,
$this->guesser2, $this->guesser2,
]))); ]));
} }
public function testCreateNamedBuilderWithTypeName() public function testCreateNamedBuilderWithTypeName()
@ -73,16 +73,16 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->once()) $this->registry->expects($this->once())
->method('getType') ->method('getType')
->with('type') ->with('type')
->will($this->returnValue($resolvedType)); ->willReturn($resolvedType);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('createBuilder') ->method('createBuilder')
->with($this->factory, 'name', $options) ->with($this->factory, 'name', $options)
->will($this->returnValue($this->builder)); ->willReturn($this->builder);
$this->builder->expects($this->any()) $this->builder->expects($this->any())
->method('getOptions') ->method('getOptions')
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('buildForm') ->method('buildForm')
@ -101,16 +101,16 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->once()) $this->registry->expects($this->once())
->method('getType') ->method('getType')
->with('type') ->with('type')
->will($this->returnValue($resolvedType)); ->willReturn($resolvedType);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('createBuilder') ->method('createBuilder')
->with($this->factory, 'name', $expectedOptions) ->with($this->factory, 'name', $expectedOptions)
->will($this->returnValue($this->builder)); ->willReturn($this->builder);
$this->builder->expects($this->any()) $this->builder->expects($this->any())
->method('getOptions') ->method('getOptions')
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('buildForm') ->method('buildForm')
@ -128,16 +128,16 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->once()) $this->registry->expects($this->once())
->method('getType') ->method('getType')
->with('type') ->with('type')
->will($this->returnValue($resolvedType)); ->willReturn($resolvedType);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('createBuilder') ->method('createBuilder')
->with($this->factory, 'name', $options) ->with($this->factory, 'name', $options)
->will($this->returnValue($this->builder)); ->willReturn($this->builder);
$this->builder->expects($this->any()) $this->builder->expects($this->any())
->method('getOptions') ->method('getOptions')
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('buildForm') ->method('buildForm')
@ -181,16 +181,16 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->any()) $this->registry->expects($this->any())
->method('getType') ->method('getType')
->with('TYPE') ->with('TYPE')
->will($this->returnValue($resolvedType)); ->willReturn($resolvedType);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('createBuilder') ->method('createBuilder')
->with($this->factory, 'TYPE_PREFIX', $options) ->with($this->factory, 'TYPE_PREFIX', $options)
->will($this->returnValue($this->builder)); ->willReturn($this->builder);
$this->builder->expects($this->any()) $this->builder->expects($this->any())
->method('getOptions') ->method('getOptions')
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('buildForm') ->method('buildForm')
@ -198,7 +198,7 @@ class FormFactoryTest extends TestCase
$this->builder->expects($this->once()) $this->builder->expects($this->once())
->method('getForm') ->method('getForm')
->will($this->returnValue('FORM')); ->willReturn('FORM');
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); $this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
} }
@ -212,16 +212,16 @@ class FormFactoryTest extends TestCase
$this->registry->expects($this->once()) $this->registry->expects($this->once())
->method('getType') ->method('getType')
->with('type') ->with('type')
->will($this->returnValue($resolvedType)); ->willReturn($resolvedType);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('createBuilder') ->method('createBuilder')
->with($this->factory, 'name', $options) ->with($this->factory, 'name', $options)
->will($this->returnValue($this->builder)); ->willReturn($this->builder);
$this->builder->expects($this->any()) $this->builder->expects($this->any())
->method('getOptions') ->method('getOptions')
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$resolvedType->expects($this->once()) $resolvedType->expects($this->once())
->method('buildForm') ->method('buildForm')
@ -229,7 +229,7 @@ class FormFactoryTest extends TestCase
$this->builder->expects($this->once()) $this->builder->expects($this->once())
->method('getForm') ->method('getForm')
->will($this->returnValue('FORM')); ->willReturn('FORM');
$this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options));
} }
@ -245,7 +245,7 @@ class FormFactoryTest extends TestCase
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@ -257,27 +257,27 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessType') ->method('guessType')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new TypeGuess( ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\TextType', 'Symfony\Component\Form\Extension\Core\Type\TextType',
['attr' => ['maxlength' => 10]], ['attr' => ['maxlength' => 10]],
Guess::MEDIUM_CONFIDENCE Guess::MEDIUM_CONFIDENCE
))); ));
$this->guesser2->expects($this->once()) $this->guesser2->expects($this->once())
->method('guessType') ->method('guessType')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new TypeGuess( ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'Symfony\Component\Form\Extension\Core\Type\PasswordType',
['attr' => ['maxlength' => 7]], ['attr' => ['maxlength' => 7]],
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@ -289,14 +289,14 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessType') ->method('guessType')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(null)); ->willReturn(null);
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
@ -308,18 +308,18 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessType') ->method('guessType')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new TypeGuess( ->willReturn(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\TextType', 'Symfony\Component\Form\Extension\Core\Type\TextType',
['attr' => ['class' => 'foo', 'maxlength' => 10]], ['attr' => ['class' => 'foo', 'maxlength' => 10]],
Guess::MEDIUM_CONFIDENCE Guess::MEDIUM_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty( $this->builder = $factory->createBuilderForProperty(
'Application\Author', 'Application\Author',
@ -336,25 +336,25 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessMaxLength') ->method('guessMaxLength')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
15, 15,
Guess::MEDIUM_CONFIDENCE Guess::MEDIUM_CONFIDENCE
))); ));
$this->guesser2->expects($this->once()) $this->guesser2->expects($this->once())
->method('guessMaxLength') ->method('guessMaxLength')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
20, 20,
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty( $this->builder = $factory->createBuilderForProperty(
'Application\Author', 'Application\Author',
@ -369,25 +369,25 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessMaxLength') ->method('guessMaxLength')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
20, 20,
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$this->guesser2->expects($this->once()) $this->guesser2->expects($this->once())
->method('guessPattern') ->method('guessPattern')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
'.{5,}', '.{5,}',
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty( $this->builder = $factory->createBuilderForProperty(
'Application\Author', 'Application\Author',
@ -404,25 +404,25 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessRequired') ->method('guessRequired')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
true, true,
Guess::MEDIUM_CONFIDENCE Guess::MEDIUM_CONFIDENCE
))); ));
$this->guesser2->expects($this->once()) $this->guesser2->expects($this->once())
->method('guessRequired') ->method('guessRequired')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
false, false,
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty( $this->builder = $factory->createBuilderForProperty(
'Application\Author', 'Application\Author',
@ -437,25 +437,25 @@ class FormFactoryTest extends TestCase
$this->guesser1->expects($this->once()) $this->guesser1->expects($this->once())
->method('guessPattern') ->method('guessPattern')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
'[a-z]', '[a-z]',
Guess::MEDIUM_CONFIDENCE Guess::MEDIUM_CONFIDENCE
))); ));
$this->guesser2->expects($this->once()) $this->guesser2->expects($this->once())
->method('guessPattern') ->method('guessPattern')
->with('Application\Author', 'firstName') ->with('Application\Author', 'firstName')
->will($this->returnValue(new ValueGuess( ->willReturn(new ValueGuess(
'[a-zA-Z]', '[a-zA-Z]',
Guess::HIGH_CONFIDENCE Guess::HIGH_CONFIDENCE
))); ));
$factory = $this->getMockFactory(['createNamedBuilder']); $factory = $this->getMockFactory(['createNamedBuilder']);
$factory->expects($this->once()) $factory->expects($this->once())
->method('createNamedBuilder') ->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']]) ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']])
->will($this->returnValue('builderInstance')); ->willReturn('builderInstance');
$this->builder = $factory->createBuilderForProperty( $this->builder = $factory->createBuilderForProperty(
'Application\Author', 'Application\Author',

View File

@ -99,21 +99,21 @@ class ResolvedFormTypeTest extends TestCase
// First the default options are generated for the super type // First the default options are generated for the super type
$this->parentType->expects($this->once()) $this->parentType->expects($this->once())
->method('configureOptions') ->method('configureOptions')
->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default'))); ->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default'));
// The form type itself // The form type itself
$this->type->expects($this->once()) $this->type->expects($this->once())
->method('configureOptions') ->method('configureOptions')
->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default'))); ->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default'));
// And its extensions // And its extensions
$this->extension1->expects($this->once()) $this->extension1->expects($this->once())
->method('configureOptions') ->method('configureOptions')
->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default'))); ->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default'));
$this->extension2->expects($this->once()) $this->extension2->expects($this->once())
->method('configureOptions') ->method('configureOptions')
->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default'))); ->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default'));
$givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom'];
$resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'];
@ -136,12 +136,12 @@ class ResolvedFormTypeTest extends TestCase
$this->resolvedType->expects($this->once()) $this->resolvedType->expects($this->once())
->method('getOptionsResolver') ->method('getOptionsResolver')
->will($this->returnValue($optionsResolver)); ->willReturn($optionsResolver);
$optionsResolver->expects($this->once()) $optionsResolver->expects($this->once())
->method('resolve') ->method('resolve')
->with($givenOptions) ->with($givenOptions)
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$factory = $this->getMockFormFactory(); $factory = $this->getMockFormFactory();
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
@ -164,12 +164,12 @@ class ResolvedFormTypeTest extends TestCase
$this->resolvedType->expects($this->once()) $this->resolvedType->expects($this->once())
->method('getOptionsResolver') ->method('getOptionsResolver')
->will($this->returnValue($optionsResolver)); ->willReturn($optionsResolver);
$optionsResolver->expects($this->once()) $optionsResolver->expects($this->once())
->method('resolve') ->method('resolve')
->with($givenOptions) ->with($givenOptions)
->will($this->returnValue($resolvedOptions)); ->willReturn($resolvedOptions);
$factory = $this->getMockFormFactory(); $factory = $this->getMockFormFactory();
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
@ -198,24 +198,24 @@ class ResolvedFormTypeTest extends TestCase
$this->parentType->expects($this->once()) $this->parentType->expects($this->once())
->method('buildForm') ->method('buildForm')
->with($builder, $options) ->with($builder, $options)
->will($this->returnCallback($assertIndex(0))); ->willReturnCallback($assertIndex(0));
// Then the type itself // Then the type itself
$this->type->expects($this->once()) $this->type->expects($this->once())
->method('buildForm') ->method('buildForm')
->with($builder, $options) ->with($builder, $options)
->will($this->returnCallback($assertIndex(1))); ->willReturnCallback($assertIndex(1));
// Then its extensions // Then its extensions
$this->extension1->expects($this->once()) $this->extension1->expects($this->once())
->method('buildForm') ->method('buildForm')
->with($builder, $options) ->with($builder, $options)
->will($this->returnCallback($assertIndex(2))); ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once()) $this->extension2->expects($this->once())
->method('buildForm') ->method('buildForm')
->with($builder, $options) ->with($builder, $options)
->will($this->returnCallback($assertIndex(3))); ->willReturnCallback($assertIndex(3));
$this->resolvedType->buildForm($builder, $options); $this->resolvedType->buildForm($builder, $options);
} }
@ -261,24 +261,24 @@ class ResolvedFormTypeTest extends TestCase
$this->parentType->expects($this->once()) $this->parentType->expects($this->once())
->method('buildView') ->method('buildView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(0))); ->willReturnCallback($assertIndex(0));
// Then the type itself // Then the type itself
$this->type->expects($this->once()) $this->type->expects($this->once())
->method('buildView') ->method('buildView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(1))); ->willReturnCallback($assertIndex(1));
// Then its extensions // Then its extensions
$this->extension1->expects($this->once()) $this->extension1->expects($this->once())
->method('buildView') ->method('buildView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(2))); ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once()) $this->extension2->expects($this->once())
->method('buildView') ->method('buildView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(3))); ->willReturnCallback($assertIndex(3));
$this->resolvedType->buildView($view, $form, $options); $this->resolvedType->buildView($view, $form, $options);
} }
@ -303,24 +303,24 @@ class ResolvedFormTypeTest extends TestCase
$this->parentType->expects($this->once()) $this->parentType->expects($this->once())
->method('finishView') ->method('finishView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(0))); ->willReturnCallback($assertIndex(0));
// Then the type itself // Then the type itself
$this->type->expects($this->once()) $this->type->expects($this->once())
->method('finishView') ->method('finishView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(1))); ->willReturnCallback($assertIndex(1));
// Then its extensions // Then its extensions
$this->extension1->expects($this->once()) $this->extension1->expects($this->once())
->method('finishView') ->method('finishView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(2))); ->willReturnCallback($assertIndex(2));
$this->extension2->expects($this->once()) $this->extension2->expects($this->once())
->method('finishView') ->method('finishView')
->with($view, $form, $options) ->with($view, $form, $options)
->will($this->returnCallback($assertIndex(3))); ->willReturnCallback($assertIndex(3));
$this->resolvedType->finishView($view, $form, $options); $this->resolvedType->finishView($view, $form, $options);
} }

View File

@ -722,7 +722,7 @@ class SimpleFormTest extends AbstractFormTest
$type->expects($this->once()) $type->expects($this->once())
->method('createView') ->method('createView')
->with($form) ->with($form)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $form->createView()); $this->assertSame($view, $form->createView());
} }
@ -739,12 +739,12 @@ class SimpleFormTest extends AbstractFormTest
$parentType->expects($this->once()) $parentType->expects($this->once())
->method('createView') ->method('createView')
->will($this->returnValue($parentView)); ->willReturn($parentView);
$type->expects($this->once()) $type->expects($this->once())
->method('createView') ->method('createView')
->with($form, $parentView) ->with($form, $parentView)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $form->createView()); $this->assertSame($view, $form->createView());
} }
@ -759,7 +759,7 @@ class SimpleFormTest extends AbstractFormTest
$type->expects($this->once()) $type->expects($this->once())
->method('createView') ->method('createView')
->with($form, $parentView) ->with($form, $parentView)
->will($this->returnValue($view)); ->willReturn($view);
$this->assertSame($view, $form->createView($parentView)); $this->assertSame($view, $form->createView($parentView));
} }

View File

@ -35,14 +35,14 @@ class HttpExceptionTraitTest extends TestCase
$response = $this->createMock(ResponseInterface::class); $response = $this->createMock(ResponseInterface::class);
$response $response
->method('getInfo') ->method('getInfo')
->will($this->returnValueMap([ ->willReturnMap([
['http_code', 400], ['http_code', 400],
['url', 'http://example.com'], ['url', 'http://example.com'],
['response_headers', [ ['response_headers', [
'HTTP/1.1 400 Bad Request', 'HTTP/1.1 400 Bad Request',
'Content-Type: '.$mimeType, 'Content-Type: '.$mimeType,
]], ]],
])); ]);
$response->method('getContent')->willReturn($json); $response->method('getContent')->willReturn($json);
$e = new TestException($response); $e = new TestException($response);

View File

@ -62,7 +62,7 @@ class MemcachedSessionHandlerTest extends TestCase
$this->memcached $this->memcached
->expects($this->once()) ->expects($this->once())
->method('quit') ->method('quit')
->will($this->returnValue(true)) ->willReturn(true)
; ;
$this->assertTrue($this->storage->close()); $this->assertTrue($this->storage->close());
@ -85,7 +85,7 @@ class MemcachedSessionHandlerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('set') ->method('set')
->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2)) ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2))
->will($this->returnValue(true)) ->willReturn(true)
; ;
$this->assertTrue($this->storage->write('id', 'data')); $this->assertTrue($this->storage->write('id', 'data'));
@ -97,7 +97,7 @@ class MemcachedSessionHandlerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('delete') ->method('delete')
->with(self::PREFIX.'id') ->with(self::PREFIX.'id')
->will($this->returnValue(true)) ->willReturn(true)
; ;
$this->assertTrue($this->storage->destroy('id')); $this->assertTrue($this->storage->destroy('id'));

View File

@ -38,11 +38,11 @@ class MigratingSessionHandlerTest extends TestCase
{ {
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('close') ->method('close')
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('close') ->method('close')
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->close(); $result = $this->dualHandler->close();
@ -56,12 +56,12 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('destroy') ->method('destroy')
->with($sessionId) ->with($sessionId)
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('destroy') ->method('destroy')
->with($sessionId) ->with($sessionId)
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->destroy($sessionId); $result = $this->dualHandler->destroy($sessionId);
@ -75,12 +75,12 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('gc') ->method('gc')
->with($maxlifetime) ->with($maxlifetime)
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('gc') ->method('gc')
->with($maxlifetime) ->with($maxlifetime)
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->gc($maxlifetime); $result = $this->dualHandler->gc($maxlifetime);
$this->assertTrue($result); $this->assertTrue($result);
@ -94,12 +94,12 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('open') ->method('open')
->with($savePath, $sessionName) ->with($savePath, $sessionName)
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('open') ->method('open')
->with($savePath, $sessionName) ->with($savePath, $sessionName)
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->open($savePath, $sessionName); $result = $this->dualHandler->open($savePath, $sessionName);
@ -114,7 +114,7 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('read') ->method('read')
->with($sessionId) ->with($sessionId)
->will($this->returnValue($readValue)); ->willReturn($readValue);
$this->writeOnlyHandler->expects($this->never()) $this->writeOnlyHandler->expects($this->never())
->method('read') ->method('read')
@ -133,12 +133,12 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('write') ->method('write')
->with($sessionId, $data) ->with($sessionId, $data)
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('write') ->method('write')
->with($sessionId, $data) ->with($sessionId, $data)
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->write($sessionId, $data); $result = $this->dualHandler->write($sessionId, $data);
@ -153,7 +153,7 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('read') ->method('read')
->with($sessionId) ->with($sessionId)
->will($this->returnValue($readValue)); ->willReturn($readValue);
$this->writeOnlyHandler->expects($this->never()) $this->writeOnlyHandler->expects($this->never())
->method('read') ->method('read')
@ -172,12 +172,12 @@ class MigratingSessionHandlerTest extends TestCase
$this->currentHandler->expects($this->once()) $this->currentHandler->expects($this->once())
->method('write') ->method('write')
->with($sessionId, $data) ->with($sessionId, $data)
->will($this->returnValue(true)); ->willReturn(true);
$this->writeOnlyHandler->expects($this->once()) $this->writeOnlyHandler->expects($this->once())
->method('write') ->method('write')
->with($sessionId, $data) ->with($sessionId, $data)
->will($this->returnValue(false)); ->willReturn(false);
$result = $this->dualHandler->updateTimestamp($sessionId, $data); $result = $this->dualHandler->updateTimestamp($sessionId, $data);

View File

@ -77,7 +77,7 @@ class MongoDbSessionHandlerTest extends TestCase
$this->mongo->expects($this->once()) $this->mongo->expects($this->once())
->method('selectCollection') ->method('selectCollection')
->with($this->options['database'], $this->options['collection']) ->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection)); ->willReturn($collection);
// defining the timeout before the actual method call // defining the timeout before the actual method call
// allows to test for "greater than" values in the $criteria // allows to test for "greater than" values in the $criteria
@ -85,7 +85,7 @@ class MongoDbSessionHandlerTest extends TestCase
$collection->expects($this->once()) $collection->expects($this->once())
->method('findOne') ->method('findOne')
->will($this->returnCallback(function ($criteria) use ($testTimeout) { ->willReturnCallback(function ($criteria) use ($testTimeout) {
$this->assertArrayHasKey($this->options['id_field'], $criteria); $this->assertArrayHasKey($this->options['id_field'], $criteria);
$this->assertEquals($criteria[$this->options['id_field']], 'foo'); $this->assertEquals($criteria[$this->options['id_field']], 'foo');
@ -100,7 +100,7 @@ class MongoDbSessionHandlerTest extends TestCase
$this->options['expiry_field'] => new \MongoDB\BSON\UTCDateTime(), $this->options['expiry_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['data_field'] => new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY), $this->options['data_field'] => new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
]; ];
})); });
$this->assertEquals('bar', $this->storage->read('foo')); $this->assertEquals('bar', $this->storage->read('foo'));
} }
@ -112,11 +112,11 @@ class MongoDbSessionHandlerTest extends TestCase
$this->mongo->expects($this->once()) $this->mongo->expects($this->once())
->method('selectCollection') ->method('selectCollection')
->with($this->options['database'], $this->options['collection']) ->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection)); ->willReturn($collection);
$collection->expects($this->once()) $collection->expects($this->once())
->method('updateOne') ->method('updateOne')
->will($this->returnCallback(function ($criteria, $updateData, $options) { ->willReturnCallback(function ($criteria, $updateData, $options) {
$this->assertEquals([$this->options['id_field'] => 'foo'], $criteria); $this->assertEquals([$this->options['id_field'] => 'foo'], $criteria);
$this->assertEquals(['upsert' => true], $options); $this->assertEquals(['upsert' => true], $options);
@ -127,7 +127,7 @@ class MongoDbSessionHandlerTest extends TestCase
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['time_field']]); $this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['time_field']]);
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['expiry_field']]); $this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $data[$this->options['expiry_field']]);
$this->assertGreaterThanOrEqual($expectedExpiry, round((string) $data[$this->options['expiry_field']] / 1000)); $this->assertGreaterThanOrEqual($expectedExpiry, round((string) $data[$this->options['expiry_field']] / 1000));
})); });
$this->assertTrue($this->storage->write('foo', 'bar')); $this->assertTrue($this->storage->write('foo', 'bar'));
} }
@ -139,15 +139,15 @@ class MongoDbSessionHandlerTest extends TestCase
$this->mongo->expects($this->once()) $this->mongo->expects($this->once())
->method('selectCollection') ->method('selectCollection')
->with($this->options['database'], $this->options['collection']) ->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection)); ->willReturn($collection);
$data = []; $data = [];
$collection->expects($this->exactly(2)) $collection->expects($this->exactly(2))
->method('updateOne') ->method('updateOne')
->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) {
$data = $updateData; $data = $updateData;
})); });
$this->storage->write('foo', 'bar'); $this->storage->write('foo', 'bar');
$this->storage->write('foo', 'foobar'); $this->storage->write('foo', 'foobar');
@ -162,7 +162,7 @@ class MongoDbSessionHandlerTest extends TestCase
$this->mongo->expects($this->once()) $this->mongo->expects($this->once())
->method('selectCollection') ->method('selectCollection')
->with($this->options['database'], $this->options['collection']) ->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection)); ->willReturn($collection);
$collection->expects($this->once()) $collection->expects($this->once())
->method('deleteOne') ->method('deleteOne')
@ -178,14 +178,14 @@ class MongoDbSessionHandlerTest extends TestCase
$this->mongo->expects($this->once()) $this->mongo->expects($this->once())
->method('selectCollection') ->method('selectCollection')
->with($this->options['database'], $this->options['collection']) ->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection)); ->willReturn($collection);
$collection->expects($this->once()) $collection->expects($this->once())
->method('deleteMany') ->method('deleteMany')
->will($this->returnCallback(function ($criteria) { ->willReturnCallback(function ($criteria) {
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$lt']); $this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$lt']);
$this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000)); $this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000));
})); });
$this->assertTrue($this->storage->gc(1)); $this->assertTrue($this->storage->gc(1));
} }

View File

@ -143,7 +143,7 @@ class PdoSessionHandlerTest extends TestCase
$stream = $this->createStream($content); $stream = $this->createStream($content);
$pdo->prepareResult->expects($this->once())->method('fetchAll') $pdo->prepareResult->expects($this->once())->method('fetchAll')
->will($this->returnValue([[$stream, 42, time()]])); ->willReturn([[$stream, 42, time()]]);
$storage = new PdoSessionHandler($pdo); $storage = new PdoSessionHandler($pdo);
$result = $storage->read('foo'); $result = $storage->read('foo');
@ -170,14 +170,14 @@ class PdoSessionHandlerTest extends TestCase
$exception = null; $exception = null;
$selectStmt->expects($this->atLeast(2))->method('fetchAll') $selectStmt->expects($this->atLeast(2))->method('fetchAll')
->will($this->returnCallback(function () use (&$exception, $stream) { ->willReturnCallback(function () use (&$exception, $stream) {
return $exception ? [[$stream, 42, time()]] : []; return $exception ? [[$stream, 42, time()]] : [];
})); });
$insertStmt->expects($this->once())->method('execute') $insertStmt->expects($this->once())->method('execute')
->will($this->returnCallback(function () use (&$exception) { ->willReturnCallback(function () use (&$exception) {
throw $exception = new \PDOException('', '23'); throw $exception = new \PDOException('', '23');
})); });
$storage = new PdoSessionHandler($pdo); $storage = new PdoSessionHandler($pdo);
$result = $storage->read('foo'); $result = $storage->read('foo');

View File

@ -50,7 +50,7 @@ class SessionHandlerProxyTest extends TestCase
{ {
$this->mock->expects($this->once()) $this->mock->expects($this->once())
->method('open') ->method('open')
->will($this->returnValue(true)); ->willReturn(true);
$this->assertFalse($this->proxy->isActive()); $this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id'); $this->proxy->open('name', 'id');
@ -61,7 +61,7 @@ class SessionHandlerProxyTest extends TestCase
{ {
$this->mock->expects($this->once()) $this->mock->expects($this->once())
->method('open') ->method('open')
->will($this->returnValue(false)); ->willReturn(false);
$this->assertFalse($this->proxy->isActive()); $this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id'); $this->proxy->open('name', 'id');
@ -72,7 +72,7 @@ class SessionHandlerProxyTest extends TestCase
{ {
$this->mock->expects($this->once()) $this->mock->expects($this->once())
->method('close') ->method('close')
->will($this->returnValue(true)); ->willReturn(true);
$this->assertFalse($this->proxy->isActive()); $this->assertFalse($this->proxy->isActive());
$this->proxy->close(); $this->proxy->close();
@ -83,7 +83,7 @@ class SessionHandlerProxyTest extends TestCase
{ {
$this->mock->expects($this->once()) $this->mock->expects($this->once())
->method('close') ->method('close')
->will($this->returnValue(false)); ->willReturn(false);
$this->assertFalse($this->proxy->isActive()); $this->assertFalse($this->proxy->isActive());
$this->proxy->close(); $this->proxy->close();

View File

@ -59,7 +59,7 @@ class CacheWarmerAggregateTest extends TestCase
$warmer $warmer
->expects($this->once()) ->expects($this->once())
->method('isOptional') ->method('isOptional')
->will($this->returnValue(true)); ->willReturn(true);
$warmer $warmer
->expects($this->never()) ->expects($this->never())
->method('warmUp'); ->method('warmUp');

View File

@ -23,7 +23,7 @@ class FileLocatorTest extends TestCase
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('locateResource') ->method('locateResource')
->with('@BundleName/some/path', null, true) ->with('@BundleName/some/path', null, true)
->will($this->returnValue('/bundle-name/some/path')); ->willReturn('/bundle-name/some/path');
$locator = new FileLocator($kernel); $locator = new FileLocator($kernel);
$this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));

View File

@ -27,11 +27,11 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with('foo') ->with('foo')
->will($this->returnValue(true)); ->willReturn(true);
$container->expects($this->once()) $container->expects($this->once())
->method('get') ->method('get')
->with('foo') ->with('foo')
->will($this->returnValue($service)) ->willReturn($service)
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);
@ -52,11 +52,11 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with('foo') ->with('foo')
->will($this->returnValue(true)); ->willReturn(true);
$container->expects($this->once()) $container->expects($this->once())
->method('get') ->method('get')
->with('foo') ->with('foo')
->will($this->returnValue($service)) ->willReturn($service)
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);
@ -77,12 +77,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with('foo') ->with('foo')
->will($this->returnValue(true)) ->willReturn(true)
; ;
$container->expects($this->once()) $container->expects($this->once())
->method('get') ->method('get')
->with('foo') ->with('foo')
->will($this->returnValue($service)) ->willReturn($service)
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);
@ -102,12 +102,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with(InvokableControllerService::class) ->with(InvokableControllerService::class)
->will($this->returnValue(true)) ->willReturn(true)
; ;
$container->expects($this->once()) $container->expects($this->once())
->method('get') ->method('get')
->with(InvokableControllerService::class) ->with(InvokableControllerService::class)
->will($this->returnValue($service)) ->willReturn($service)
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);
@ -131,13 +131,13 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with(ControllerTestService::class) ->with(ControllerTestService::class)
->will($this->returnValue(false)) ->willReturn(false)
; ;
$container->expects($this->atLeastOnce()) $container->expects($this->atLeastOnce())
->method('getRemovedIds') ->method('getRemovedIds')
->with() ->with()
->will($this->returnValue([ControllerTestService::class => true])) ->willReturn([ControllerTestService::class => true])
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);
@ -159,13 +159,13 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once()) $container->expects($this->once())
->method('has') ->method('has')
->with('app.my_controller') ->with('app.my_controller')
->will($this->returnValue(false)) ->willReturn(false)
; ;
$container->expects($this->atLeastOnce()) $container->expects($this->atLeastOnce())
->method('getRemovedIds') ->method('getRemovedIds')
->with() ->with()
->will($this->returnValue(['app.my_controller' => true])) ->willReturn(['app.my_controller' => true])
; ;
$resolver = $this->createControllerResolver(null, $container); $resolver = $this->createControllerResolver(null, $container);

View File

@ -27,8 +27,8 @@ class LoggerDataCollectorTest extends TestCase
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
->setMethods(['countErrors', 'getLogs', 'clear']) ->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock(); ->getMock();
$logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo')); $logger->expects($this->once())->method('countErrors')->willReturn('foo');
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([])); $logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/'); $c = new LoggerDataCollector($logger, __DIR__.'/');
$c->lateCollect(); $c->lateCollect();
@ -56,7 +56,7 @@ class LoggerDataCollectorTest extends TestCase
->setMethods(['countErrors', 'getLogs', 'clear']) ->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock(); ->getMock();
$logger->expects($this->once())->method('countErrors')->with(null); $logger->expects($this->once())->method('countErrors')->with(null);
$logger->expects($this->exactly(2))->method('getLogs')->with(null)->will($this->returnValue([])); $logger->expects($this->exactly(2))->method('getLogs')->with(null)->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/', $stack); $c = new LoggerDataCollector($logger, __DIR__.'/', $stack);
@ -77,7 +77,7 @@ class LoggerDataCollectorTest extends TestCase
->setMethods(['countErrors', 'getLogs', 'clear']) ->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock(); ->getMock();
$logger->expects($this->once())->method('countErrors')->with($subRequest); $logger->expects($this->once())->method('countErrors')->with($subRequest);
$logger->expects($this->exactly(2))->method('getLogs')->with($subRequest)->will($this->returnValue([])); $logger->expects($this->exactly(2))->method('getLogs')->with($subRequest)->willReturn([]);
$c = new LoggerDataCollector($logger, __DIR__.'/', $stack); $c = new LoggerDataCollector($logger, __DIR__.'/', $stack);
@ -94,8 +94,8 @@ class LoggerDataCollectorTest extends TestCase
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
->setMethods(['countErrors', 'getLogs', 'clear']) ->setMethods(['countErrors', 'getLogs', 'clear'])
->getMock(); ->getMock();
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); $logger->expects($this->once())->method('countErrors')->willReturn($nb);
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); $logger->expects($this->exactly(2))->method('getLogs')->willReturn($logs);
$c = new LoggerDataCollector($logger); $c = new LoggerDataCollector($logger);
$c->lateCollect(); $c->lateCollect();

View File

@ -44,7 +44,7 @@ class TimeDataCollectorTest extends TestCase
$this->assertEquals(0, $c->getStartTime()); $this->assertEquals(0, $c->getStartTime());
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); $kernel->expects($this->once())->method('getStartTime')->willReturn(123456);
$c = new TimeDataCollector($kernel); $c = new TimeDataCollector($kernel);
$request = new Request(); $request = new Request();

View File

@ -50,7 +50,7 @@ class TraceableEventDispatcherTest extends TestCase
->getMock(); ->getMock();
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('isStarted') ->method('isStarted')
->will($this->returnValue(false)); ->willReturn(false);
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
@ -66,7 +66,7 @@ class TraceableEventDispatcherTest extends TestCase
->getMock(); ->getMock();
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('isStarted') ->method('isStarted')
->will($this->returnValue(true)); ->willReturn(true);
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('stop'); ->method('stop');
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
@ -113,9 +113,9 @@ class TraceableEventDispatcherTest extends TestCase
protected function getHttpKernel($dispatcher, $controller) protected function getHttpKernel($dispatcher, $controller)
{ {
$controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock();
$controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); $controllerResolver->expects($this->once())->method('getController')->willReturn($controller);
$argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock();
$argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue([])); $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]);
return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver);
} }

View File

@ -21,15 +21,15 @@ class LazyLoadingFragmentHandlerTest extends TestCase
public function testRender() public function testRender()
{ {
$renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); $renderer->expects($this->once())->method('getName')->willReturn('foo');
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); $renderer->expects($this->any())->method('render')->willReturn(new Response());
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
$container->expects($this->once())->method('has')->with('foo')->willReturn(true); $container->expects($this->once())->method('has')->with('foo')->willReturn(true);
$container->expects($this->once())->method('get')->will($this->returnValue($renderer)); $container->expects($this->once())->method('get')->willReturn($renderer);
$handler = new LazyLoadingFragmentHandler($container, $requestStack, false); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false);

View File

@ -78,7 +78,7 @@ class AddRequestFormatsListenerTest extends TestCase
$event->expects($this->any()) $event->expects($this->any())
->method('getRequest') ->method('getRequest')
->will($this->returnValue($request)); ->willReturn($request);
return $event; return $event;
} }

View File

@ -94,7 +94,7 @@ class DebugHandlersListenerTest extends TestCase
$dispatcher = new EventDispatcher(); $dispatcher = new EventDispatcher();
$listener = new DebugHandlersListener(null); $listener = new DebugHandlersListener(null);
$app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock();
$app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet());
$command = new Command(__FUNCTION__); $command = new Command(__FUNCTION__);
$command->setApplication($app); $command->setApplication($app);
$event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput()); $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());

View File

@ -116,9 +116,9 @@ class ExceptionListenerTest extends TestCase
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock());
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat()); return new Response($request->getRequestFormat());
})); });
$request = Request::create('/'); $request = Request::create('/');
$request->setRequestFormat('xml'); $request->setRequestFormat('xml');
@ -134,9 +134,9 @@ class ExceptionListenerTest extends TestCase
{ {
$dispatcher = new EventDispatcher(); $dispatcher = new EventDispatcher();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat()); return new Response($request->getRequestFormat());
})); });
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true);
@ -160,11 +160,11 @@ class ExceptionListenerTest extends TestCase
{ {
$listener = new ExceptionListener(null); $listener = new ExceptionListener(null);
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
$controller = $request->attributes->get('_controller'); $controller = $request->attributes->get('_controller');
return $controller(); return $controller();
})); });
$request = Request::create('/'); $request = Request::create('/');
$event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));

View File

@ -73,7 +73,7 @@ class LocaleListenerTest extends TestCase
$context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $context->expects($this->once())->method('setParameter')->with('_locale', 'es');
$router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock();
$router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $router->expects($this->once())->method('getContext')->willReturn($context);
$request = Request::create('/'); $request = Request::create('/');
@ -89,12 +89,12 @@ class LocaleListenerTest extends TestCase
$context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $context->expects($this->once())->method('setParameter')->with('_locale', 'es');
$router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock();
$router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $router->expects($this->once())->method('getContext')->willReturn($context);
$parentRequest = Request::create('/'); $parentRequest = Request::create('/');
$parentRequest->setLocale('es'); $parentRequest->setLocale('es');
$this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); $this->requestStack->expects($this->once())->method('getParentRequest')->willReturn($parentRequest);
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock();

View File

@ -36,7 +36,7 @@ class ProfilerListenerTest extends TestCase
$profiler->expects($this->once()) $profiler->expects($this->once())
->method('collect') ->method('collect')
->will($this->returnValue($profile)); ->willReturn($profile);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();

View File

@ -49,7 +49,7 @@ class RouterListenerTest extends TestCase
$context->setHttpsPort($defaultHttpsPort); $context->setHttpsPort($defaultHttpsPort);
$urlMatcher->expects($this->any()) $urlMatcher->expects($this->any())
->method('getContext') ->method('getContext')
->will($this->returnValue($context)); ->willReturn($context);
$listener = new RouterListener($urlMatcher, $this->requestStack); $listener = new RouterListener($urlMatcher, $this->requestStack);
$event = $this->createRequestEventForUri($uri); $event = $this->createRequestEventForUri($uri);
@ -97,7 +97,7 @@ class RouterListenerTest extends TestCase
$requestMatcher->expects($this->once()) $requestMatcher->expects($this->once())
->method('matchRequest') ->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
->will($this->returnValue([])); ->willReturn([]);
$listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext());
$listener->onKernelRequest($event); $listener->onKernelRequest($event);
@ -113,7 +113,7 @@ class RouterListenerTest extends TestCase
$requestMatcher->expects($this->any()) $requestMatcher->expects($this->any())
->method('matchRequest') ->method('matchRequest')
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
->will($this->returnValue([])); ->willReturn([]);
$context = new RequestContext(); $context = new RequestContext();
@ -138,7 +138,7 @@ class RouterListenerTest extends TestCase
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once()) $requestMatcher->expects($this->once())
->method('matchRequest') ->method('matchRequest')
->will($this->returnValue($parameter)); ->willReturn($parameter);
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$logger->expects($this->once()) $logger->expects($this->once())

View File

@ -46,7 +46,7 @@ class TestSessionListenerTest extends TestCase
$this->session = $this->getSession(); $this->session = $this->getSession();
$this->listener->expects($this->any()) $this->listener->expects($this->any())
->method('getSession') ->method('getSession')
->will($this->returnValue($this->session)); ->willReturn($this->session);
} }
public function testShouldSaveMasterRequestSession() public function testShouldSaveMasterRequestSession()
@ -183,28 +183,28 @@ class TestSessionListenerTest extends TestCase
{ {
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('isStarted') ->method('isStarted')
->will($this->returnValue(true)); ->willReturn(true);
} }
private function sessionHasNotBeenStarted() private function sessionHasNotBeenStarted()
{ {
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('isStarted') ->method('isStarted')
->will($this->returnValue(false)); ->willReturn(false);
} }
private function sessionIsEmpty() private function sessionIsEmpty()
{ {
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('isEmpty') ->method('isEmpty')
->will($this->returnValue(true)); ->willReturn(true);
} }
private function fixSessionId($sessionId) private function fixSessionId($sessionId)
{ {
$this->session->expects($this->any()) $this->session->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue($sessionId)); ->willReturn($sessionId);
} }
private function getSession() private function getSession()
@ -214,7 +214,7 @@ class TestSessionListenerTest extends TestCase
->getMock(); ->getMock();
// set return value for getName() // set return value for getName()
$mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID');
return $mock; return $mock;
} }

View File

@ -117,6 +117,6 @@ class TranslatorListenerTest extends TestCase
$this->requestStack $this->requestStack
->expects($this->any()) ->expects($this->any())
->method('getParentRequest') ->method('getParentRequest')
->will($this->returnValue($request)); ->willReturn($request);
} }
} }

View File

@ -32,7 +32,7 @@ class FragmentHandlerTest extends TestCase
$this->requestStack $this->requestStack
->expects($this->any()) ->expects($this->any())
->method('getCurrentRequest') ->method('getCurrentRequest')
->will($this->returnValue(Request::create('/'))) ->willReturn(Request::create('/'))
; ;
} }
@ -79,7 +79,7 @@ class FragmentHandlerTest extends TestCase
$renderer $renderer
->expects($this->any()) ->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue('foo')) ->willReturn('foo')
; ;
$e = $renderer $e = $renderer
->expects($this->any()) ->expects($this->any())

View File

@ -124,18 +124,18 @@ class InlineFragmentRendererTest extends TestCase
$controllerResolver $controllerResolver
->expects($this->once()) ->expects($this->once())
->method('getController') ->method('getController')
->will($this->returnValue(function () { ->willReturn(function () {
ob_start(); ob_start();
echo 'bar'; echo 'bar';
throw new \RuntimeException(); throw new \RuntimeException();
})) })
; ;
$argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock();
$argumentResolver $argumentResolver
->expects($this->once()) ->expects($this->once())
->method('getArguments') ->method('getArguments')
->will($this->returnValue([])) ->willReturn([])
; ;
$kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver); $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver);

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