minor #31738 Use willReturn() instead of will(returnValue()) (derrabus)
This PR was merged into the 3.4 branch.
Discussion
----------
Use willReturn() instead of will(returnValue())
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | N/A
| License | MIT
| Doc PR | N/A
In a recent PR, fabbot complained about the usage of will(returnValue()) in test cases that I haven't changed. In this PR, I've applied the PHP CS Fixer's `php_unit_mock_short_will_return` fixer on the whole codebase.
Commits
-------
4fb67df612
Use willReturn() instead of will(returnValue()).
This commit is contained in:
commit
3cd3522735
@ -18,8 +18,6 @@ return PhpCsFixer\Config::create()
|
||||
'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
|
||||
'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)
|
||||
->setFinder(
|
||||
|
@ -166,20 +166,20 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
->getMock();
|
||||
$connection->expects($this->any())
|
||||
->method('getDatabasePlatform')
|
||||
->will($this->returnValue(new MySqlPlatform()));
|
||||
->willReturn(new MySqlPlatform());
|
||||
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getConnectionNames')
|
||||
->will($this->returnValue(['default' => 'doctrine.dbal.default_connection']));
|
||||
->willReturn(['default' => 'doctrine.dbal.default_connection']);
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getManagerNames')
|
||||
->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager']));
|
||||
->willReturn(['default' => 'doctrine.orm.default_entity_manager']);
|
||||
$registry->expects($this->any())
|
||||
->method('getConnection')
|
||||
->will($this->returnValue($connection));
|
||||
->willReturn($connection);
|
||||
|
||||
$logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
|
||||
$logger->queries = $queries;
|
||||
|
@ -44,9 +44,9 @@ class DoctrineExtensionTest extends TestCase
|
||||
|
||||
$this->extension->expects($this->any())
|
||||
->method('getObjectManagerElementName')
|
||||
->will($this->returnCallback(function ($name) {
|
||||
->willReturnCallback(function ($name) {
|
||||
return 'doctrine.orm.'.$name;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ class DoctrineParserCacheTest extends TestCase
|
||||
|
||||
$doctrineCacheMock->expects($this->once())
|
||||
->method('fetch')
|
||||
->will($this->returnValue('bar'));
|
||||
->willReturn('bar');
|
||||
|
||||
$result = $parserCache->fetch('foo');
|
||||
|
||||
@ -41,7 +41,7 @@ class DoctrineParserCacheTest extends TestCase
|
||||
$doctrineCacheMock
|
||||
->expects($this->once())
|
||||
->method('fetch')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->assertNull($parserCache->fetch(''));
|
||||
}
|
||||
|
@ -34,47 +34,47 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
// Simple field, not nullable
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$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)];
|
||||
|
||||
// Simple field, nullable
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$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)];
|
||||
|
||||
// One-to-one, nullable (by default)
|
||||
$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' => [[]]];
|
||||
$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)];
|
||||
|
||||
// One-to-one, nullable (explicit)
|
||||
$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]]];
|
||||
$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)];
|
||||
|
||||
// One-to-one, not nullable
|
||||
$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]]];
|
||||
$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)];
|
||||
|
||||
// One-to-many, no clue
|
||||
$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];
|
||||
|
||||
@ -84,10 +84,10 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
private function getGuesser(ClassMetadata $classMetadata)
|
||||
{
|
||||
$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->expects($this->once())->method('getManagers')->will($this->returnValue([$em]));
|
||||
$registry->expects($this->once())->method('getManagers')->willReturn([$em]);
|
||||
|
||||
return new DoctrineOrmTypeGuesser($registry);
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
->will($this->returnValue($this->em));
|
||||
->willReturn($this->em);
|
||||
|
||||
$manager->expects($this->any())
|
||||
->method('getManagerForClass')
|
||||
->will($this->returnValue($this->em));
|
||||
->willReturn($this->em);
|
||||
|
||||
return [
|
||||
new CoreExtension(),
|
||||
|
@ -1087,7 +1087,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$this->emRegistry->expects($this->once())
|
||||
->method('getManagerForClass')
|
||||
->with(self::SINGLE_IDENT_CLASS)
|
||||
->will($this->returnValue($this->em));
|
||||
->willReturn($this->em);
|
||||
|
||||
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
@ -1237,7 +1237,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
->will($this->returnValue($em));
|
||||
->willReturn($em);
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class EntityUserProviderTest extends TestCase
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
->will($this->returnValue($em));
|
||||
->willReturn($em);
|
||||
|
||||
return $manager;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo(self::EM_NAME))
|
||||
->will($this->returnValue($em));
|
||||
->willReturn($em);
|
||||
|
||||
return $registry;
|
||||
}
|
||||
@ -104,14 +104,14 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
;
|
||||
$em->expects($this->any())
|
||||
->method('getRepository')
|
||||
->will($this->returnValue($repositoryMock))
|
||||
->willReturn($repositoryMock)
|
||||
;
|
||||
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
|
||||
$classMetadata
|
||||
->expects($this->any())
|
||||
->method('hasField')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
|
||||
->disableOriginalConstructor()
|
||||
@ -125,12 +125,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$refl
|
||||
->expects($this->any())
|
||||
->method('getValue')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$classMetadata->reflFields = ['name' => $refl];
|
||||
$em->expects($this->any())
|
||||
->method('getClassMetadata')
|
||||
->will($this->returnValue($classMetadata))
|
||||
->willReturn($classMetadata)
|
||||
;
|
||||
|
||||
return $em;
|
||||
@ -366,7 +366,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will($this->returnValue([]))
|
||||
->willReturn([])
|
||||
;
|
||||
$this->em = $this->createEntityManagerMock($repository);
|
||||
$this->registry = $this->createRegistryMock($this->em);
|
||||
@ -394,15 +394,15 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will(
|
||||
$this->returnCallback(function () use ($entity) {
|
||||
->willReturnCallback(
|
||||
function () use ($entity) {
|
||||
$returnValue = [
|
||||
$entity,
|
||||
];
|
||||
next($returnValue);
|
||||
|
||||
return $returnValue;
|
||||
})
|
||||
}
|
||||
)
|
||||
;
|
||||
$this->em = $this->createEntityManagerMock($repository);
|
||||
@ -430,7 +430,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will($this->returnValue($result))
|
||||
->willReturn($result)
|
||||
;
|
||||
$this->em = $this->createEntityManagerMock($repository);
|
||||
$this->registry = $this->createRegistryMock($this->em);
|
||||
@ -564,7 +564,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will($this->returnValue([$entity1]))
|
||||
->willReturn([$entity1])
|
||||
;
|
||||
|
||||
$this->em->persist($entity1);
|
||||
@ -635,7 +635,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository
|
||||
->method('find')
|
||||
->will($this->returnValue(null))
|
||||
->willReturn(null)
|
||||
;
|
||||
|
||||
$this->em = $this->createEntityManagerMock($repository);
|
||||
|
@ -50,7 +50,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
$output
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getVerbosity')
|
||||
->will($this->returnValue($verbosity))
|
||||
->willReturn($verbosity)
|
||||
;
|
||||
$handler = new ConsoleHandler($output, true, $map);
|
||||
$this->assertSame($isHandling, $handler->isHandling(['level' => $level]),
|
||||
@ -114,12 +114,12 @@ class ConsoleHandlerTest extends TestCase
|
||||
$output
|
||||
->expects($this->at(0))
|
||||
->method('getVerbosity')
|
||||
->will($this->returnValue(OutputInterface::VERBOSITY_QUIET))
|
||||
->willReturn(OutputInterface::VERBOSITY_QUIET)
|
||||
;
|
||||
$output
|
||||
->expects($this->at(1))
|
||||
->method('getVerbosity')
|
||||
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
|
||||
->willReturn(OutputInterface::VERBOSITY_DEBUG)
|
||||
;
|
||||
$handler = new ConsoleHandler($output);
|
||||
$this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]),
|
||||
@ -144,7 +144,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
$output
|
||||
->expects($this->any())
|
||||
->method('getVerbosity')
|
||||
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
|
||||
->willReturn(OutputInterface::VERBOSITY_DEBUG)
|
||||
;
|
||||
$output
|
||||
->expects($this->once())
|
||||
|
@ -95,10 +95,10 @@ class WebProcessorTest extends TestCase
|
||||
->getMock();
|
||||
$event->expects($this->any())
|
||||
->method('isMasterRequest')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request));
|
||||
->willReturn($request);
|
||||
|
||||
return [$event, $server];
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class HttpKernelExtensionTest extends TestCase
|
||||
protected function getFragmentHandler($return)
|
||||
{
|
||||
$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);
|
||||
|
||||
$context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')
|
||||
@ -70,7 +70,7 @@ class HttpKernelExtensionTest extends TestCase
|
||||
->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);
|
||||
}
|
||||
@ -82,9 +82,9 @@ class HttpKernelExtensionTest extends TestCase
|
||||
$twig->addExtension(new HttpKernelExtension());
|
||||
|
||||
$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)],
|
||||
]));
|
||||
]);
|
||||
$twig->addRuntimeLoader($loader);
|
||||
|
||||
return $twig->render('index');
|
||||
|
@ -34,7 +34,7 @@ class TemplateFinderTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->once())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue(['BaseBundle' => new BaseBundle()]))
|
||||
->willReturn(['BaseBundle' => new BaseBundle()])
|
||||
;
|
||||
|
||||
$parser = new TemplateFilenameParser();
|
||||
|
@ -68,13 +68,13 @@ class TemplatePathsCacheWarmerTest extends TestCase
|
||||
$this->templateFinder
|
||||
->expects($this->once())
|
||||
->method('findAllTemplates')
|
||||
->will($this->returnValue([$template]));
|
||||
->willReturn([$template]);
|
||||
|
||||
$this->fileLocator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->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->warmUp($this->tmpDir);
|
||||
@ -87,7 +87,7 @@ class TemplatePathsCacheWarmerTest extends TestCase
|
||||
$this->templateFinder
|
||||
->expects($this->once())
|
||||
->method('findAllTemplates')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$this->fileLocator
|
||||
->expects($this->never())
|
||||
|
@ -82,7 +82,7 @@ class RouterDebugCommandTest extends TestCase
|
||||
$router
|
||||
->expects($this->any())
|
||||
->method('getRouteCollection')
|
||||
->will($this->returnValue($routeCollection));
|
||||
->willReturn($routeCollection);
|
||||
|
||||
return $router;
|
||||
}
|
||||
@ -93,13 +93,13 @@ class RouterDebugCommandTest extends TestCase
|
||||
$container
|
||||
->expects($this->atLeastOnce())
|
||||
->method('has')
|
||||
->will($this->returnCallback(function ($id) {
|
||||
->willReturnCallback(function ($id) {
|
||||
if ('console.command_loader' === $id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}))
|
||||
})
|
||||
;
|
||||
$container
|
||||
->expects($this->any())
|
||||
|
@ -80,11 +80,11 @@ class RouterMatchCommandTest extends TestCase
|
||||
$router
|
||||
->expects($this->any())
|
||||
->method('getRouteCollection')
|
||||
->will($this->returnValue($routeCollection));
|
||||
->willReturn($routeCollection);
|
||||
$router
|
||||
->expects($this->any())
|
||||
->method('getContext')
|
||||
->will($this->returnValue($requestContext));
|
||||
->willReturn($requestContext);
|
||||
|
||||
return $router;
|
||||
}
|
||||
@ -95,9 +95,9 @@ class RouterMatchCommandTest extends TestCase
|
||||
$container
|
||||
->expects($this->atLeastOnce())
|
||||
->method('has')
|
||||
->will($this->returnCallback(function ($id) {
|
||||
->willReturnCallback(function ($id) {
|
||||
return 'console.command_loader' !== $id;
|
||||
}))
|
||||
})
|
||||
;
|
||||
$container
|
||||
->expects($this->any())
|
||||
|
@ -136,26 +136,26 @@ class TranslationDebugCommandTest extends TestCase
|
||||
$translator
|
||||
->expects($this->any())
|
||||
->method('getFallbackLocales')
|
||||
->will($this->returnValue(['en']));
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->method('extract')
|
||||
->will(
|
||||
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
|
||||
->willReturnCallback(
|
||||
function ($path, $catalogue) use ($extractedMessages) {
|
||||
$catalogue->add($extractedMessages);
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
->will(
|
||||
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
|
||||
->willReturnCallback(
|
||||
function ($path, $catalogue) use ($loadedMessages) {
|
||||
$catalogue->add($loadedMessages);
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
if (null === $kernel) {
|
||||
@ -173,23 +173,23 @@ class TranslationDebugCommandTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
->will($this->returnValueMap($returnValues));
|
||||
->willReturnMap($returnValues);
|
||||
}
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getRootDir')
|
||||
->will($this->returnValue($this->translationDir));
|
||||
->willReturn($this->translationDir);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
|
||||
->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock());
|
||||
|
||||
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates');
|
||||
|
||||
@ -214,23 +214,23 @@ class TranslationDebugCommandTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap([
|
||||
->willReturnMap([
|
||||
['translation.extractor', 1, $extractor],
|
||||
['translation.reader', 1, $loader],
|
||||
['translator', 1, $translator],
|
||||
['kernel', 1, $kernel],
|
||||
]));
|
||||
]);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
->will($this->returnValue($container));
|
||||
->willReturn($container);
|
||||
|
||||
$command = new TranslationDebugCommand();
|
||||
$command->setContainer($container);
|
||||
@ -250,7 +250,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
->will($this->returnValue($path))
|
||||
->willReturn($path)
|
||||
;
|
||||
|
||||
return $bundle;
|
||||
|
@ -114,36 +114,36 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
$translator
|
||||
->expects($this->any())
|
||||
->method('getFallbackLocales')
|
||||
->will($this->returnValue(['en']));
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->method('extract')
|
||||
->will(
|
||||
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
|
||||
->willReturnCallback(
|
||||
function ($path, $catalogue) use ($extractedMessages) {
|
||||
foreach ($extractedMessages as $domain => $messages) {
|
||||
$catalogue->add($messages, $domain);
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
->will(
|
||||
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
|
||||
->willReturnCallback(
|
||||
function ($path, $catalogue) use ($loadedMessages) {
|
||||
$catalogue->add($loadedMessages);
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
|
||||
$writer
|
||||
->expects($this->any())
|
||||
->method('getFormats')
|
||||
->will(
|
||||
$this->returnValue(['xlf', 'yml', 'yaml'])
|
||||
->willReturn(
|
||||
['xlf', 'yml', 'yaml']
|
||||
);
|
||||
|
||||
if (null === $kernel) {
|
||||
@ -161,23 +161,23 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
->will($this->returnValueMap($returnValues));
|
||||
->willReturnMap($returnValues);
|
||||
}
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getRootDir')
|
||||
->will($this->returnValue($this->translationDir));
|
||||
->willReturn($this->translationDir);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
|
||||
->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock());
|
||||
|
||||
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates');
|
||||
|
||||
@ -203,24 +203,24 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap([
|
||||
->willReturnMap([
|
||||
['translation.extractor', 1, $extractor],
|
||||
['translation.reader', 1, $loader],
|
||||
['translation.writer', 1, $writer],
|
||||
['translator', 1, $translator],
|
||||
['kernel', 1, $kernel],
|
||||
]));
|
||||
]);
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
->will($this->returnValue($container));
|
||||
->willReturn($container);
|
||||
|
||||
$command = new TranslationUpdateCommand();
|
||||
$command->setContainer($container);
|
||||
@ -240,7 +240,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
->will($this->returnValue($path))
|
||||
->willReturn($path)
|
||||
;
|
||||
|
||||
return $bundle;
|
||||
|
@ -206,7 +206,7 @@ class ApplicationTest extends TestCase
|
||||
->expects($this->atLeastOnce())
|
||||
->method('get')
|
||||
->with($this->equalTo('event_dispatcher'))
|
||||
->will($this->returnValue($dispatcher));
|
||||
->willReturn($dispatcher);
|
||||
}
|
||||
|
||||
$container
|
||||
@ -226,12 +226,12 @@ class ApplicationTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue($bundles))
|
||||
->willReturn($bundles)
|
||||
;
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
->will($this->returnValue($container))
|
||||
->willReturn($container)
|
||||
;
|
||||
|
||||
return $kernel;
|
||||
@ -243,9 +243,9 @@ class ApplicationTest extends TestCase
|
||||
$bundle
|
||||
->expects($this->once())
|
||||
->method('registerCommands')
|
||||
->will($this->returnCallback(function (Application $application) use ($commands) {
|
||||
->willReturnCallback(function (Application $application) use ($commands) {
|
||||
$application->addCommands($commands);
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
return $bundle;
|
||||
|
@ -156,13 +156,13 @@ class ControllerNameParserTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
->will($this->returnCallback(function ($bundle) use ($bundles) {
|
||||
->willReturnCallback(function ($bundle) use ($bundles) {
|
||||
if (!isset($bundles[$bundle])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle));
|
||||
}
|
||||
|
||||
return $bundles[$bundle];
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$bundles = [
|
||||
@ -175,7 +175,7 @@ class ControllerNameParserTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue($bundles))
|
||||
->willReturn($bundles)
|
||||
;
|
||||
|
||||
return new ControllerNameParser($kernel);
|
||||
@ -184,8 +184,8 @@ class ControllerNameParserTest extends TestCase
|
||||
private function getBundle($namespace, $name)
|
||||
{
|
||||
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
|
||||
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
|
||||
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
|
||||
$bundle->expects($this->any())->method('getName')->willReturn($name);
|
||||
$bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
|
||||
|
||||
return $bundle;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
$parser->expects($this->once())
|
||||
->method('parse')
|
||||
->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);
|
||||
|
@ -43,9 +43,9 @@ abstract class ControllerTraitTest extends TestCase
|
||||
$requestStack->push($request);
|
||||
|
||||
$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());
|
||||
}));
|
||||
});
|
||||
|
||||
$container = new Container();
|
||||
$container->set('request_stack', $requestStack);
|
||||
@ -110,7 +110,7 @@ abstract class ControllerTraitTest extends TestCase
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token));
|
||||
->willReturn($token);
|
||||
|
||||
$container = new Container();
|
||||
$container->set('security.token_storage', $tokenStorage);
|
||||
@ -137,7 +137,7 @@ abstract class ControllerTraitTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('serialize')
|
||||
->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS])
|
||||
->will($this->returnValue('[]'));
|
||||
->willReturn('[]');
|
||||
|
||||
$container->set('serializer', $serializer);
|
||||
|
||||
@ -158,7 +158,7 @@ abstract class ControllerTraitTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('serialize')
|
||||
->with([], 'json', ['json_encode_options' => 0, 'other' => 'context'])
|
||||
->will($this->returnValue('[]'));
|
||||
->willReturn('[]');
|
||||
|
||||
$container->set('serializer', $serializer);
|
||||
|
||||
|
@ -72,7 +72,7 @@ class RedirectControllerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('generate')
|
||||
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
|
||||
->will($this->returnValue($url));
|
||||
->willReturn($url);
|
||||
|
||||
$controller = new RedirectController($router);
|
||||
|
||||
@ -250,23 +250,23 @@ class RedirectControllerTest extends TestCase
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getScheme')
|
||||
->will($this->returnValue($scheme));
|
||||
->willReturn($scheme);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getHost')
|
||||
->will($this->returnValue($host));
|
||||
->willReturn($host);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getPort')
|
||||
->will($this->returnValue($port));
|
||||
->willReturn($port);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getBaseUrl')
|
||||
->will($this->returnValue($baseUrl));
|
||||
->willReturn($baseUrl);
|
||||
$request
|
||||
->expects($this->any())
|
||||
->method('getQueryString')
|
||||
->will($this->returnValue($queryString));
|
||||
->willReturn($queryString);
|
||||
|
||||
return $request;
|
||||
}
|
||||
@ -288,24 +288,24 @@ class RedirectControllerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('hasParameter')
|
||||
->with($this->equalTo('request_listener.http_port'))
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with($this->equalTo('request_listener.http_port'))
|
||||
->will($this->returnValue($httpPort));
|
||||
->willReturn($httpPort);
|
||||
}
|
||||
if (null !== $httpsPort) {
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('hasParameter')
|
||||
->with($this->equalTo('request_listener.https_port'))
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with($this->equalTo('request_listener.https_port'))
|
||||
->will($this->returnValue($httpsPort));
|
||||
->willReturn($httpsPort);
|
||||
}
|
||||
|
||||
$controller = new RedirectController();
|
||||
|
@ -49,9 +49,9 @@ class TemplateControllerTest extends TestCase
|
||||
$twig->expects($this->once())->method('render')->willReturn('bar');
|
||||
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$container->expects($this->at(0))->method('has')->will($this->returnValue(false));
|
||||
$container->expects($this->at(1))->method('has')->will($this->returnValue(true));
|
||||
$container->expects($this->at(2))->method('get')->will($this->returnValue($twig));
|
||||
$container->expects($this->at(0))->method('has')->willReturn(false);
|
||||
$container->expects($this->at(1))->method('has')->willReturn(true);
|
||||
$container->expects($this->at(2))->method('get')->willReturn($twig);
|
||||
|
||||
$controller = new TemplateController();
|
||||
$controller->setContainer($container);
|
||||
@ -69,7 +69,7 @@ class TemplateControllerTest extends TestCase
|
||||
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$container->expects($this->at(0))->method('has')->willReturn(true);
|
||||
$container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
|
||||
$container->expects($this->at(1))->method('get')->willReturn($templating);
|
||||
|
||||
$controller = new TemplateController();
|
||||
$controller->setContainer($container);
|
||||
|
@ -248,7 +248,7 @@ class RouterTest extends TestCase
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValue($routes))
|
||||
->willReturn($routes)
|
||||
;
|
||||
|
||||
$sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock();
|
||||
@ -256,7 +256,7 @@ class RouterTest extends TestCase
|
||||
$sc
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->will($this->returnValue($loader))
|
||||
->willReturn($loader)
|
||||
;
|
||||
|
||||
return $sc;
|
||||
|
@ -67,7 +67,7 @@ class DelegatingEngineTest extends TestCase
|
||||
$engine->expects($this->once())
|
||||
->method('renderResponse')
|
||||
->with('template.php', ['foo' => 'bar'])
|
||||
->will($this->returnValue($response));
|
||||
->willReturn($response);
|
||||
$container = $this->getContainerMock(['engine' => $engine]);
|
||||
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine']);
|
||||
@ -91,7 +91,7 @@ class DelegatingEngineTest extends TestCase
|
||||
$engine->expects($this->once())
|
||||
->method('supports')
|
||||
->with($template)
|
||||
->will($this->returnValue($supports));
|
||||
->willReturn($supports);
|
||||
|
||||
return $engine;
|
||||
}
|
||||
@ -103,7 +103,7 @@ class DelegatingEngineTest extends TestCase
|
||||
$engine->expects($this->once())
|
||||
->method('supports')
|
||||
->with($template)
|
||||
->will($this->returnValue($supports));
|
||||
->willReturn($supports);
|
||||
|
||||
return $engine;
|
||||
}
|
||||
@ -117,7 +117,7 @@ class DelegatingEngineTest extends TestCase
|
||||
$container->expects($this->at($i++))
|
||||
->method('get')
|
||||
->with($id)
|
||||
->will($this->returnValue($service));
|
||||
->willReturn($service);
|
||||
}
|
||||
|
||||
return $container;
|
||||
|
@ -47,7 +47,7 @@ class GlobalVariablesTest extends TestCase
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue('token'));
|
||||
->willReturn('token');
|
||||
|
||||
$this->assertSame('token', $this->globals->getToken());
|
||||
}
|
||||
@ -77,12 +77,12 @@ class GlobalVariablesTest extends TestCase
|
||||
$token
|
||||
->expects($this->once())
|
||||
->method('getUser')
|
||||
->will($this->returnValue($user));
|
||||
->willReturn($user);
|
||||
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->will($this->returnValue($token));
|
||||
->willReturn($token);
|
||||
|
||||
$this->assertSame($expectedUser, $this->globals->getUser());
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class TemplateLocatorTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->with($template->getPath())
|
||||
->will($this->returnValue('/path/to/template'))
|
||||
->willReturn('/path/to/template')
|
||||
;
|
||||
|
||||
$locator = new TemplateLocator($fileLocator);
|
||||
|
@ -26,13 +26,13 @@ class TemplateNameParserTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
->will($this->returnCallback(function ($bundle) {
|
||||
->willReturnCallback(function ($bundle) {
|
||||
if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException();
|
||||
}))
|
||||
})
|
||||
;
|
||||
$this->parser = new TemplateNameParser($kernel);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class TimedPhpEngineTest extends TestCase
|
||||
$stopwatch->expects($this->once())
|
||||
->method('start')
|
||||
->with('template.php (index.php)', 'template')
|
||||
->will($this->returnValue($stopwatchEvent));
|
||||
->willReturn($stopwatchEvent);
|
||||
|
||||
$stopwatchEvent->expects($this->once())->method('stop');
|
||||
|
||||
@ -56,7 +56,7 @@ class TimedPhpEngineTest extends TestCase
|
||||
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
|
||||
$templateNameParser->expects($this->any())
|
||||
->method('parse')
|
||||
->will($this->returnValue($templateReference));
|
||||
->willReturn($templateReference);
|
||||
|
||||
return $templateNameParser;
|
||||
}
|
||||
@ -91,7 +91,7 @@ class TimedPhpEngineTest extends TestCase
|
||||
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
|
||||
$loader->expects($this->once())
|
||||
->method('load')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class TranslatorTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with('kernel.default_locale')
|
||||
->will($this->returnValue('en'))
|
||||
->willReturn('en')
|
||||
;
|
||||
$translator = new Translator($container, new MessageFormatter());
|
||||
|
||||
@ -357,53 +357,53 @@ class TranslatorTest extends TestCase
|
||||
$loader
|
||||
->expects($this->at(0))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('fr', [
|
||||
->willReturn($this->getCatalogue('fr', [
|
||||
'foo' => 'foo (FR)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(1))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('en', [
|
||||
->willReturn($this->getCatalogue('en', [
|
||||
'foo' => 'foo (EN)',
|
||||
'bar' => 'bar (EN)',
|
||||
'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(2))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('es', [
|
||||
->willReturn($this->getCatalogue('es', [
|
||||
'foobar' => 'foobar (ES)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(3))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('pt-PT', [
|
||||
->willReturn($this->getCatalogue('pt-PT', [
|
||||
'foobarfoo' => 'foobarfoo (PT-PT)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(4))
|
||||
->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)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(5))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('fr.UTF-8', [
|
||||
->willReturn($this->getCatalogue('fr.UTF-8', [
|
||||
'foobarbaz' => 'foobarbaz (fr.UTF-8)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
$loader
|
||||
->expects($this->at(6))
|
||||
->method('load')
|
||||
->will($this->returnValue($this->getCatalogue('sr@latin', [
|
||||
->willReturn($this->getCatalogue('sr@latin', [
|
||||
'foobarbax' => 'foobarbax (sr@latin)',
|
||||
])))
|
||||
]))
|
||||
;
|
||||
|
||||
return $loader;
|
||||
@ -415,7 +415,7 @@ class TranslatorTest extends TestCase
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($loader))
|
||||
->willReturn($loader)
|
||||
;
|
||||
|
||||
return $container;
|
||||
|
@ -68,7 +68,7 @@ class ConstraintValidatorFactoryTest extends TestCase
|
||||
$constraint
|
||||
->expects($this->exactly(2))
|
||||
->method('validatedBy')
|
||||
->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name'));
|
||||
->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name');
|
||||
|
||||
$factory = new ConstraintValidatorFactory(new Container());
|
||||
$factory->getInstance($constraint);
|
||||
|
@ -132,17 +132,17 @@ class AbstractFactoryTest extends TestCase
|
||||
$factory
|
||||
->expects($this->once())
|
||||
->method('createAuthProvider')
|
||||
->will($this->returnValue('auth_provider'))
|
||||
->willReturn('auth_provider')
|
||||
;
|
||||
$factory
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getListenerId')
|
||||
->will($this->returnValue('abstract_listener'))
|
||||
->willReturn('abstract_listener')
|
||||
;
|
||||
$factory
|
||||
->expects($this->any())
|
||||
->method('getKey')
|
||||
->will($this->returnValue('abstract_factory'))
|
||||
->willReturn('abstract_factory')
|
||||
;
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -44,7 +44,7 @@ class PreviewErrorControllerTest extends TestCase
|
||||
}),
|
||||
$this->equalTo(HttpKernelInterface::SUB_REQUEST)
|
||||
)
|
||||
->will($this->returnValue($response));
|
||||
->willReturn($response);
|
||||
|
||||
$controller = new PreviewErrorController($kernel, $logicalControllerName);
|
||||
|
||||
|
@ -24,7 +24,7 @@ class FilesystemLoaderTest extends TestCase
|
||||
$locator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig'))
|
||||
->willReturn(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')
|
||||
;
|
||||
$loader = new FilesystemLoader($locator, $parser);
|
||||
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace');
|
||||
@ -44,7 +44,7 @@ class FilesystemLoaderTest extends TestCase
|
||||
$locator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig'))
|
||||
->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')
|
||||
;
|
||||
$loader = new FilesystemLoader($locator, $parser);
|
||||
|
||||
@ -61,7 +61,7 @@ class FilesystemLoaderTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('parse')
|
||||
->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();
|
||||
@ -85,14 +85,14 @@ class FilesystemLoaderTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('parse')
|
||||
->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
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false)
|
||||
;
|
||||
|
||||
$loader = new FilesystemLoader($locator, $parser);
|
||||
|
@ -18,13 +18,13 @@ class TemplateIteratorTest extends TestCase
|
||||
public function testGetIterator()
|
||||
{
|
||||
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
|
||||
$bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle'));
|
||||
$bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle'));
|
||||
$bundle->expects($this->any())->method('getName')->willReturn('BarBundle');
|
||||
$bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle');
|
||||
|
||||
$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,
|
||||
]));
|
||||
]);
|
||||
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates');
|
||||
|
||||
$sorted = iterator_to_array($iterator);
|
||||
|
@ -97,11 +97,11 @@ class ProfilerControllerTest extends TestCase
|
||||
$profiler
|
||||
->expects($this->exactly(2))
|
||||
->method('loadProfile')
|
||||
->will($this->returnCallback(function ($token) {
|
||||
->willReturnCallback(function ($token) {
|
||||
if ('found' == $token) {
|
||||
return new Profile($token);
|
||||
}
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$controller = $this->createController($profiler, $twig, $withCsp);
|
||||
@ -149,7 +149,7 @@ class ProfilerControllerTest extends TestCase
|
||||
$profiler
|
||||
->expects($this->once())
|
||||
->method('find')
|
||||
->will($this->returnValue($tokens));
|
||||
->willReturn($tokens);
|
||||
|
||||
$request = Request::create('/_profiler/empty/search/results', 'GET', [
|
||||
'limit' => 2,
|
||||
|
@ -200,7 +200,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
|
||||
|
||||
$generator->expects($this->any())
|
||||
->method('generate')
|
||||
->will($this->returnValue($value));
|
||||
->willReturn($value);
|
||||
|
||||
return $generator;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('generate')
|
||||
->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL)
|
||||
->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx'))
|
||||
->willReturn('http://mydomain.com/_profiler/xxxxxxxx')
|
||||
;
|
||||
|
||||
$event = new FilterResponseEvent($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->expects($this->any())
|
||||
->method('isXmlHttpRequest')
|
||||
->will($this->returnValue($isXmlHttpRequest));
|
||||
->willReturn($isXmlHttpRequest);
|
||||
$request->expects($this->any())
|
||||
->method('getRequestFormat')
|
||||
->will($this->returnValue($requestFormat));
|
||||
->willReturn($requestFormat);
|
||||
|
||||
$request->headers = new HeaderBag();
|
||||
|
||||
@ -313,7 +313,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
|
||||
$request->expects($this->any())
|
||||
->method('getSession')
|
||||
->will($this->returnValue($session));
|
||||
->willReturn($session);
|
||||
}
|
||||
|
||||
return $request;
|
||||
@ -324,7 +324,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
$templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
|
||||
$templating->expects($this->any())
|
||||
->method('render')
|
||||
->will($this->returnValue($render));
|
||||
->willReturn($render);
|
||||
|
||||
return $templating;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class TemplateManagerTest extends TestCase
|
||||
$this->profiler->expects($this->any())
|
||||
->method('has')
|
||||
->withAnyParameters()
|
||||
->will($this->returnCallback([$this, 'profilerHasCallback']));
|
||||
->willReturnCallback([$this, 'profilerHasCallback']);
|
||||
|
||||
$this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo'));
|
||||
}
|
||||
@ -83,7 +83,7 @@ class TemplateManagerTest extends TestCase
|
||||
$this->profiler->expects($this->any())
|
||||
->method('has')
|
||||
->withAnyParameters()
|
||||
->will($this->returnCallback([$this, 'profileHasCollectorCallback']));
|
||||
->willReturnCallback([$this, 'profileHasCollectorCallback']);
|
||||
|
||||
$result = $this->templateManager->getTemplates(new ProfileDummy());
|
||||
$this->assertArrayHasKey('foo', $result);
|
||||
@ -124,14 +124,14 @@ class TemplateManagerTest extends TestCase
|
||||
|
||||
$this->twigEnvironment->expects($this->any())
|
||||
->method('loadTemplate')
|
||||
->will($this->returnValue('loadedTemplate'));
|
||||
->willReturn('loadedTemplate');
|
||||
|
||||
if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) {
|
||||
$loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock();
|
||||
} else {
|
||||
$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;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class PathPackageTest extends TestCase
|
||||
private function getContext($basePath)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class UrlPackageTest extends TestCase
|
||||
private function getContext($secure)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ChainAdapterTest extends AdapterTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
@ -97,7 +97,7 @@ class ChainAdapterTest extends AdapterTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class TagAwareAdapterTest extends AdapterTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
@ -190,7 +190,7 @@ class TagAwareAdapterTest extends AdapterTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class ChainCacheTest extends CacheTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
@ -95,7 +95,7 @@ class ChainCacheTest extends CacheTestCase
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ class DelegatingLoaderTest extends TestCase
|
||||
public function testSupports()
|
||||
{
|
||||
$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]));
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$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]));
|
||||
$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()
|
||||
{
|
||||
$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');
|
||||
$resolver = new LoaderResolver([$loader]);
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
@ -62,7 +62,7 @@ class DelegatingLoaderTest extends TestCase
|
||||
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
|
||||
{
|
||||
$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]);
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
|
@ -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');
|
||||
|
||||
$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]);
|
||||
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class LoaderTest extends TestCase
|
||||
$resolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with('foo.xml')
|
||||
->will($this->returnValue($resolvedLoader));
|
||||
->willReturn($resolvedLoader);
|
||||
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
@ -52,7 +52,7 @@ class LoaderTest extends TestCase
|
||||
$resolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with('FOOBAR')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
@ -66,13 +66,13 @@ class LoaderTest extends TestCase
|
||||
$resolvedLoader->expects($this->once())
|
||||
->method('load')
|
||||
->with('foo')
|
||||
->will($this->returnValue('yes'));
|
||||
->willReturn('yes');
|
||||
|
||||
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
|
||||
$resolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with('foo')
|
||||
->will($this->returnValue($resolvedLoader));
|
||||
->willReturn($resolvedLoader);
|
||||
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
@ -86,13 +86,13 @@ class LoaderTest extends TestCase
|
||||
$resolvedLoader->expects($this->once())
|
||||
->method('load')
|
||||
->with('foo', 'bar')
|
||||
->will($this->returnValue('yes'));
|
||||
->willReturn('yes');
|
||||
|
||||
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
|
||||
$resolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with('foo', 'bar')
|
||||
->will($this->returnValue($resolvedLoader));
|
||||
->willReturn($resolvedLoader);
|
||||
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
|
@ -660,7 +660,7 @@ class ApplicationTest extends TestCase
|
||||
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock();
|
||||
$application->expects($this->once())
|
||||
->method('getNamespaces')
|
||||
->will($this->returnValue(['foo:sublong', 'bar:sub']));
|
||||
->willReturn(['foo:sublong', 'bar:sub']);
|
||||
|
||||
$this->assertEquals('foo:sublong', $application->findNamespace('f:sub'));
|
||||
}
|
||||
@ -804,7 +804,7 @@ class ApplicationTest extends TestCase
|
||||
$application->setAutoExit(false);
|
||||
$application->expects($this->any())
|
||||
->method('getTerminalWidth')
|
||||
->will($this->returnValue(120));
|
||||
->willReturn(120);
|
||||
$application->register('foo')->setCode(function () {
|
||||
throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n");
|
||||
});
|
||||
|
@ -321,7 +321,7 @@ class CommandTest extends TestCase
|
||||
$command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock();
|
||||
$command->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue('2.3'));
|
||||
->willReturn('2.3');
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ abstract class AbstractQuestionHelperTest extends TestCase
|
||||
$mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock();
|
||||
$mock->expects($this->any())
|
||||
->method('isInteractive')
|
||||
->will($this->returnValue($interactive));
|
||||
->willReturn($interactive);
|
||||
|
||||
if ($stream) {
|
||||
$mock->expects($this->any())
|
||||
|
@ -114,7 +114,7 @@ class HelperSetTest extends TestCase
|
||||
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
|
||||
$mock_helper->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue($name));
|
||||
->willReturn($name);
|
||||
|
||||
if ($helperset) {
|
||||
$mock_helper->expects($this->any())
|
||||
|
@ -1068,7 +1068,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
|
||||
$mock->expects($this->any())
|
||||
->method('isInteractive')
|
||||
->will($this->returnValue($interactive));
|
||||
->willReturn($interactive);
|
||||
|
||||
return $mock;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
|
||||
$mock->expects($this->any())
|
||||
->method('isInteractive')
|
||||
->will($this->returnValue($interactive));
|
||||
->willReturn($interactive);
|
||||
|
||||
return $mock;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class ConsoleLoggerTest extends TestCase
|
||||
} else {
|
||||
$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);
|
||||
|
||||
|
@ -234,7 +234,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->will($this->returnCallback($warnArgCheck))
|
||||
->willReturnCallback($warnArgCheck)
|
||||
;
|
||||
|
||||
$handler = ErrorHandler::register();
|
||||
@ -262,7 +262,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->will($this->returnCallback($logArgCheck))
|
||||
->willReturnCallback($logArgCheck)
|
||||
;
|
||||
|
||||
$handler = ErrorHandler::register();
|
||||
@ -318,7 +318,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->will($this->returnCallback($logArgCheck))
|
||||
->willReturnCallback($logArgCheck)
|
||||
;
|
||||
|
||||
$handler = new ErrorHandler();
|
||||
@ -349,7 +349,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$logger
|
||||
->expects($this->exactly(2))
|
||||
->method('log')
|
||||
->will($this->returnCallback($logArgCheck))
|
||||
->willReturnCallback($logArgCheck)
|
||||
;
|
||||
|
||||
$handler->setDefaultLogger($logger, E_ERROR);
|
||||
@ -503,7 +503,7 @@ class ErrorHandlerTest extends TestCase
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->will($this->returnCallback($logArgCheck))
|
||||
->willReturnCallback($logArgCheck)
|
||||
;
|
||||
|
||||
$handler->setDefaultLogger($logger, E_PARSE);
|
||||
|
@ -31,13 +31,13 @@ class AutowireExceptionPassTest extends TestCase
|
||||
$autowireException = new AutowiringFailedException('foo_service_id', 'An autowiring exception message');
|
||||
$autowirePass->expects($this->any())
|
||||
->method('getAutowiringExceptions')
|
||||
->will($this->returnValue([$autowireException]));
|
||||
->willReturn([$autowireException]);
|
||||
|
||||
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
|
||||
->getMock();
|
||||
$inlinePass->expects($this->any())
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo_service_id');
|
||||
@ -60,18 +60,18 @@ class AutowireExceptionPassTest extends TestCase
|
||||
$autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message');
|
||||
$autowirePass->expects($this->any())
|
||||
->method('getAutowiringExceptions')
|
||||
->will($this->returnValue([$autowireException]));
|
||||
->willReturn([$autowireException]);
|
||||
|
||||
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
|
||||
->getMock();
|
||||
$inlinePass->expects($this->any())
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
// a_service inlined into b_service
|
||||
'a_service' => ['b_service'],
|
||||
// b_service inlined into c_service
|
||||
'b_service' => ['c_service'],
|
||||
]));
|
||||
]);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
// ONLY register c_service in the final container
|
||||
@ -95,18 +95,18 @@ class AutowireExceptionPassTest extends TestCase
|
||||
$autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message');
|
||||
$autowirePass->expects($this->any())
|
||||
->method('getAutowiringExceptions')
|
||||
->will($this->returnValue([$autowireException]));
|
||||
->willReturn([$autowireException]);
|
||||
|
||||
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
|
||||
->getMock();
|
||||
$inlinePass->expects($this->any())
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
// a_service inlined into b_service
|
||||
'a_service' => ['b_service'],
|
||||
// b_service inlined into c_service
|
||||
'b_service' => ['c_service'],
|
||||
]));
|
||||
]);
|
||||
|
||||
// do NOT register c_service in the container
|
||||
$container = new ContainerBuilder();
|
||||
@ -126,13 +126,13 @@ class AutowireExceptionPassTest extends TestCase
|
||||
$autowireException = new AutowiringFailedException('non_existent_service');
|
||||
$autowirePass->expects($this->any())
|
||||
->method('getAutowiringExceptions')
|
||||
->will($this->returnValue([$autowireException]));
|
||||
->willReturn([$autowireException]);
|
||||
|
||||
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
|
||||
->getMock();
|
||||
$inlinePass->expects($this->any())
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
|
@ -30,18 +30,18 @@ class MergeExtensionConfigurationPassTest extends TestCase
|
||||
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
|
||||
$extension->expects($this->any())
|
||||
->method('getXsdValidationBasePath')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
$extension->expects($this->any())
|
||||
->method('getNamespace')
|
||||
->will($this->returnValue('http://example.org/schema/dic/foo'));
|
||||
->willReturn('http://example.org/schema/dic/foo');
|
||||
$extension->expects($this->any())
|
||||
->method('getAlias')
|
||||
->will($this->returnValue('foo'));
|
||||
->willReturn('foo');
|
||||
$extension->expects($this->once())
|
||||
->method('load')
|
||||
->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
|
||||
->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
|
||||
$tmpProviders = $container->getExpressionLanguageProviders();
|
||||
}));
|
||||
});
|
||||
|
||||
$provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
|
||||
$container = new ContainerBuilder(new ParameterBag());
|
||||
@ -76,7 +76,7 @@ class MergeExtensionConfigurationPassTest extends TestCase
|
||||
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock();
|
||||
$extension->expects($this->exactly(2))
|
||||
->method('getConfiguration')
|
||||
->will($this->returnValue(new FooConfiguration()));
|
||||
->willReturn(new FooConfiguration());
|
||||
|
||||
$container = new ContainerBuilder(new ParameterBag());
|
||||
$container->registerExtension($extension);
|
||||
|
@ -67,10 +67,10 @@ class ContainerParametersResourceCheckerTest extends TestCase
|
||||
[$this->equalTo('locales')],
|
||||
[$this->equalTo('default_locale')]
|
||||
)
|
||||
->will($this->returnValueMap([
|
||||
->willReturnMap([
|
||||
['locales', ['fr', 'en']],
|
||||
['default_locale', 'fr'],
|
||||
]))
|
||||
])
|
||||
;
|
||||
}, true];
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ class ContainerBuilderTest extends TestCase
|
||||
public function testRegisteredButNotLoadedExtension()
|
||||
{
|
||||
$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');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
@ -1071,7 +1071,7 @@ class ContainerBuilderTest extends TestCase
|
||||
public function testRegisteredAndLoadedExtension()
|
||||
{
|
||||
$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']]);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -862,13 +862,13 @@ class FormTest extends TestCase
|
||||
$field
|
||||
->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue($name))
|
||||
->willReturn($name)
|
||||
;
|
||||
|
||||
$field
|
||||
->expects($this->any())
|
||||
->method('getValue')
|
||||
->will($this->returnValue($value))
|
||||
->willReturn($value)
|
||||
;
|
||||
|
||||
return $field;
|
||||
|
@ -43,7 +43,7 @@ class ImmutableEventDispatcherTest extends TestCase
|
||||
$this->innerDispatcher->expects($this->once())
|
||||
->method('dispatch')
|
||||
->with('event', $event)
|
||||
->will($this->returnValue('result'));
|
||||
->willReturn('result');
|
||||
|
||||
$this->assertSame('result', $this->dispatcher->dispatch('event', $event));
|
||||
}
|
||||
@ -53,7 +53,7 @@ class ImmutableEventDispatcherTest extends TestCase
|
||||
$this->innerDispatcher->expects($this->once())
|
||||
->method('getListeners')
|
||||
->with('event')
|
||||
->will($this->returnValue('result'));
|
||||
->willReturn('result');
|
||||
|
||||
$this->assertSame('result', $this->dispatcher->getListeners('event'));
|
||||
}
|
||||
@ -63,7 +63,7 @@ class ImmutableEventDispatcherTest extends TestCase
|
||||
$this->innerDispatcher->expects($this->once())
|
||||
->method('hasListeners')
|
||||
->with('event')
|
||||
->will($this->returnValue('result'));
|
||||
->willReturn('result');
|
||||
|
||||
$this->assertSame('result', $this->dispatcher->hasListeners('event'));
|
||||
}
|
||||
|
@ -36,18 +36,18 @@ class ExpressionLanguageTest extends TestCase
|
||||
$cacheItemMock
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->will($this->returnCallback(function () use (&$savedParsedExpression) {
|
||||
->willReturnCallback(function () use (&$savedParsedExpression) {
|
||||
return $savedParsedExpression;
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$cacheItemMock
|
||||
->expects($this->exactly(1))
|
||||
->method('set')
|
||||
->with($this->isInstanceOf(ParsedExpression::class))
|
||||
->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
|
||||
->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
|
||||
$savedParsedExpression = $parsedExpression;
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$cacheMock
|
||||
@ -85,9 +85,9 @@ class ExpressionLanguageTest extends TestCase
|
||||
->expects($this->exactly(1))
|
||||
->method('save')
|
||||
->with('1%20%2B%201%2F%2F', $this->isInstanceOf(ParsedExpression::class))
|
||||
->will($this->returnCallback(function ($key, $expression) use (&$savedParsedExpression) {
|
||||
->willReturnCallback(function ($key, $expression) use (&$savedParsedExpression) {
|
||||
$savedParsedExpression = $expression;
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$parsedExpression = $expressionLanguage->parse('1 + 1', []);
|
||||
@ -213,18 +213,18 @@ class ExpressionLanguageTest extends TestCase
|
||||
$cacheItemMock
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->will($this->returnCallback(function () use (&$savedParsedExpression) {
|
||||
->willReturnCallback(function () use (&$savedParsedExpression) {
|
||||
return $savedParsedExpression;
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$cacheItemMock
|
||||
->expects($this->exactly(1))
|
||||
->method('set')
|
||||
->with($this->isInstanceOf(ParsedExpression::class))
|
||||
->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
|
||||
->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) {
|
||||
$savedParsedExpression = $parsedExpression;
|
||||
}))
|
||||
})
|
||||
;
|
||||
|
||||
$cacheMock
|
||||
|
@ -26,9 +26,9 @@ class FilterIteratorTest extends RealIteratorTestCase
|
||||
$i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', [$i]);
|
||||
$i->expects($this->any())
|
||||
->method('accept')
|
||||
->will($this->returnCallback(function () use ($i) {
|
||||
->willReturnCallback(function () use ($i) {
|
||||
return (bool) preg_match('/\.php/', (string) $i->current());
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
$c = 0;
|
||||
|
@ -473,7 +473,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
{
|
||||
$this->csrfTokenManager->expects($this->any())
|
||||
->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')
|
||||
->add($this->factory
|
||||
|
@ -312,10 +312,10 @@ abstract class AbstractRequestHandlerTest extends TestCase
|
||||
{
|
||||
$this->serverParams->expects($this->once())
|
||||
->method('getContentLength')
|
||||
->will($this->returnValue($contentLength));
|
||||
->willReturn($contentLength);
|
||||
$this->serverParams->expects($this->any())
|
||||
->method('getNormalizedIniPostMaxSize')
|
||||
->will($this->returnValue($iniMax));
|
||||
->willReturn($iniMax);
|
||||
|
||||
$options = ['post_max_size_message' => 'Max {{ max }}!'];
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);
|
||||
|
@ -339,7 +339,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
{
|
||||
$this->csrfTokenManager->expects($this->any())
|
||||
->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')
|
||||
->add($this->factory
|
||||
|
@ -42,7 +42,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with([])
|
||||
->will($this->returnValue($list));
|
||||
->willReturn($list);
|
||||
|
||||
$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())
|
||||
->method('createListFromChoices')
|
||||
->with($choices2)
|
||||
->will($this->returnValue($list));
|
||||
->willReturn($list);
|
||||
|
||||
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
|
||||
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
|
||||
@ -74,11 +74,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createListFromChoices')
|
||||
->with($choices1)
|
||||
->will($this->returnValue($list1));
|
||||
->willReturn($list1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createListFromChoices')
|
||||
->with($choices2)
|
||||
->will($this->returnValue($list2));
|
||||
->willReturn($list2);
|
||||
|
||||
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
|
||||
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
|
||||
@ -96,7 +96,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices1)
|
||||
->will($this->returnValue($list));
|
||||
->willReturn($list);
|
||||
|
||||
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
|
||||
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
|
||||
@ -115,11 +115,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createListFromChoices')
|
||||
->with($choices1)
|
||||
->will($this->returnValue($list1));
|
||||
->willReturn($list1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createListFromChoices')
|
||||
->with($choices2)
|
||||
->will($this->returnValue($list2));
|
||||
->willReturn($list2);
|
||||
|
||||
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
|
||||
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
|
||||
@ -134,7 +134,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->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));
|
||||
@ -151,11 +151,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $closure1)
|
||||
->will($this->returnValue($list1));
|
||||
->willReturn($list1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $closure2)
|
||||
->will($this->returnValue($list2));
|
||||
->willReturn($list2);
|
||||
|
||||
$this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1));
|
||||
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
|
||||
@ -169,7 +169,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader)
|
||||
->will($this->returnValue($list));
|
||||
->willReturn($list);
|
||||
|
||||
$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))
|
||||
->method('createListFromLoader')
|
||||
->with($loader1)
|
||||
->will($this->returnValue($list1));
|
||||
->willReturn($list1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createListFromLoader')
|
||||
->with($loader2)
|
||||
->will($this->returnValue($list2));
|
||||
->willReturn($list2);
|
||||
|
||||
$this->assertSame($list1, $this->factory->createListFromLoader($loader1));
|
||||
$this->assertSame($list2, $this->factory->createListFromLoader($loader2));
|
||||
@ -204,7 +204,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->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));
|
||||
@ -221,11 +221,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $closure1)
|
||||
->will($this->returnValue($list1));
|
||||
->willReturn($list1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $closure2)
|
||||
->will($this->returnValue($list2));
|
||||
->willReturn($list2);
|
||||
|
||||
$this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1));
|
||||
$this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2));
|
||||
@ -240,7 +240,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -257,11 +257,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, $preferred1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->with($list, $preferred2)
|
||||
->will($this->returnValue($view2));
|
||||
->willReturn($view2);
|
||||
|
||||
$this->assertSame($view1, $this->factory->createView($list, $preferred1));
|
||||
$this->assertSame($view2, $this->factory->createView($list, $preferred2));
|
||||
@ -276,7 +276,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -293,11 +293,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, $preferred1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->with($list, $preferred2)
|
||||
->will($this->returnValue($view2));
|
||||
->willReturn($view2);
|
||||
|
||||
$this->assertSame($view1, $this->factory->createView($list, $preferred1));
|
||||
$this->assertSame($view2, $this->factory->createView($list, $preferred2));
|
||||
@ -312,7 +312,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -329,11 +329,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, null, $labels1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->with($list, null, $labels2)
|
||||
->will($this->returnValue($view2));
|
||||
->willReturn($view2);
|
||||
|
||||
$this->assertSame($view1, $this->factory->createView($list, null, $labels1));
|
||||
$this->assertSame($view2, $this->factory->createView($list, null, $labels2));
|
||||
@ -348,7 +348,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -365,11 +365,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, null, null, $index1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->with($list, null, null, $index2)
|
||||
->will($this->returnValue($view2));
|
||||
->willReturn($view2);
|
||||
|
||||
$this->assertSame($view1, $this->factory->createView($list, null, null, $index1));
|
||||
$this->assertSame($view2, $this->factory->createView($list, null, null, $index2));
|
||||
@ -384,7 +384,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -401,11 +401,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, null, null, null, $groupBy1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->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($view2, $this->factory->createView($list, null, null, null, $groupBy2));
|
||||
@ -420,7 +420,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -437,11 +437,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, null, null, null, null, $attr1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->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($view2, $this->factory->createView($list, null, null, null, null, $attr2));
|
||||
@ -456,7 +456,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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));
|
||||
@ -473,11 +473,11 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->at(0))
|
||||
->method('createView')
|
||||
->with($list, null, null, null, null, $attr1)
|
||||
->will($this->returnValue($view1));
|
||||
->willReturn($view1);
|
||||
$this->decoratedFactory->expects($this->at(1))
|
||||
->method('createView')
|
||||
->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($view2, $this->factory->createView($list, null, null, null, null, $attr2));
|
||||
|
@ -43,9 +43,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($choices, $callback) {
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return array_map($callback, $choices);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property'));
|
||||
}
|
||||
@ -57,9 +57,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($choices, $callback) {
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return array_map($callback, $choices);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property')));
|
||||
}
|
||||
@ -86,9 +86,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($loader, $callback) {
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return $callback((object) ['property' => 'value']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('value', $this->factory->createListFromLoader($loader, 'property'));
|
||||
}
|
||||
@ -116,9 +116,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($choices, $callback) {
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return array_map($callback, $choices);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame([null], $this->factory->createListFromChoices($choices, 'property'));
|
||||
}
|
||||
@ -131,9 +131,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($loader, $callback) {
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return $callback(null);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertNull($this->factory->createListFromLoader($loader, 'property'));
|
||||
}
|
||||
@ -145,9 +145,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($loader, $callback) {
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return $callback((object) ['property' => 'value']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property')));
|
||||
}
|
||||
@ -159,9 +159,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($list, $preferred) {
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return $preferred((object) ['property' => true]);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertTrue($this->factory->createView(
|
||||
$list,
|
||||
@ -194,9 +194,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($list, $preferred) {
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return $preferred((object) ['property' => true]);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertTrue($this->factory->createView(
|
||||
$list,
|
||||
@ -212,9 +212,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($list, $preferred) {
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return $preferred((object) ['category' => null]);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertFalse($this->factory->createView(
|
||||
$list,
|
||||
@ -229,9 +229,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($list, $preferred, $label) {
|
||||
->willReturnCallback(function ($list, $preferred, $label) {
|
||||
return $label((object) ['property' => 'label']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('label', $this->factory->createView(
|
||||
$list,
|
||||
@ -266,9 +266,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||
->will($this->returnCallback(function ($list, $preferred, $label) {
|
||||
->willReturnCallback(function ($list, $preferred, $label) {
|
||||
return $label((object) ['property' => 'label']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('label', $this->factory->createView(
|
||||
$list,
|
||||
@ -284,9 +284,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('index', $this->factory->createView(
|
||||
$list,
|
||||
@ -323,9 +323,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('index', $this->factory->createView(
|
||||
$list,
|
||||
@ -342,9 +342,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('group', $this->factory->createView(
|
||||
$list,
|
||||
@ -383,9 +383,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('group', $this->factory->createView(
|
||||
$list,
|
||||
@ -404,9 +404,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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]);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertNull($this->factory->createView(
|
||||
$list,
|
||||
@ -424,9 +424,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('attr', $this->factory->createView(
|
||||
$list,
|
||||
@ -467,9 +467,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->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']);
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertSame('attr', $this->factory->createView(
|
||||
$list,
|
||||
|
@ -50,12 +50,12 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadChoiceList')
|
||||
->with($this->value)
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
// The same list is returned by the loader
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getChoices')
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getChoices());
|
||||
$this->assertSame('RESULT', $this->list->getChoices());
|
||||
@ -79,7 +79,7 @@ class LazyChoiceListTest extends TestCase
|
||||
// The same list is returned by the lazy choice list
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getChoices')
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getChoices());
|
||||
$this->assertSame('RESULT', $this->list->getChoices());
|
||||
@ -90,12 +90,12 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadChoiceList')
|
||||
->with($this->value)
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
// The same list is returned by the loader
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getValues')
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getValues());
|
||||
$this->assertSame('RESULT', $this->list->getValues());
|
||||
@ -106,12 +106,12 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadChoiceList')
|
||||
->with($this->value)
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
// The same list is returned by the loader
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getStructuredValues')
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getStructuredValues());
|
||||
$this->assertSame('RESULT', $this->list->getStructuredValues());
|
||||
@ -122,12 +122,12 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadChoiceList')
|
||||
->with($this->value)
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
// The same list is returned by the loader
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getOriginalKeys')
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getOriginalKeys());
|
||||
$this->assertSame('RESULT', $this->list->getOriginalKeys());
|
||||
@ -138,7 +138,7 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadChoicesForValues')
|
||||
->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']));
|
||||
@ -151,7 +151,7 @@ class LazyChoiceListTest extends TestCase
|
||||
->with($this->value)
|
||||
// For BC, the same choice loaded list is returned 3 times
|
||||
// It should only twice in 4.0
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
$this->loader->expects($this->never())
|
||||
->method('loadChoicesForValues');
|
||||
@ -159,7 +159,7 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getChoicesForValues')
|
||||
->with(['a', 'b'])
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
// load choice list
|
||||
$this->list->getChoices();
|
||||
@ -176,7 +176,7 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loader->expects($this->exactly(2))
|
||||
->method('loadValuesForChoices')
|
||||
->with(['a', 'b'])
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
$this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b']));
|
||||
$this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b']));
|
||||
@ -189,7 +189,7 @@ class LazyChoiceListTest extends TestCase
|
||||
->with($this->value)
|
||||
// For BC, the same choice loaded list is returned 3 times
|
||||
// It should only twice in 4.0
|
||||
->will($this->returnValue($this->loadedList));
|
||||
->willReturn($this->loadedList);
|
||||
|
||||
$this->loader->expects($this->never())
|
||||
->method('loadValuesForChoices');
|
||||
@ -197,7 +197,7 @@ class LazyChoiceListTest extends TestCase
|
||||
$this->loadedList->expects($this->exactly(2))
|
||||
->method('getValuesForChoices')
|
||||
->with(['a', 'b'])
|
||||
->will($this->returnValue('RESULT'));
|
||||
->willReturn('RESULT');
|
||||
|
||||
// load choice list
|
||||
$this->list->getChoices();
|
||||
|
@ -179,7 +179,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
'bar' => 'baz',
|
||||
'auto_initialize' => false,
|
||||
])
|
||||
->will($this->returnValue($child));
|
||||
->willReturn($child);
|
||||
|
||||
$this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']);
|
||||
|
||||
@ -198,7 +198,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
'bar' => 'baz',
|
||||
'auto_initialize' => false,
|
||||
])
|
||||
->will($this->returnValue($child));
|
||||
->willReturn($child);
|
||||
|
||||
// in order to make casting unnecessary
|
||||
$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())
|
||||
->method('createNamed')
|
||||
->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||
->will($this->returnValue($child));
|
||||
->willReturn($child);
|
||||
|
||||
$this->form->add('foo');
|
||||
|
||||
@ -236,7 +236,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$this->factory->expects($this->once())
|
||||
->method('createForProperty')
|
||||
->with('\stdClass', 'foo')
|
||||
->will($this->returnValue($child));
|
||||
->willReturn($child);
|
||||
|
||||
$this->form->add('foo');
|
||||
|
||||
@ -260,7 +260,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
'bar' => 'baz',
|
||||
'auto_initialize' => false,
|
||||
])
|
||||
->will($this->returnValue($child));
|
||||
->willReturn($child);
|
||||
|
||||
$this->form->add('foo', null, ['bar' => 'baz']);
|
||||
|
||||
@ -352,10 +352,10 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$mapper->expects($this->once())
|
||||
->method('mapDataToForms')
|
||||
->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->assertSame([$child->getName() => $child], iterator_to_array($iterator));
|
||||
}));
|
||||
});
|
||||
|
||||
$form->initialize();
|
||||
$form->add($child);
|
||||
@ -442,10 +442,10 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$mapper->expects($this->once())
|
||||
->method('mapDataToForms')
|
||||
->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->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
|
||||
}));
|
||||
});
|
||||
|
||||
$form->setData('foo');
|
||||
}
|
||||
@ -517,12 +517,12 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$mapper->expects($this->once())
|
||||
->method('mapFormsToData')
|
||||
->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->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
|
||||
$this->assertEquals('Bernhard', $child1->getData());
|
||||
$this->assertEquals('Schussek', $child2->getData());
|
||||
}));
|
||||
});
|
||||
|
||||
$form->submit([
|
||||
'firstName' => 'Bernhard',
|
||||
@ -589,10 +589,10 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$mapper->expects($this->once())
|
||||
->method('mapFormsToData')
|
||||
->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->assertSame(['name' => $child], iterator_to_array($iterator));
|
||||
}));
|
||||
});
|
||||
|
||||
$form->submit([
|
||||
'name' => 'Bernhard',
|
||||
@ -912,11 +912,11 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$field1View = new FormView();
|
||||
$type1
|
||||
->method('createView')
|
||||
->will($this->returnValue($field1View));
|
||||
->willReturn($field1View);
|
||||
$field2View = new FormView();
|
||||
$type2
|
||||
->method('createView')
|
||||
->will($this->returnValue($field2View));
|
||||
->willReturn($field2View);
|
||||
|
||||
$this->form = $this->getBuilder('form', null, null, $options)
|
||||
->setCompound(true)
|
||||
@ -935,13 +935,13 @@ class CompoundFormTest extends AbstractFormTest
|
||||
// First create the view
|
||||
$type->expects($this->once())
|
||||
->method('createView')
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
// Then build it for the form itself
|
||||
$type->expects($this->once())
|
||||
->method('buildView')
|
||||
->with($view, $this->form, $options)
|
||||
->will($this->returnCallback($assertChildViewsEqual([])));
|
||||
->willReturnCallback($assertChildViewsEqual([]));
|
||||
|
||||
$this->assertSame($view, $this->form->createView());
|
||||
$this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children);
|
||||
@ -961,7 +961,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$button->expects($this->any())
|
||||
->method('isClicked')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$parentForm = $this->getBuilder('parent')->getForm();
|
||||
$nestedForm = $this->getBuilder('nested')->getForm();
|
||||
@ -983,7 +983,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$button->expects($this->any())
|
||||
->method('isClicked')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$this->form->add($button);
|
||||
$this->form->submit([]);
|
||||
@ -1002,7 +1002,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$nestedForm->expects($this->any())
|
||||
->method('getClickedButton')
|
||||
->will($this->returnValue($button));
|
||||
->willReturn($button);
|
||||
|
||||
$this->form->add($nestedForm);
|
||||
$this->form->submit([]);
|
||||
@ -1021,7 +1021,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$parentForm->expects($this->any())
|
||||
->method('getClickedButton')
|
||||
->will($this->returnValue($button));
|
||||
->willReturn($button);
|
||||
|
||||
$this->form->setParent($parentForm);
|
||||
$this->form->submit([]);
|
||||
|
@ -22,12 +22,12 @@ class DataTransformerChainTest extends TestCase
|
||||
$transformer1->expects($this->once())
|
||||
->method('transform')
|
||||
->with($this->identicalTo('foo'))
|
||||
->will($this->returnValue('bar'));
|
||||
->willReturn('bar');
|
||||
$transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
|
||||
$transformer2->expects($this->once())
|
||||
->method('transform')
|
||||
->with($this->identicalTo('bar'))
|
||||
->will($this->returnValue('baz'));
|
||||
->willReturn('baz');
|
||||
|
||||
$chain = new DataTransformerChain([$transformer1, $transformer2]);
|
||||
|
||||
@ -40,12 +40,12 @@ class DataTransformerChainTest extends TestCase
|
||||
$transformer2->expects($this->once())
|
||||
->method('reverseTransform')
|
||||
->with($this->identicalTo('foo'))
|
||||
->will($this->returnValue('bar'));
|
||||
->willReturn('bar');
|
||||
$transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
|
||||
$transformer1->expects($this->once())
|
||||
->method('reverseTransform')
|
||||
->with($this->identicalTo('bar'))
|
||||
->will($this->returnValue('baz'));
|
||||
->willReturn('baz');
|
||||
|
||||
$chain = new DataTransformerChain([$transformer1, $transformer2]);
|
||||
|
||||
|
@ -122,7 +122,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('getToken')
|
||||
->with('TOKEN_ID')
|
||||
->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token')));
|
||||
->willReturn(new CsrfToken('TOKEN_ID', 'token'));
|
||||
|
||||
$view = $this->factory
|
||||
->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -141,7 +141,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('getToken')
|
||||
->with('FORM_NAME')
|
||||
->will($this->returnValue('token'));
|
||||
->willReturn('token');
|
||||
|
||||
$view = $this->factory
|
||||
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -159,7 +159,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('getToken')
|
||||
->with('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||
->will($this->returnValue('token'));
|
||||
->willReturn('token');
|
||||
|
||||
$view = $this->factory
|
||||
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -188,7 +188,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('isTokenValid')
|
||||
->with(new CsrfToken('TOKEN_ID', 'token'))
|
||||
->will($this->returnValue($valid));
|
||||
->willReturn($valid);
|
||||
|
||||
$form = $this->factory
|
||||
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -220,7 +220,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('isTokenValid')
|
||||
->with(new CsrfToken('FORM_NAME', 'token'))
|
||||
->will($this->returnValue($valid));
|
||||
->willReturn($valid);
|
||||
|
||||
$form = $this->factory
|
||||
->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -251,7 +251,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('isTokenValid')
|
||||
->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token'))
|
||||
->will($this->returnValue($valid));
|
||||
->willReturn($valid);
|
||||
|
||||
$form = $this->factory
|
||||
->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
@ -366,12 +366,12 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
||||
$this->tokenManager->expects($this->once())
|
||||
->method('isTokenValid')
|
||||
->with(new CsrfToken('TOKEN_ID', 'token'))
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->translator->expects($this->once())
|
||||
->method('trans')
|
||||
->with('Foobar')
|
||||
->will($this->returnValue('[trans]Foobar[/trans]'));
|
||||
->willReturn('[trans]Foobar[/trans]');
|
||||
|
||||
$form = $this->factory
|
||||
->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
|
@ -84,29 +84,29 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(2))
|
||||
->method('extractDefaultData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['default_data' => 'foo']));
|
||||
->willReturn(['default_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(3))
|
||||
->method('extractDefaultData')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['default_data' => 'bar']));
|
||||
->willReturn(['default_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(4))
|
||||
->method('extractSubmittedData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['submitted_data' => 'foo']));
|
||||
->willReturn(['submitted_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(5))
|
||||
->method('extractSubmittedData')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['submitted_data' => 'bar']));
|
||||
->willReturn(['submitted_data' => 'bar']);
|
||||
|
||||
$this->dataCollector->collectConfiguration($this->form);
|
||||
$this->dataCollector->collectDefaultData($this->form);
|
||||
@ -150,11 +150,11 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($form1)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($form2)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
$this->dataCollector->collectConfiguration($form1);
|
||||
$this->dataCollector->collectConfiguration($form2);
|
||||
@ -200,12 +200,12 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractDefaultData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['default_data' => 'foo']));
|
||||
->willReturn(['default_data' => 'foo']);
|
||||
|
||||
$this->dataCollector->collectConfiguration($this->form);
|
||||
$this->dataCollector->buildPreliminaryFormTree($this->form);
|
||||
@ -272,39 +272,39 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(2))
|
||||
->method('extractDefaultData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['default_data' => 'foo']));
|
||||
->willReturn(['default_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(3))
|
||||
->method('extractDefaultData')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['default_data' => 'bar']));
|
||||
->willReturn(['default_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(4))
|
||||
->method('extractSubmittedData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['submitted_data' => 'foo']));
|
||||
->willReturn(['submitted_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(5))
|
||||
->method('extractSubmittedData')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['submitted_data' => 'bar']));
|
||||
->willReturn(['submitted_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(6))
|
||||
->method('extractViewVariables')
|
||||
->with($this->view)
|
||||
->will($this->returnValue(['view_vars' => 'foo']));
|
||||
->willReturn(['view_vars' => 'foo']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(7))
|
||||
->method('extractViewVariables')
|
||||
->with($this->childView)
|
||||
->will($this->returnValue(['view_vars' => 'bar']));
|
||||
->willReturn(['view_vars' => 'bar']);
|
||||
|
||||
$this->dataCollector->collectConfiguration($this->form);
|
||||
$this->dataCollector->collectDefaultData($this->form);
|
||||
@ -365,76 +365,76 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($form1)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(2))
|
||||
->method('extractDefaultData')
|
||||
->with($form1)
|
||||
->will($this->returnValue(['default_data' => 'foo']));
|
||||
->willReturn(['default_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(3))
|
||||
->method('extractDefaultData')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['default_data' => 'bar']));
|
||||
->willReturn(['default_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(4))
|
||||
->method('extractSubmittedData')
|
||||
->with($form1)
|
||||
->will($this->returnValue(['submitted_data' => 'foo']));
|
||||
->willReturn(['submitted_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(5))
|
||||
->method('extractSubmittedData')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['submitted_data' => 'bar']));
|
||||
->willReturn(['submitted_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(6))
|
||||
->method('extractViewVariables')
|
||||
->with($form1View)
|
||||
->will($this->returnValue(['view_vars' => 'foo']));
|
||||
->willReturn(['view_vars' => 'foo']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(7))
|
||||
->method('extractViewVariables')
|
||||
->with($child1View)
|
||||
->will($this->returnValue(['view_vars' => $child1View->vars]));
|
||||
->willReturn(['view_vars' => $child1View->vars]);
|
||||
|
||||
$this->dataExtractor->expects($this->at(8))
|
||||
->method('extractConfiguration')
|
||||
->with($form2)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(9))
|
||||
->method('extractConfiguration')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(10))
|
||||
->method('extractDefaultData')
|
||||
->with($form2)
|
||||
->will($this->returnValue(['default_data' => 'foo']));
|
||||
->willReturn(['default_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(11))
|
||||
->method('extractDefaultData')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['default_data' => 'bar']));
|
||||
->willReturn(['default_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(12))
|
||||
->method('extractSubmittedData')
|
||||
->with($form2)
|
||||
->will($this->returnValue(['submitted_data' => 'foo']));
|
||||
->willReturn(['submitted_data' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(13))
|
||||
->method('extractSubmittedData')
|
||||
->with($child1)
|
||||
->will($this->returnValue(['submitted_data' => 'bar']));
|
||||
->willReturn(['submitted_data' => 'bar']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(14))
|
||||
->method('extractViewVariables')
|
||||
->with($form2View)
|
||||
->will($this->returnValue(['view_vars' => 'foo']));
|
||||
->willReturn(['view_vars' => 'foo']);
|
||||
|
||||
$this->dataExtractor->expects($this->at(15))
|
||||
->method('extractViewVariables')
|
||||
->with($child1View)
|
||||
->will($this->returnValue(['view_vars' => $child1View->vars]));
|
||||
->willReturn(['view_vars' => $child1View->vars]);
|
||||
|
||||
$this->dataCollector->collectConfiguration($form1);
|
||||
$this->dataCollector->collectDefaultData($form1);
|
||||
@ -518,11 +518,11 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
// explicitly call collectConfiguration(), since $this->childForm is not
|
||||
// contained in the form tree
|
||||
@ -566,11 +566,11 @@ class FormDataCollectorTest extends TestCase
|
||||
$this->dataExtractor->expects($this->at(0))
|
||||
->method('extractConfiguration')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['config' => 'foo']));
|
||||
->willReturn(['config' => 'foo']);
|
||||
$this->dataExtractor->expects($this->at(1))
|
||||
->method('extractConfiguration')
|
||||
->with($this->childForm)
|
||||
->will($this->returnValue(['config' => 'bar']));
|
||||
->willReturn(['config' => 'bar']);
|
||||
|
||||
// explicitly call collectConfiguration(), since $this->childForm is not
|
||||
// contained in the form tree
|
||||
@ -611,22 +611,22 @@ class FormDataCollectorTest extends TestCase
|
||||
$form1->add($childForm1);
|
||||
$this->dataExtractor
|
||||
->method('extractConfiguration')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor
|
||||
->method('extractDefaultData')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor->expects($this->at(4))
|
||||
->method('extractSubmittedData')
|
||||
->with($form1)
|
||||
->will($this->returnValue(['errors' => ['foo']]));
|
||||
->willReturn(['errors' => ['foo']]);
|
||||
$this->dataExtractor->expects($this->at(5))
|
||||
->method('extractSubmittedData')
|
||||
->with($childForm1)
|
||||
->will($this->returnValue(['errors' => ['bar', 'bam']]));
|
||||
->willReturn(['errors' => ['bar', 'bam']]);
|
||||
$this->dataExtractor->expects($this->at(8))
|
||||
->method('extractSubmittedData')
|
||||
->with($form2)
|
||||
->will($this->returnValue(['errors' => ['baz']]));
|
||||
->willReturn(['errors' => ['baz']]);
|
||||
|
||||
$this->dataCollector->collectSubmittedData($form1);
|
||||
|
||||
@ -653,30 +653,30 @@ class FormDataCollectorTest extends TestCase
|
||||
|
||||
$this->dataExtractor
|
||||
->method('extractConfiguration')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor
|
||||
->method('extractDefaultData')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor->expects($this->at(10))
|
||||
->method('extractSubmittedData')
|
||||
->with($this->form)
|
||||
->will($this->returnValue(['errors' => []]));
|
||||
->willReturn(['errors' => []]);
|
||||
$this->dataExtractor->expects($this->at(11))
|
||||
->method('extractSubmittedData')
|
||||
->with($child1Form)
|
||||
->will($this->returnValue(['errors' => []]));
|
||||
->willReturn(['errors' => []]);
|
||||
$this->dataExtractor->expects($this->at(12))
|
||||
->method('extractSubmittedData')
|
||||
->with($child11Form)
|
||||
->will($this->returnValue(['errors' => ['foo']]));
|
||||
->willReturn(['errors' => ['foo']]);
|
||||
$this->dataExtractor->expects($this->at(13))
|
||||
->method('extractSubmittedData')
|
||||
->with($child2Form)
|
||||
->will($this->returnValue(['errors' => []]));
|
||||
->willReturn(['errors' => []]);
|
||||
$this->dataExtractor->expects($this->at(14))
|
||||
->method('extractSubmittedData')
|
||||
->with($child21Form)
|
||||
->will($this->returnValue(['errors' => []]));
|
||||
->willReturn(['errors' => []]);
|
||||
|
||||
$this->dataCollector->collectSubmittedData($this->form);
|
||||
$this->dataCollector->buildPreliminaryFormTree($this->form);
|
||||
@ -701,14 +701,14 @@ class FormDataCollectorTest extends TestCase
|
||||
|
||||
$this->dataExtractor->expects($this->any())
|
||||
->method('extractConfiguration')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor->expects($this->any())
|
||||
->method('extractDefaultData')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->dataExtractor->expects($this->any())
|
||||
->method('extractSubmittedData')
|
||||
->with($form)
|
||||
->will($this->returnValue(['errors' => ['baz']]));
|
||||
->willReturn(['errors' => ['baz']]);
|
||||
|
||||
$this->dataCollector->buildPreliminaryFormTree($form);
|
||||
$this->dataCollector->collectSubmittedData($form);
|
||||
|
@ -56,7 +56,7 @@ class FormDataExtractorTest extends TestCase
|
||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type->expects($this->any())
|
||||
->method('getInnerType')
|
||||
->will($this->returnValue(new \stdClass()));
|
||||
->willReturn(new \stdClass());
|
||||
|
||||
$form = $this->createBuilder('name')
|
||||
->setType($type)
|
||||
@ -77,7 +77,7 @@ class FormDataExtractorTest extends TestCase
|
||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type->expects($this->any())
|
||||
->method('getInnerType')
|
||||
->will($this->returnValue(new \stdClass()));
|
||||
->willReturn(new \stdClass());
|
||||
|
||||
$options = [
|
||||
'b' => 'foo',
|
||||
@ -111,7 +111,7 @@ class FormDataExtractorTest extends TestCase
|
||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type->expects($this->any())
|
||||
->method('getInnerType')
|
||||
->will($this->returnValue(new \stdClass()));
|
||||
->willReturn(new \stdClass());
|
||||
|
||||
$options = [
|
||||
'b' => 'foo',
|
||||
@ -142,7 +142,7 @@ class FormDataExtractorTest extends TestCase
|
||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type->expects($this->any())
|
||||
->method('getInnerType')
|
||||
->will($this->returnValue(new \stdClass()));
|
||||
->willReturn(new \stdClass());
|
||||
|
||||
$grandParent = $this->createBuilder('grandParent')
|
||||
->setCompound(true)
|
||||
|
@ -42,7 +42,7 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
|
||||
$this->validator->expects($this->once())
|
||||
->method('validate')
|
||||
->with($this->equalTo($form))
|
||||
->will($this->returnValue(new ConstraintViolationList()));
|
||||
->willReturn(new ConstraintViolationList());
|
||||
|
||||
// specific data is irrelevant
|
||||
$form->submit([]);
|
||||
|
@ -91,7 +91,7 @@ class FormBuilderTest extends TestCase
|
||||
$this->factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->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->assertFalse($this->builder->has('foo'));
|
||||
@ -186,7 +186,7 @@ class FormBuilderTest extends TestCase
|
||||
$this->factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with($expectedName, $expectedType, null, $expectedOptions)
|
||||
->will($this->returnValue($this->getFormBuilder()));
|
||||
->willReturn($this->getFormBuilder());
|
||||
|
||||
$this->builder->add($expectedName, $expectedType, $expectedOptions);
|
||||
$builder = $this->builder->get($expectedName);
|
||||
@ -202,7 +202,7 @@ class FormBuilderTest extends TestCase
|
||||
$this->factory->expects($this->once())
|
||||
->method('createBuilderForProperty')
|
||||
->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->add($expectedName, null, $expectedOptions);
|
||||
@ -236,7 +236,7 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue($name));
|
||||
->willReturn($name);
|
||||
|
||||
return $mock;
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
$this->registry->expects($this->any())
|
||||
->method('getTypeGuesser')
|
||||
->will($this->returnValue(new FormTypeGuesserChain([
|
||||
->willReturn(new FormTypeGuesserChain([
|
||||
$this->guesser1,
|
||||
$this->guesser2,
|
||||
])));
|
||||
]));
|
||||
}
|
||||
|
||||
public function testCreateNamedBuilderWithTypeName()
|
||||
@ -73,16 +73,16 @@ class FormFactoryTest extends TestCase
|
||||
$this->registry->expects($this->once())
|
||||
->method('getType')
|
||||
->with('type')
|
||||
->will($this->returnValue($resolvedType));
|
||||
->willReturn($resolvedType);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('createBuilder')
|
||||
->with($this->factory, 'name', $options)
|
||||
->will($this->returnValue($this->builder));
|
||||
->willReturn($this->builder);
|
||||
|
||||
$this->builder->expects($this->any())
|
||||
->method('getOptions')
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('buildForm')
|
||||
@ -101,16 +101,16 @@ class FormFactoryTest extends TestCase
|
||||
$this->registry->expects($this->once())
|
||||
->method('getType')
|
||||
->with('type')
|
||||
->will($this->returnValue($resolvedType));
|
||||
->willReturn($resolvedType);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('createBuilder')
|
||||
->with($this->factory, 'name', $expectedOptions)
|
||||
->will($this->returnValue($this->builder));
|
||||
->willReturn($this->builder);
|
||||
|
||||
$this->builder->expects($this->any())
|
||||
->method('getOptions')
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('buildForm')
|
||||
@ -128,16 +128,16 @@ class FormFactoryTest extends TestCase
|
||||
$this->registry->expects($this->once())
|
||||
->method('getType')
|
||||
->with('type')
|
||||
->will($this->returnValue($resolvedType));
|
||||
->willReturn($resolvedType);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('createBuilder')
|
||||
->with($this->factory, 'name', $options)
|
||||
->will($this->returnValue($this->builder));
|
||||
->willReturn($this->builder);
|
||||
|
||||
$this->builder->expects($this->any())
|
||||
->method('getOptions')
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('buildForm')
|
||||
@ -181,16 +181,16 @@ class FormFactoryTest extends TestCase
|
||||
$this->registry->expects($this->any())
|
||||
->method('getType')
|
||||
->with('TYPE')
|
||||
->will($this->returnValue($resolvedType));
|
||||
->willReturn($resolvedType);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('createBuilder')
|
||||
->with($this->factory, 'TYPE_PREFIX', $options)
|
||||
->will($this->returnValue($this->builder));
|
||||
->willReturn($this->builder);
|
||||
|
||||
$this->builder->expects($this->any())
|
||||
->method('getOptions')
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('buildForm')
|
||||
@ -198,7 +198,7 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
$this->builder->expects($this->once())
|
||||
->method('getForm')
|
||||
->will($this->returnValue('FORM'));
|
||||
->willReturn('FORM');
|
||||
|
||||
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
|
||||
}
|
||||
@ -212,16 +212,16 @@ class FormFactoryTest extends TestCase
|
||||
$this->registry->expects($this->once())
|
||||
->method('getType')
|
||||
->with('type')
|
||||
->will($this->returnValue($resolvedType));
|
||||
->willReturn($resolvedType);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('createBuilder')
|
||||
->with($this->factory, 'name', $options)
|
||||
->will($this->returnValue($this->builder));
|
||||
->willReturn($this->builder);
|
||||
|
||||
$this->builder->expects($this->any())
|
||||
->method('getOptions')
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$resolvedType->expects($this->once())
|
||||
->method('buildForm')
|
||||
@ -229,7 +229,7 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
$this->builder->expects($this->once())
|
||||
->method('getForm')
|
||||
->will($this->returnValue('FORM'));
|
||||
->willReturn('FORM');
|
||||
|
||||
$this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options));
|
||||
}
|
||||
@ -245,7 +245,7 @@ class FormFactoryTest extends TestCase
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [])
|
||||
->will($this->returnValue('builderInstance'));
|
||||
->willReturn('builderInstance');
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
||||
|
||||
@ -257,27 +257,27 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessType')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new TypeGuess(
|
||||
->willReturn(new TypeGuess(
|
||||
'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||
['attr' => ['maxlength' => 10]],
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessType')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new TypeGuess(
|
||||
->willReturn(new TypeGuess(
|
||||
'Symfony\Component\Form\Extension\Core\Type\PasswordType',
|
||||
['attr' => ['maxlength' => 7]],
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->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');
|
||||
|
||||
@ -289,14 +289,14 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessType')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(null));
|
||||
->willReturn(null);
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||
->will($this->returnValue('builderInstance'));
|
||||
->willReturn('builderInstance');
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
||||
|
||||
@ -308,18 +308,18 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessType')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new TypeGuess(
|
||||
->willReturn(new TypeGuess(
|
||||
'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||
['attr' => ['class' => 'foo', 'maxlength' => 10]],
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->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(
|
||||
'Application\Author',
|
||||
@ -336,25 +336,25 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessMaxLength')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
15,
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessMaxLength')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
20,
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]])
|
||||
->will($this->returnValue('builderInstance'));
|
||||
->willReturn('builderInstance');
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty(
|
||||
'Application\Author',
|
||||
@ -369,25 +369,25 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessMaxLength')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
20,
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessPattern')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
'.{5,}',
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->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(
|
||||
'Application\Author',
|
||||
@ -404,25 +404,25 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessRequired')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
true,
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessRequired')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
false,
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false])
|
||||
->will($this->returnValue('builderInstance'));
|
||||
->willReturn('builderInstance');
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty(
|
||||
'Application\Author',
|
||||
@ -437,25 +437,25 @@ class FormFactoryTest extends TestCase
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessPattern')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
'[a-z]',
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessPattern')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
->willReturn(new ValueGuess(
|
||||
'[a-zA-Z]',
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
));
|
||||
|
||||
$factory = $this->getMockFactory(['createNamedBuilder']);
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->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(
|
||||
'Application\Author',
|
||||
|
@ -99,21 +99,21 @@ class ResolvedFormTypeTest extends TestCase
|
||||
// First the default options are generated for the super type
|
||||
$this->parentType->expects($this->once())
|
||||
->method('configureOptions')
|
||||
->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default')));
|
||||
->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default'));
|
||||
|
||||
// The form type itself
|
||||
$this->type->expects($this->once())
|
||||
->method('configureOptions')
|
||||
->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default')));
|
||||
->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default'));
|
||||
|
||||
// And its extensions
|
||||
$this->extension1->expects($this->once())
|
||||
->method('configureOptions')
|
||||
->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default')));
|
||||
->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default'));
|
||||
|
||||
$this->extension2->expects($this->once())
|
||||
->method('configureOptions')
|
||||
->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default')));
|
||||
->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default'));
|
||||
|
||||
$givenOptions = ['a' => 'a_custom', 'c' => 'c_custom'];
|
||||
$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())
|
||||
->method('getOptionsResolver')
|
||||
->will($this->returnValue($optionsResolver));
|
||||
->willReturn($optionsResolver);
|
||||
|
||||
$optionsResolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with($givenOptions)
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$factory = $this->getMockFormFactory();
|
||||
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
|
||||
@ -164,12 +164,12 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
$this->resolvedType->expects($this->once())
|
||||
->method('getOptionsResolver')
|
||||
->will($this->returnValue($optionsResolver));
|
||||
->willReturn($optionsResolver);
|
||||
|
||||
$optionsResolver->expects($this->once())
|
||||
->method('resolve')
|
||||
->with($givenOptions)
|
||||
->will($this->returnValue($resolvedOptions));
|
||||
->willReturn($resolvedOptions);
|
||||
|
||||
$factory = $this->getMockFormFactory();
|
||||
$builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions);
|
||||
@ -198,24 +198,24 @@ class ResolvedFormTypeTest extends TestCase
|
||||
$this->parentType->expects($this->once())
|
||||
->method('buildForm')
|
||||
->with($builder, $options)
|
||||
->will($this->returnCallback($assertIndex(0)));
|
||||
->willReturnCallback($assertIndex(0));
|
||||
|
||||
// Then the type itself
|
||||
$this->type->expects($this->once())
|
||||
->method('buildForm')
|
||||
->with($builder, $options)
|
||||
->will($this->returnCallback($assertIndex(1)));
|
||||
->willReturnCallback($assertIndex(1));
|
||||
|
||||
// Then its extensions
|
||||
$this->extension1->expects($this->once())
|
||||
->method('buildForm')
|
||||
->with($builder, $options)
|
||||
->will($this->returnCallback($assertIndex(2)));
|
||||
->willReturnCallback($assertIndex(2));
|
||||
|
||||
$this->extension2->expects($this->once())
|
||||
->method('buildForm')
|
||||
->with($builder, $options)
|
||||
->will($this->returnCallback($assertIndex(3)));
|
||||
->willReturnCallback($assertIndex(3));
|
||||
|
||||
$this->resolvedType->buildForm($builder, $options);
|
||||
}
|
||||
@ -261,24 +261,24 @@ class ResolvedFormTypeTest extends TestCase
|
||||
$this->parentType->expects($this->once())
|
||||
->method('buildView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(0)));
|
||||
->willReturnCallback($assertIndex(0));
|
||||
|
||||
// Then the type itself
|
||||
$this->type->expects($this->once())
|
||||
->method('buildView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(1)));
|
||||
->willReturnCallback($assertIndex(1));
|
||||
|
||||
// Then its extensions
|
||||
$this->extension1->expects($this->once())
|
||||
->method('buildView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(2)));
|
||||
->willReturnCallback($assertIndex(2));
|
||||
|
||||
$this->extension2->expects($this->once())
|
||||
->method('buildView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(3)));
|
||||
->willReturnCallback($assertIndex(3));
|
||||
|
||||
$this->resolvedType->buildView($view, $form, $options);
|
||||
}
|
||||
@ -303,24 +303,24 @@ class ResolvedFormTypeTest extends TestCase
|
||||
$this->parentType->expects($this->once())
|
||||
->method('finishView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(0)));
|
||||
->willReturnCallback($assertIndex(0));
|
||||
|
||||
// Then the type itself
|
||||
$this->type->expects($this->once())
|
||||
->method('finishView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(1)));
|
||||
->willReturnCallback($assertIndex(1));
|
||||
|
||||
// Then its extensions
|
||||
$this->extension1->expects($this->once())
|
||||
->method('finishView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(2)));
|
||||
->willReturnCallback($assertIndex(2));
|
||||
|
||||
$this->extension2->expects($this->once())
|
||||
->method('finishView')
|
||||
->with($view, $form, $options)
|
||||
->will($this->returnCallback($assertIndex(3)));
|
||||
->willReturnCallback($assertIndex(3));
|
||||
|
||||
$this->resolvedType->finishView($view, $form, $options);
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
$type->expects($this->once())
|
||||
->method('createView')
|
||||
->with($form)
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$this->assertSame($view, $form->createView());
|
||||
}
|
||||
@ -748,12 +748,12 @@ class SimpleFormTest extends AbstractFormTest
|
||||
|
||||
$parentType->expects($this->once())
|
||||
->method('createView')
|
||||
->will($this->returnValue($parentView));
|
||||
->willReturn($parentView);
|
||||
|
||||
$type->expects($this->once())
|
||||
->method('createView')
|
||||
->with($form, $parentView)
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$this->assertSame($view, $form->createView());
|
||||
}
|
||||
@ -768,7 +768,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
$type->expects($this->once())
|
||||
->method('createView')
|
||||
->with($form, $parentView)
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$this->assertSame($view, $form->createView($parentView));
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class FileTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('guess')
|
||||
->with($this->equalTo($path))
|
||||
->will($this->returnValue($mimeType))
|
||||
->willReturn($mimeType)
|
||||
;
|
||||
|
||||
return $guesser;
|
||||
|
@ -79,7 +79,7 @@ class MemcacheSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('set')
|
||||
->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2))
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->write('id', 'data'));
|
||||
@ -91,7 +91,7 @@ class MemcacheSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(self::PREFIX.'id')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->destroy('id'));
|
||||
|
@ -66,7 +66,7 @@ class MemcachedSessionHandlerTest extends TestCase
|
||||
$this->memcached
|
||||
->expects($this->once())
|
||||
->method('quit')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->close());
|
||||
@ -89,7 +89,7 @@ class MemcachedSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('set')
|
||||
->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2))
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->write('id', 'data'));
|
||||
@ -101,7 +101,7 @@ class MemcachedSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(self::PREFIX.'id')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->destroy('id'));
|
||||
|
@ -95,7 +95,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
// defining the timeout before the actual method call
|
||||
// allows to test for "greater than" values in the $criteria
|
||||
@ -103,7 +103,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method('findOne')
|
||||
->will($this->returnCallback(function ($criteria) use ($testTimeout) {
|
||||
->willReturnCallback(function ($criteria) use ($testTimeout) {
|
||||
$this->assertArrayHasKey($this->options['id_field'], $criteria);
|
||||
$this->assertEquals($criteria[$this->options['id_field']], 'foo');
|
||||
|
||||
@ -131,7 +131,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertEquals('bar', $this->storage->read('foo'));
|
||||
}
|
||||
@ -143,7 +143,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$data = [];
|
||||
|
||||
@ -151,7 +151,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method($methodName)
|
||||
->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
$this->assertEquals([$this->options['id_field'] => 'foo'], $criteria);
|
||||
|
||||
if (phpversion('mongodb')) {
|
||||
@ -161,7 +161,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
$data = $updateData['$set'];
|
||||
}));
|
||||
});
|
||||
|
||||
$expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime');
|
||||
$this->assertTrue($this->storage->write('foo', 'bar'));
|
||||
@ -197,7 +197,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$data = [];
|
||||
|
||||
@ -205,7 +205,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method($methodName)
|
||||
->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
$this->assertEquals([$this->options['id_field'] => 'foo'], $criteria);
|
||||
|
||||
if (phpversion('mongodb')) {
|
||||
@ -215,7 +215,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
$data = $updateData['$set'];
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertTrue($this->storage->write('foo', 'bar'));
|
||||
|
||||
@ -237,7 +237,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$data = [];
|
||||
|
||||
@ -245,9 +245,9 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
|
||||
$collection->expects($this->exactly(2))
|
||||
->method($methodName)
|
||||
->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
$data = $updateData;
|
||||
}));
|
||||
});
|
||||
|
||||
$this->storage->write('foo', 'bar');
|
||||
$this->storage->write('foo', 'foobar');
|
||||
@ -266,7 +266,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$methodName = phpversion('mongodb') ? 'deleteOne' : 'remove';
|
||||
|
||||
@ -284,13 +284,13 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
->willReturn($collection);
|
||||
|
||||
$methodName = phpversion('mongodb') ? 'deleteMany' : 'remove';
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method($methodName)
|
||||
->will($this->returnCallback(function ($criteria) {
|
||||
->willReturnCallback(function ($criteria) {
|
||||
if (phpversion('mongodb')) {
|
||||
$this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$this->options['expiry_field']]['$lt']);
|
||||
$this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000));
|
||||
@ -298,7 +298,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$lt']);
|
||||
$this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['expiry_field']]['$lt']->sec);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
$this->assertTrue($this->storage->gc(1));
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class PdoSessionHandlerTest extends TestCase
|
||||
$stream = $this->createStream($content);
|
||||
|
||||
$pdo->prepareResult->expects($this->once())->method('fetchAll')
|
||||
->will($this->returnValue([[$stream, 42, time()]]));
|
||||
->willReturn([[$stream, 42, time()]]);
|
||||
|
||||
$storage = new PdoSessionHandler($pdo);
|
||||
$result = $storage->read('foo');
|
||||
@ -177,14 +177,14 @@ class PdoSessionHandlerTest extends TestCase
|
||||
$exception = null;
|
||||
|
||||
$selectStmt->expects($this->atLeast(2))->method('fetchAll')
|
||||
->will($this->returnCallback(function () use (&$exception, $stream) {
|
||||
->willReturnCallback(function () use (&$exception, $stream) {
|
||||
return $exception ? [[$stream, 42, time()]] : [];
|
||||
}));
|
||||
});
|
||||
|
||||
$insertStmt->expects($this->once())->method('execute')
|
||||
->will($this->returnCallback(function () use (&$exception) {
|
||||
->willReturnCallback(function () use (&$exception) {
|
||||
throw $exception = new \PDOException('', '23');
|
||||
}));
|
||||
});
|
||||
|
||||
$storage = new PdoSessionHandler($pdo);
|
||||
$result = $storage->read('foo');
|
||||
|
@ -30,7 +30,7 @@ class WriteCheckSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('close')
|
||||
->with()
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($writeCheckSessionHandler->close());
|
||||
@ -45,7 +45,7 @@ class WriteCheckSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('write')
|
||||
->with('foo', 'bar')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertTrue($writeCheckSessionHandler->write('foo', 'bar'));
|
||||
@ -60,7 +60,7 @@ class WriteCheckSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('read')
|
||||
->with('foo')
|
||||
->will($this->returnValue('bar'))
|
||||
->willReturn('bar')
|
||||
;
|
||||
|
||||
$wrappedSessionHandlerMock
|
||||
@ -81,14 +81,14 @@ class WriteCheckSessionHandlerTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('read')
|
||||
->with('foo')
|
||||
->will($this->returnValue('bar'))
|
||||
->willReturn('bar')
|
||||
;
|
||||
|
||||
$wrappedSessionHandlerMock
|
||||
->expects($this->once())
|
||||
->method('write')
|
||||
->with('foo', 'baZZZ')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->assertEquals('bar', $writeCheckSessionHandler->read('foo'));
|
||||
|
@ -50,7 +50,7 @@ class SessionHandlerProxyTest extends TestCase
|
||||
{
|
||||
$this->mock->expects($this->once())
|
||||
->method('open')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$this->assertFalse($this->proxy->isActive());
|
||||
$this->proxy->open('name', 'id');
|
||||
@ -61,7 +61,7 @@ class SessionHandlerProxyTest extends TestCase
|
||||
{
|
||||
$this->mock->expects($this->once())
|
||||
->method('open')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->assertFalse($this->proxy->isActive());
|
||||
$this->proxy->open('name', 'id');
|
||||
@ -72,7 +72,7 @@ class SessionHandlerProxyTest extends TestCase
|
||||
{
|
||||
$this->mock->expects($this->once())
|
||||
->method('close')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$this->assertFalse($this->proxy->isActive());
|
||||
$this->proxy->close();
|
||||
@ -83,7 +83,7 @@ class SessionHandlerProxyTest extends TestCase
|
||||
{
|
||||
$this->mock->expects($this->once())
|
||||
->method('close')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->assertFalse($this->proxy->isActive());
|
||||
$this->proxy->close();
|
||||
|
@ -87,7 +87,7 @@ class CacheWarmerAggregateTest extends TestCase
|
||||
$warmer
|
||||
->expects($this->once())
|
||||
->method('isOptional')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$warmer
|
||||
->expects($this->never())
|
||||
->method('warmUp');
|
||||
|
@ -157,7 +157,7 @@ class ClientTest extends TestCase
|
||||
|
||||
$file->expects($this->once())
|
||||
->method('getSize')
|
||||
->will($this->returnValue(INF))
|
||||
->willReturn(INF)
|
||||
;
|
||||
|
||||
$client->request('POST', '/', [], [$file]);
|
||||
|
@ -23,7 +23,7 @@ class FileLocatorTest extends TestCase
|
||||
->expects($this->atLeastOnce())
|
||||
->method('locateResource')
|
||||
->with('@BundleName/some/path', null, true)
|
||||
->will($this->returnValue('/bundle-name/some/path'));
|
||||
->willReturn('/bundle-name/some/path');
|
||||
$locator = new FileLocator($kernel);
|
||||
$this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path'));
|
||||
|
||||
|
@ -26,11 +26,11 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->once())
|
||||
->method('has')
|
||||
->with('foo')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($this))
|
||||
->willReturn($this)
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -51,12 +51,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->once())
|
||||
->method('has')
|
||||
->with('foo')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($invokableController))
|
||||
->willReturn($invokableController)
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -77,12 +77,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->once())
|
||||
->method('has')
|
||||
->with($className)
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with($className)
|
||||
->will($this->returnValue($invokableController))
|
||||
->willReturn($invokableController)
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -100,7 +100,7 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->once())
|
||||
->method('has')
|
||||
->with(NonInstantiableController::class)
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false)
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -122,19 +122,19 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->at(0))
|
||||
->method('has')
|
||||
->with(ImpossibleConstructController::class)
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$container->expects($this->at(1))
|
||||
->method('has')
|
||||
->with(ImpossibleConstructController::class)
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false)
|
||||
;
|
||||
|
||||
$container->expects($this->atLeastOnce())
|
||||
->method('getRemovedIds')
|
||||
->with()
|
||||
->will($this->returnValue([ImpossibleConstructController::class => true]))
|
||||
->willReturn([ImpossibleConstructController::class => true])
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -162,12 +162,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->atLeastOnce())
|
||||
->method('has')
|
||||
->with(NonInstantiableController::class)
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$container->expects($this->atLeastOnce())
|
||||
->method('get')
|
||||
->with(NonInstantiableController::class)
|
||||
->will($this->returnValue($service))
|
||||
->willReturn($service)
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -189,13 +189,13 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->at(0))
|
||||
->method('has')
|
||||
->with('app.my_controller')
|
||||
->will($this->returnValue(false))
|
||||
->willReturn(false)
|
||||
;
|
||||
|
||||
$container->expects($this->atLeastOnce())
|
||||
->method('getRemovedIds')
|
||||
->with()
|
||||
->will($this->returnValue(['app.my_controller' => true]))
|
||||
->willReturn(['app.my_controller' => true])
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
@ -215,12 +215,12 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$container->expects($this->once())
|
||||
->method('has')
|
||||
->with('app.my_controller')
|
||||
->will($this->returnValue(true))
|
||||
->willReturn(true)
|
||||
;
|
||||
$container->expects($this->once())
|
||||
->method('get')
|
||||
->with('app.my_controller')
|
||||
->will($this->returnValue(new ImpossibleConstructController('toto', 'controller')))
|
||||
->willReturn(new ImpossibleConstructController('toto', 'controller'))
|
||||
;
|
||||
|
||||
$resolver = $this->createControllerResolver(null, $container);
|
||||
|
@ -226,7 +226,7 @@ class ControllerResolverTest extends TestCase
|
||||
public function testCreateControllerCanReturnAnyCallable()
|
||||
{
|
||||
$mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(['createController'])->getMock();
|
||||
$mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'));
|
||||
$mock->expects($this->once())->method('createController')->willReturn('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function');
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('_controller', 'foobar');
|
||||
|
@ -23,8 +23,8 @@ class LoggerDataCollectorTest extends TestCase
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||
->setMethods(['countErrors', 'getLogs', 'clear'])
|
||||
->getMock();
|
||||
$logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo'));
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([]));
|
||||
$logger->expects($this->once())->method('countErrors')->willReturn('foo');
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
|
||||
|
||||
$c = new LoggerDataCollector($logger, __DIR__.'/');
|
||||
$c->lateCollect();
|
||||
@ -50,8 +50,8 @@ class LoggerDataCollectorTest extends TestCase
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||
->setMethods(['countErrors', 'getLogs', 'clear'])
|
||||
->getMock();
|
||||
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
|
||||
$logger->expects($this->once())->method('countErrors')->willReturn($nb);
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->willReturn($logs);
|
||||
|
||||
$c = new LoggerDataCollector($logger);
|
||||
$c->lateCollect();
|
||||
|
@ -44,7 +44,7 @@ class TimeDataCollectorTest extends TestCase
|
||||
$this->assertEquals(0, $c->getStartTime());
|
||||
|
||||
$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);
|
||||
$request = new Request();
|
||||
|
@ -49,7 +49,7 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
->getMock();
|
||||
$stopwatch->expects($this->once())
|
||||
->method('isStarted')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
|
||||
|
||||
@ -65,7 +65,7 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
->getMock();
|
||||
$stopwatch->expects($this->once())
|
||||
->method('isStarted')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
$stopwatch->expects($this->once())
|
||||
->method('stop');
|
||||
$stopwatch->expects($this->once())
|
||||
@ -112,9 +112,9 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
protected function getHttpKernel($dispatcher, $controller)
|
||||
{
|
||||
$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->expects($this->once())->method('getArguments')->will($this->returnValue([]));
|
||||
$argumentResolver->expects($this->once())->method('getArguments')->willReturn([]);
|
||||
|
||||
return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver);
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ class LazyLoadingFragmentHandlerTest extends TestCase
|
||||
public function testRenderWithLegacyMapping()
|
||||
{
|
||||
$renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
|
||||
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
|
||||
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
|
||||
$renderer->expects($this->once())->method('getName')->willReturn('foo');
|
||||
$renderer->expects($this->any())->method('render')->willReturn(new Response());
|
||||
|
||||
$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('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$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->addRendererService('foo', 'foo');
|
||||
@ -46,15 +46,15 @@ class LazyLoadingFragmentHandlerTest extends TestCase
|
||||
public function testRender()
|
||||
{
|
||||
$renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock();
|
||||
$renderer->expects($this->once())->method('getName')->will($this->returnValue('foo'));
|
||||
$renderer->expects($this->any())->method('render')->will($this->returnValue(new Response()));
|
||||
$renderer->expects($this->once())->method('getName')->willReturn('foo');
|
||||
$renderer->expects($this->any())->method('render')->willReturn(new Response());
|
||||
|
||||
$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->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);
|
||||
|
||||
|
@ -77,7 +77,7 @@ class AddRequestFormatsListenerTest extends TestCase
|
||||
|
||||
$event->expects($this->any())
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request));
|
||||
->willReturn($request);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class DebugHandlersListenerTest extends TestCase
|
||||
$dispatcher = new EventDispatcher();
|
||||
$listener = new DebugHandlersListener(null);
|
||||
$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->setApplication($app);
|
||||
$event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());
|
||||
|
@ -112,9 +112,9 @@ class ExceptionListenerTest extends TestCase
|
||||
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->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 = Request::create('/');
|
||||
$request->setRequestFormat('xml');
|
||||
@ -130,9 +130,9 @@ class ExceptionListenerTest extends TestCase
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$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());
|
||||
}));
|
||||
});
|
||||
|
||||
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true);
|
||||
|
||||
|
@ -55,7 +55,7 @@ class LocaleListenerTest extends TestCase
|
||||
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
|
||||
|
||||
$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('/');
|
||||
|
||||
@ -71,12 +71,12 @@ class LocaleListenerTest extends TestCase
|
||||
$context->expects($this->once())->method('setParameter')->with('_locale', 'es');
|
||||
|
||||
$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->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();
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user