minor #34105 Remove unused local variables (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

Remove unused local variables

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This PR removes useless assignations. There are also somes fixes in tests.

Commits
-------

c07cee8f61 Remove unused local variables in tests
This commit is contained in:
Tobias Schultze 2019-10-25 04:33:49 +02:00
commit 278280a246
77 changed files with 118 additions and 133 deletions

View File

@ -187,7 +187,7 @@ class EntityTypeTest extends BaseTypeTest
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
{
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
'em' => 'default',
'class' => self::SINGLE_IDENT_CLASS,
'query_builder' => new \stdClass(),

View File

@ -28,7 +28,6 @@ class SearchAndRenderBlockNode extends FunctionExpression
preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches);
$label = null;
$arguments = iterator_to_array($this->getNode('arguments'));
$blockNameSuffix = $matches[1];

View File

@ -180,10 +180,10 @@ class AppVariableTest extends TestCase
$flashMessages = $this->setFlashMessages();
$this->assertEquals($flashMessages, $this->appVariable->getFlashes([]));
$flashMessages = $this->setFlashMessages();
$this->setFlashMessages();
$this->assertEquals([], $this->appVariable->getFlashes('this-does-not-exist'));
$flashMessages = $this->setFlashMessages();
$this->setFlashMessages();
$this->assertEquals(
['this-does-not-exist' => []],
$this->appVariable->getFlashes(['this-does-not-exist'])

View File

@ -52,7 +52,7 @@ class LintCommandTest extends TestCase
$filename = $this->createFile('');
unlink($filename);
$ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]);
$tester->execute(['filename' => [$filename]], ['decorated' => false]);
}
public function testLintFileCompileTimeException()

View File

@ -34,7 +34,7 @@ class StopwatchExtensionTest extends TestCase
$twig->addExtension(new StopwatchExtension($this->getStopwatch($events)));
try {
$nodes = $twig->render('template');
$twig->render('template');
} catch (RuntimeError $e) {
throw $e->getPrevious();
}

View File

@ -49,21 +49,21 @@ class TranslationExtensionTest extends TestCase
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.');
$output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
$this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
}
public function testTransComplexBody()
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('A message inside a trans tag must be a simple text in "index" at line 2.');
$output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
$this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
}
public function testTransChoiceComplexBody()
{
$this->expectException('Twig\Error\SyntaxError');
$this->expectExceptionMessage('A message inside a transchoice tag must be a simple text in "index" at line 2.');
$output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
$this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
}
public function getTransTests()

View File

@ -425,7 +425,6 @@ class TextDescriptor extends Descriptor
$tableHeaders = ['Order', 'Callable', 'Priority'];
$tableRows = [];
$order = 1;
foreach ($eventListeners as $order => $listener) {
$tableRows[] = [sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)];
}

View File

@ -1043,8 +1043,6 @@ class FrameworkExtension extends Extension
$container->getDefinition('assets.url_package')->setPrivate(true);
$container->getDefinition('assets.static_version_strategy')->setPrivate(true);
$defaultVersion = null;
if ($config['version_strategy']) {
$defaultVersion = new Reference($config['version_strategy']);
} else {

View File

@ -277,8 +277,7 @@ abstract class ControllerTraitTest extends TestCase
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
$controller = $this->createController();
/* @var BinaryFileResponse $response */
$response = $controller->file('some-file.txt', 'test.php');
$controller->file('some-file.txt', 'test.php');
}
public function testIsGranted()

View File

@ -51,7 +51,7 @@ class AddConstraintValidatorsPassTest extends TestCase
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.');
$container = new ContainerBuilder();
$validatorFactory = $container->register('validator.validator_factory')
$container->register('validator.validator_factory')
->addArgument([]);
$container->register('my_abstract_constraint_validator')

View File

@ -251,7 +251,7 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testDeprecatedWorkflowMissingType()
{
$container = $this->createContainerFromFile('workflows_without_type');
$this->createContainerFromFile('workflows_without_type');
}
public function testWorkflowCannotHaveBothTypeAndService()

View File

@ -26,7 +26,7 @@ class TestExtension extends Extension implements PrependExtensionInterface
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->processConfiguration($configuration, $configs);
$container->setAlias('test.annotation_reader', new Alias('annotation_reader', true));
}

View File

@ -59,7 +59,7 @@ class SessionTest extends AbstractWebTestCase
}
// set flash
$crawler = $client->request('GET', '/session_setflash/Hello%20world.');
$client->request('GET', '/session_setflash/Hello%20world.');
// check flash displays on redirect
$this->assertStringContainsString('Hello world.', $client->followRedirect()->text());

View File

@ -162,7 +162,7 @@ class TranslatorTest extends TestCase
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Missing third $defaultLocale argument.');
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$translator = new Translator($container, new MessageFormatter());
new Translator($container, new MessageFormatter());
}
/**

View File

@ -61,7 +61,7 @@ class AbstractFactoryTest extends TestCase
$options['failure_handler'] = $serviceId;
}
list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
list($container) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();
@ -99,7 +99,7 @@ class AbstractFactoryTest extends TestCase
$options['success_handler'] = $serviceId;
}
list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
list($container) = $this->callFactory('foo', $options, 'user_provider', 'entry_point');
$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();

View File

@ -159,7 +159,7 @@ class GuardAuthenticationFactoryTest extends TestCase
'authenticators' => ['authenticator123', 'authenticatorABC'],
'entry_point' => 'authenticatorABC',
];
list($container, $entryPointId) = $this->executeCreate($config, null);
list(, $entryPointId) = $this->executeCreate($config, null);
$this->assertEquals('authenticatorABC', $entryPointId);
}
@ -172,7 +172,7 @@ class GuardAuthenticationFactoryTest extends TestCase
$userProviderId = 'my_user_provider';
$factory = new GuardAuthenticationFactory();
list($providerId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId);
list(, , $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId);
return [$container, $entryPointId];
}

View File

@ -198,6 +198,6 @@ class CookieTest extends TestCase
{
$this->expectException('UnexpectedValueException');
$this->expectExceptionMessage('The cookie expiration time "string" is not valid.');
$cookie = new Cookie('foo', 'bar', 'string');
new Cookie('foo', 'bar', 'string');
}
}

View File

@ -70,7 +70,7 @@ class MaxIdLengthAdapterTest extends TestCase
{
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
$this->getMockBuilder(MaxIdLengthAdapter::class)
->setConstructorArgs([str_repeat('-', 40)])
->getMock();
}

View File

@ -19,7 +19,7 @@ class DelegatingLoaderTest extends TestCase
{
public function testConstructor()
{
$loader = new DelegatingLoader($resolver = new LoaderResolver());
new DelegatingLoader($resolver = new LoaderResolver());
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
}

View File

@ -67,7 +67,7 @@ EOF
$loadedClass = 123;
$res = new ClassExistenceResource('MissingFooClass', false);
new ClassExistenceResource('MissingFooClass', false);
$this->assertSame(123, $loadedClass);
} finally {

View File

@ -67,7 +67,7 @@ class DirectoryResourceTest extends TestCase
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessageRegExp('/The directory ".*" does not exist./');
$resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
}
public function testIsFresh()
@ -165,7 +165,7 @@ class DirectoryResourceTest extends TestCase
{
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
$unserialized = unserialize(serialize($resource));
unserialize(serialize($resource));
$this->assertSame(realpath($this->directory), $resource->getResource());
$this->assertSame('/\.(foo|xml)$/', $resource->getPattern());

View File

@ -57,7 +57,7 @@ class FileResourceTest extends TestCase
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessageRegExp('/The file ".*" does not exist./');
$resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999));
new FileResource('/____foo/foobar'.mt_rand(1, 999999));
}
public function testIsFresh()
@ -76,7 +76,7 @@ class FileResourceTest extends TestCase
public function testSerializeUnserialize()
{
$unserialized = unserialize(serialize($this->resource));
unserialize(serialize($this->resource));
$this->assertSame(realpath($this->file), $this->resource->getResource());
}

View File

@ -521,7 +521,7 @@ class ApplicationTest extends TestCase
// Subnamespace + plural
try {
$a = $application->find('foo3:');
$application->find('foo3:');
$this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives');
} catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e);

View File

@ -104,7 +104,7 @@ class ProgressIndicatorTest extends TestCase
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Must have at least 2 indicator value characters.');
$bar = new ProgressIndicator($this->getOutputStream(), null, 100, ['1']);
new ProgressIndicator($this->getOutputStream(), null, 100, ['1']);
}
public function testCannotStartAlreadyStartedIndicator()

View File

@ -404,7 +404,7 @@ class DebugClassLoader
}
if (isset($dirFiles[$file])) {
return $real .= $dirFiles[$file];
return $real.$dirFiles[$file];
}
$kFile = strtolower($file);
@ -423,7 +423,7 @@ class DebugClassLoader
self::$darwinCache[$kDir][1] = $dirFiles;
}
return $real .= $dirFiles[$kFile];
return $real.$dirFiles[$kFile];
}
/**

View File

@ -256,7 +256,7 @@ class FlattenExceptionTest extends TestCase
// assertEquals() does not like NAN values.
$this->assertEquals($array[$i][0], 'float');
$this->assertNan($array[$i++][1]);
$this->assertNan($array[$i][1]);
}
public function testRecursionInArguments()

View File

@ -219,7 +219,7 @@ EOF;
foreach ($ids as $id) {
$c .= ' '.$this->doExport($id)." => true,\n";
}
$files['removed-ids.php'] = $c .= "];\n";
$files['removed-ids.php'] = $c."];\n";
}
foreach ($this->generateServiceFiles() as $file => $c) {

View File

@ -25,28 +25,28 @@ class AnalyzeServiceReferencesPassTest extends TestCase
{
$container = new ContainerBuilder();
$a = $container
$container
->register('a')
->addArgument($ref1 = new Reference('b'))
;
$b = $container
$container
->register('b')
->addMethodCall('setA', [$ref2 = new Reference('a')])
;
$c = $container
$container
->register('c')
->addArgument($ref3 = new Reference('a'))
->addArgument($ref4 = new Reference('b'))
;
$d = $container
$container
->register('d')
->setProperty('foo', $ref5 = new Reference('b'))
;
$e = $container
$container
->register('e')
->setConfigurator([$ref6 = new Reference('b'), 'methodName'])
;

View File

@ -43,7 +43,7 @@ class IntegrationTest extends TestCase
->addArgument(new Reference('c'))
;
$b = $container
$container
->register('b', '\stdClass')
->addArgument(new Reference('c'))
->setPublic(false)

View File

@ -390,7 +390,7 @@ class ResolveChildDefinitionsPassTest extends TestCase
->setBindings(['a' => '1', 'b' => '2'])
;
$child = $container->setDefinition('child', new ChildDefinition('parent'))
$container->setDefinition('child', new ChildDefinition('parent'))
->setBindings(['b' => 'B', 'c' => 'C'])
;

View File

@ -87,8 +87,8 @@ class ResolveClassPassTest extends TestCase
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Service definition "App\Foo\Child" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.');
$container = new ContainerBuilder();
$parent = $container->register('App\Foo', null);
$child = $container->setDefinition('App\Foo\Child', new ChildDefinition('App\Foo'));
$container->register('App\Foo', null);
$container->setDefinition('App\Foo\Child', new ChildDefinition('App\Foo'));
(new ResolveClassPass())->process($container);
}

View File

@ -1265,7 +1265,7 @@ class ContainerBuilderTest extends TestCase
$this->expectExceptionMessage('The definition for "DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.');
$container = new ContainerBuilder();
$definition = $container->register(\DateTime::class);
$container->register(\DateTime::class);
$container->compile();
}
@ -1295,7 +1295,7 @@ class ContainerBuilderTest extends TestCase
$this->expectExceptionMessage('The definition for "123_abc" has no class.');
$container = new ContainerBuilder();
$definition = $container->register('123_abc');
$container->register('123_abc');
$container->compile();
}
@ -1305,7 +1305,7 @@ class ContainerBuilderTest extends TestCase
$this->expectExceptionMessage('The definition for "\foo" has no class.');
$container = new ContainerBuilder();
$definition = $container->register('\\foo');
$container->register('\\foo');
$container->compile();
}

View File

@ -886,7 +886,7 @@ class PhpDumperTest extends TestCase
->setPublic(true)
->addArgument($baz);
$passConfig = $container->getCompiler()->getPassConfig();
$container->getCompiler()->getPassConfig();
$container->compile();
$dumper = new PhpDumper($container);
@ -978,7 +978,6 @@ class PhpDumperTest extends TestCase
$container->compile();
$dumper = new PhpDumper($container);
$dump = $dumper->dump();
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_adawson.php', $dumper->dump());
}

View File

@ -808,7 +808,6 @@ class XmlFileLoaderTest extends TestCase
$container->compile();
$dumper = new PhpDumper($container);
$dump = $dumper->dump();
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_tsantos.php', $dumper->dump());
}

View File

@ -19,7 +19,7 @@ class ChoiceFormFieldTest extends FormFieldTestCase
{
$node = $this->createNode('textarea', '');
try {
$field = new ChoiceFormField($node);
new ChoiceFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not an input or a select');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input or a select');
@ -27,7 +27,7 @@ class ChoiceFormFieldTest extends FormFieldTestCase
$node = $this->createNode('input', '', ['type' => 'text']);
try {
$field = new ChoiceFormField($node);
new ChoiceFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');

View File

@ -24,7 +24,7 @@ class FileFormFieldTest extends FormFieldTestCase
$node = $this->createNode('textarea', '');
try {
$field = new FileFormField($node);
new FileFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not an input field');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input field');
@ -32,7 +32,7 @@ class FileFormFieldTest extends FormFieldTestCase
$node = $this->createNode('input', '', ['type' => 'text']);
try {
$field = new FileFormField($node);
new FileFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not a file input field');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a file input field');

View File

@ -24,7 +24,7 @@ class InputFormFieldTest extends FormFieldTestCase
$node = $this->createNode('textarea', '');
try {
$field = new InputFormField($node);
new InputFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not an input');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input');
@ -32,7 +32,7 @@ class InputFormFieldTest extends FormFieldTestCase
$node = $this->createNode('input', '', ['type' => 'checkbox']);
try {
$field = new InputFormField($node);
new InputFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is a checkbox');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is a checkbox');
@ -40,7 +40,7 @@ class InputFormFieldTest extends FormFieldTestCase
$node = $this->createNode('input', '', ['type' => 'file']);
try {
$field = new InputFormField($node);
new InputFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is a file');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is a file');

View File

@ -24,7 +24,7 @@ class TextareaFormFieldTest extends FormFieldTestCase
$node = $this->createNode('input', '');
try {
$field = new TextareaFormField($node);
new TextareaFormField($node);
$this->fail('->initialize() throws a \LogicException if the node is not a textarea');
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');

View File

@ -39,14 +39,14 @@ class FormTest extends TestCase
$nodes = $dom->getElementsByTagName('input');
try {
$form = new Form($nodes->item(0), 'http://example.com');
new Form($nodes->item(0), 'http://example.com');
$this->fail('__construct() throws a \\LogicException if the node has no form ancestor');
} catch (\LogicException $e) {
$this->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
}
try {
$form = new Form($nodes->item(1), 'http://example.com');
new Form($nodes->item(1), 'http://example.com');
$this->fail('__construct() throws a \\LogicException if the input type is not submit, button, or image');
} catch (\LogicException $e) {
$this->assertTrue(true, '__construct() throws a \\LogicException if the input type is not submit, button, or image');
@ -55,7 +55,7 @@ class FormTest extends TestCase
$nodes = $dom->getElementsByTagName('button');
try {
$form = new Form($nodes->item(0), 'http://example.com');
new Form($nodes->item(0), 'http://example.com');
$this->fail('__construct() throws a \\LogicException if the node has no form ancestor');
} catch (\LogicException $e) {
$this->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
@ -63,11 +63,19 @@ class FormTest extends TestCase
}
/**
* __construct() should throw \\LogicException if the form attribute is invalid.
* @dataProvider constructorThrowsExceptionIfNoRelatedFormProvider
*
* __construct() should throw a \LogicException if the form attribute is invalid.
*/
public function testConstructorThrowsExceptionIfNoRelatedForm()
public function testConstructorThrowsExceptionIfNoRelatedForm(\DOMElement $node)
{
$this->expectException('LogicException');
new Form($node, 'http://example.com');
}
public function constructorThrowsExceptionIfNoRelatedFormProvider()
{
$dom = new \DOMDocument();
$dom->loadHTML('
<html>
@ -81,8 +89,10 @@ class FormTest extends TestCase
$nodes = $dom->getElementsByTagName('input');
$form = new Form($nodes->item(0), 'http://example.com');
$form = new Form($nodes->item(1), 'http://example.com');
return [
[$nodes->item(0)],
[$nodes->item(1)],
];
}
public function testConstructorLoadsOnlyFieldsOfTheRightForm()

View File

@ -37,10 +37,6 @@ class RegisterListenersPassTest extends TestCase
public function testValidEventSubscriber()
{
$services = [
'my_event_subscriber' => [0 => []],
];
$builder = new ContainerBuilder();
$eventDispatcherDefinition = $builder->register('event_dispatcher');
$builder->register('my_event_subscriber', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')

View File

@ -98,7 +98,7 @@ class ExpressionLanguageTest extends TestCase
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Cache argument has to implement Psr\Cache\CacheItemPoolInterface.');
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemSpoolInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
new ExpressionLanguage($cacheMock);
}
public function testConstantFunction()
@ -196,7 +196,7 @@ class ExpressionLanguageTest extends TestCase
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
$savedParsedExpressions = [];
$savedParsedExpression = null;
$cacheMock
->expects($this->exactly(2))

View File

@ -68,7 +68,7 @@ class ParserCacheAdapterTest extends TestCase
->willReturn($value)
;
$cacheItem = $parserCacheAdapter->save($cacheItemMock);
$parserCacheAdapter->save($cacheItemMock);
}
public function testGetItems()

View File

@ -181,10 +181,10 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
public function testTransformWrapsIntlErrors()
{
$transformer = new DateTimeToLocalizedStringTransformer();
$this->markTestIncomplete('Checking for intl errors needs to be reimplemented');
$transformer = new DateTimeToLocalizedStringTransformer();
// HOW TO REPRODUCE?
//$this->expectException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');

View File

@ -153,7 +153,7 @@ class UploadedFileTest extends TestCase
UPLOAD_ERR_OK
);
$movedFile = $file->move(__DIR__.'/Fixtures/directory');
$file->move(__DIR__.'/Fixtures/directory');
}
public function testMoveLocalFileIsAllowedInTestMode()

View File

@ -59,7 +59,7 @@ class HeaderBagTest extends TestCase
{
$this->expectException('RuntimeException');
$bag = new HeaderBag(['foo' => 'Tue']);
$headerDate = $bag->getDate('foo');
$bag->getDate('foo');
}
public function testGetCacheControlHeader()

View File

@ -29,13 +29,13 @@ class RedirectResponseTest extends TestCase
public function testRedirectResponseConstructorNullUrl()
{
$this->expectException('InvalidArgumentException');
$response = new RedirectResponse(null);
new RedirectResponse(null);
}
public function testRedirectResponseConstructorWrongStatusCode()
{
$this->expectException('InvalidArgumentException');
$response = new RedirectResponse('foo.bar', 404);
new RedirectResponse('foo.bar', 404);
}
public function testGenerateLocationHeader()

View File

@ -41,7 +41,7 @@ class NativeFileSessionHandlerTest extends TestCase
*/
public function testConstructSavePath($savePath, $expectedSavePath, $path)
{
$handler = new NativeFileSessionHandler($savePath);
new NativeFileSessionHandler($savePath);
$this->assertEquals($expectedSavePath, ini_get('session.save_path'));
$this->assertDirectoryExists(realpath($path));
@ -62,13 +62,13 @@ class NativeFileSessionHandlerTest extends TestCase
public function testConstructException()
{
$this->expectException('InvalidArgumentException');
$handler = new NativeFileSessionHandler('something;invalid;with;too-many-args');
new NativeFileSessionHandler('something;invalid;with;too-many-args');
}
public function testConstructDefault()
{
$path = ini_get('session.save_path');
$storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler());
new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler());
$this->assertEquals($path, ini_get('session.save_path'));
}

View File

@ -28,7 +28,7 @@ class NullSessionHandlerTest extends TestCase
{
public function testSaveHandlers()
{
$storage = $this->getStorage();
$this->getStorage();
$this->assertEquals('user', ini_get('session.save_handler'));
}

View File

@ -54,7 +54,7 @@ class PdoSessionHandlerTest extends TestCase
$pdo = $this->getMemorySqlitePdo();
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
$storage = new PdoSessionHandler($pdo);
new PdoSessionHandler($pdo);
}
public function testInexistentTable()

View File

@ -145,7 +145,7 @@ class NativeSessionStorageTest extends TestCase
{
$this->iniSet('session.cache_limiter', 'nocache');
$storage = new NativeSessionStorage();
new NativeSessionStorage();
$this->assertEquals('', ini_get('session.cache_limiter'));
}
@ -153,7 +153,7 @@ class NativeSessionStorageTest extends TestCase
{
$this->iniSet('session.cache_limiter', 'nocache');
$storage = new NativeSessionStorage(['cache_limiter' => 'public']);
new NativeSessionStorage(['cache_limiter' => 'public']);
$this->assertEquals('public', ini_get('session.cache_limiter'));
}

View File

@ -49,7 +49,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
}
}
$content = null;
try {
$content = $request->getContent();
} catch (\LogicException $e) {
@ -59,7 +58,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$sessionMetadata = [];
$sessionAttributes = [];
$session = null;
$flashes = [];
if ($request->hasSession()) {
$session = $request->getSession();

View File

@ -130,7 +130,6 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
$response->headers->set('Cache-Control', implode(', ', array_keys($flags)));
$maxAge = null;
$sMaxage = null;
if (is_numeric($this->ageDirectives['max-age'])) {
$maxAge = $this->ageDirectives['max-age'] + $this->age;

View File

@ -256,7 +256,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testControllersAreMadePublic()
{
$container = new ContainerBuilder();
$resolver = $container->register('argument_resolver.service')->addArgument([]);
$container->register('argument_resolver.service')->addArgument([]);
$container->register('foo', ArgumentWithoutTypeController::class)
->setPublic(false)

View File

@ -52,7 +52,7 @@ class StoreTest extends TestCase
public function testUnlockFileThatDoesExist()
{
$cacheKey = $this->storeSimpleEntry();
$this->storeSimpleEntry();
$this->store->lock($this->request);
$this->assertTrue($this->store->unlock($this->request));
@ -92,7 +92,7 @@ class StoreTest extends TestCase
{
$cacheKey = $this->storeSimpleEntry();
$entries = $this->getStoreMetadata($cacheKey);
list($req, $res) = $entries[0];
list(, $res) = $entries[0];
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]);
}
@ -208,7 +208,7 @@ class StoreTest extends TestCase
{
$req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']);
$res1 = new Response('test 1', 200, ['Vary' => 'Foo Bar']);
$key = $this->store->write($req1, $res1);
$this->store->write($req1, $res1);
$this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent());
$req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam']);
@ -229,7 +229,7 @@ class StoreTest extends TestCase
$req = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']);
$this->assertTrue($this->store->lock($req));
$path = $this->store->lock($req);
$this->store->lock($req);
$this->assertTrue($this->store->isLocked($req));
$this->store->unlock($req);

View File

@ -132,9 +132,6 @@ class ExecutableFinderTest extends TestCase
$this->assertSamePath(PHP_BINARY, $result);
}
/**
* @requires PHP 5.4
*/
public function testFindBatchExecutableOnWindows()
{
if (ini_get('open_basedir')) {

View File

@ -19,7 +19,7 @@ class RouteTest extends TestCase
public function testInvalidRouteParameter()
{
$this->expectException('BadMethodCallException');
$route = new Route(['foo' => 'bar']);
new Route(['foo' => 'bar']);
}
/**

View File

@ -6,7 +6,7 @@ trait FooTrait
{
public function doBar()
{
$baz = self::class;
self::class;
if (true) {
}
}

View File

@ -135,7 +135,7 @@ class PhpGeneratorDumperTest extends TestCase
include $this->testTmpFilepath;
$projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext());
$url = $projectUrlGenerator->generate('NonExisting', []);
$projectUrlGenerator->generate('NonExisting', []);
}
public function testDumpForRouteWithDefaults()

View File

@ -35,9 +35,6 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
}
/**
* @requires PHP 5.4
*/
public function testLoadTraitWithClassConstant()
{
$this->reader->expects($this->never())->method('getClassAnnotation');

View File

@ -248,7 +248,7 @@ class RouteCompilerTest extends TestCase
$this->expectException('LogicException');
$route = new Route('/{name}/{name}');
$compiled = $route->compile();
$route->compile();
}
public function testRouteCharsetMismatch()
@ -256,7 +256,7 @@ class RouteCompilerTest extends TestCase
$this->expectException('LogicException');
$route = new Route("/\xE9/{bar}", [], ['bar' => '.'], ['utf8' => true]);
$compiled = $route->compile();
$route->compile();
}
public function testRequirementCharsetMismatch()
@ -264,7 +264,7 @@ class RouteCompilerTest extends TestCase
$this->expectException('LogicException');
$route = new Route('/foo/{bar}', [], ['bar' => "\xE9"], ['utf8' => true]);
$compiled = $route->compile();
$route->compile();
}
public function testRouteWithFragmentAsPathParameter()
@ -272,7 +272,7 @@ class RouteCompilerTest extends TestCase
$this->expectException('InvalidArgumentException');
$route = new Route('/{_fragment}');
$compiled = $route->compile();
$route->compile();
}
/**

View File

@ -117,7 +117,7 @@ class EncoderFactoryTest extends TestCase
$user = new EncAwareUser('user', 'pass');
$user->encoderName = 'invalid_encoder_name';
$encoder = $factory->getEncoder($user);
$factory->getEncoder($user);
}
public function testGetEncoderForEncoderAwareWithClassName()

View File

@ -192,7 +192,7 @@ class GuardAuthenticationProviderTest extends TestCase
$token->setAuthenticated(false);
$provider = new GuardAuthenticationProvider([], $this->userProvider, $providerKey, $this->userChecker);
$actualToken = $provider->authenticate($token);
$provider->authenticate($token);
}
public function testSupportsChecksGuardAuthenticatorsTokenOrigin()

View File

@ -20,7 +20,7 @@ class LogoutListenerTest extends TestCase
{
public function testHandleUnmatchedPath()
{
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener();
list($listener, , $httpUtils, $options) = $this->getListener();
list($event, $request) = $this->getGetResponseEvent();
@ -130,7 +130,7 @@ class LogoutListenerTest extends TestCase
$this->expectException('RuntimeException');
$successHandler = $this->getSuccessHandler();
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener($successHandler);
list($listener, , $httpUtils, $options) = $this->getListener($successHandler);
list($event, $request) = $this->getGetResponseEvent();
@ -152,7 +152,7 @@ class LogoutListenerTest extends TestCase
$this->expectException('Symfony\Component\Security\Core\Exception\LogoutException');
$tokenManager = $this->getTokenManager();
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener(null, $tokenManager);
list($listener, , $httpUtils, $options) = $this->getListener(null, $tokenManager);
list($event, $request) = $this->getGetResponseEvent();

View File

@ -221,7 +221,7 @@ class RememberMeListenerTest extends TestCase
public function testSessionStrategy()
{
list($listener, $tokenStorage, $service, $manager, , $dispatcher, $sessionStrategy) = $this->getListener(false, true, true);
list($listener, $tokenStorage, $service, $manager, , , $sessionStrategy) = $this->getListener(false, true, true);
$tokenStorage
->expects($this->once())
@ -286,7 +286,7 @@ class RememberMeListenerTest extends TestCase
public function testSessionIsMigratedByDefault()
{
list($listener, $tokenStorage, $service, $manager, , $dispatcher, $sessionStrategy) = $this->getListener(false, true, false);
list($listener, $tokenStorage, $service, $manager) = $this->getListener(false, true, false);
$tokenStorage
->expects($this->once())

View File

@ -60,7 +60,7 @@ class RemoteUserAuthenticationListenerTest extends TestCase
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
$method->setAccessible(true);
$result = $method->invokeArgs($listener, [$request]);
$method->invokeArgs($listener, [$request]);
}
public function testGetPreAuthenticatedDataWithDifferentKeys()

View File

@ -98,7 +98,7 @@ class X509AuthenticationListenerTest extends TestCase
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
$method->setAccessible(true);
$result = $method->invokeArgs($listener, [$request]);
$method->invokeArgs($listener, [$request]);
}
public function testGetPreAuthenticatedDataWithDifferentKeys()

View File

@ -48,8 +48,6 @@ class FirewallTest extends TestCase
public function testOnKernelRequestStopsWhenThereIsAResponse()
{
$response = new Response();
$first = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock();
$first
->expects($this->once())

View File

@ -65,8 +65,6 @@ class ResponseListenerTest extends TestCase
public function testItSubscribesToTheOnKernelResponseEvent()
{
$listener = new ResponseListener();
$this->assertSame([KernelEvents::RESPONSE => 'onKernelResponse'], ResponseListener::getSubscribedEvents());
}

View File

@ -27,7 +27,6 @@ class FilesystemLoaderTest extends TestCase
public function testConstructor()
{
$pathPattern = self::$fixturesPath.'/templates/%name%.%engine%';
$path = self::$fixturesPath.'/templates';
$loader = new ProjectTemplateLoader2($pathPattern);
$this->assertEquals([$pathPattern], $loader->getTemplatePathPatterns(), '__construct() takes a path as its second argument');
$loader = new ProjectTemplateLoader2([$pathPattern]);

View File

@ -60,7 +60,7 @@ class FileValidator extends ConstraintValidator
$binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
}
list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);
list(, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);
$this->context->buildViolation($constraint->uploadIniSizeErrorMessage)
->setParameter('{{ limit }}', $limitAsString)
->setParameter('{{ suffix }}', $suffix)

View File

@ -450,7 +450,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
$method = $reflection->getMethod('factorizeSizes');
$method->setAccessible(true);
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), [0, UploadedFile::getMaxFilesize(), false]);
list(, $limit, $suffix) = $method->invokeArgs(new FileValidator(), [0, UploadedFile::getMaxFilesize(), false]);
// it correctly parses the maxSize option and not only uses simple string comparison
// 1000M should be bigger than the ini value

View File

@ -11,7 +11,7 @@ class DefinitionBuilderTest extends TestCase
public function testAddPlaceInvalidName()
{
$this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
$builder = new DefinitionBuilder(['a"', 'b']);
new DefinitionBuilder(['a"', 'b']);
}
public function testSetInitialPlace()

View File

@ -22,7 +22,7 @@ class DefinitionTest extends TestCase
{
$this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
$places = ['a"', 'e"'];
$definition = new Definition($places, []);
new Definition($places, []);
}
public function testSetInitialPlace()
@ -37,7 +37,7 @@ class DefinitionTest extends TestCase
{
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
$this->expectExceptionMessage('Place "d" cannot be the initial place as it does not exist.');
$definition = new Definition([], [], 'd');
new Definition([], [], 'd');
}
public function testAddTransition()

View File

@ -11,7 +11,7 @@ class TransitionTest extends TestCase
{
$this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The transition "foo.bar" contains invalid characters.');
$transition = new Transition('foo.bar', 'a', 'b');
new Transition('foo.bar', 'a', 'b');
}
public function testConstructor()

View File

@ -219,7 +219,7 @@ class WorkflowTest extends TestCase
$this->assertFalse($marking->has('b'));
$this->assertFalse($marking->has('c'));
$marking = $workflow->apply($subject, 'a_to_bc');
$workflow->apply($subject, 'a_to_bc');
$marking = $workflow->apply($subject, 'b_to_c');
$this->assertFalse($marking->has('a'));
@ -291,7 +291,7 @@ class WorkflowTest extends TestCase
'workflow.workflow_name.announce.t2',
];
$marking = $workflow->apply($subject, 't1');
$workflow->apply($subject, 't1');
$this->assertSame($eventNameExpected, $eventDispatcher->dispatchedEvents);
}
@ -330,7 +330,7 @@ class WorkflowTest extends TestCase
'workflow.workflow_name.announce',
];
$marking = $workflow->apply($subject, 'a-b');
$workflow->apply($subject, 'a-b');
$this->assertSame($eventNameExpected, $eventDispatcher->dispatchedEvents);
}

View File

@ -85,7 +85,7 @@ YAML;
$filename = $this->createFile('');
unlink($filename);
$ret = $tester->execute(['filename' => $filename], ['decorated' => false]);
$tester->execute(['filename' => $filename], ['decorated' => false]);
}
/**

View File

@ -110,7 +110,7 @@ class ParserTest extends TestCase
foreach ($yamls as $yaml) {
try {
$content = $this->parser->parse($yaml);
$this->parser->parse($yaml);
$this->fail('YAML files must not contain tabs');
} catch (\Exception $e) {