Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e77ff45

Browse files
committed
minor #37592 [SCA] Minor fixes on tests (fancyweb)
This PR was merged into the 3.4 branch. Discussion ---------- [SCA] Minor fixes on tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - I mainly fixed misordered arguments in `assertEquals()`. Commits ------- b352ff0 [SCA] Minor fixes on tests
2 parents a397c49 + b352ff0 commit e77ff45

File tree

16 files changed

+50
-47
lines changed

16 files changed

+50
-47
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testEncodeNoPasswordNoInteraction()
5050
], ['interactive' => false]);
5151

5252
$this->assertStringContainsString('[ERROR] The password must not be empty.', $this->passwordEncoderCommandTester->getDisplay());
53-
$this->assertEquals($statusCode, 1);
53+
$this->assertEquals(1, $statusCode);
5454
}
5555

5656
public function testEncodePasswordBcrypt()

src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ public function testPreviousError()
147147

148148
$flattened = FlattenException::create($exception)->getPrevious();
149149

150-
$this->assertEquals($flattened->getMessage(), 'Parse error: Oh noes!', 'The message is copied from the original exception.');
151-
$this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.');
152-
$this->assertEquals($flattened->getClass(), 'Symfony\Component\Debug\Exception\FatalThrowableError', 'The class is set to the class of the original exception');
150+
$this->assertEquals('Parse error: Oh noes!', $flattened->getMessage(), 'The message is copied from the original exception.');
151+
$this->assertEquals(42, $flattened->getCode(), 'The code is copied from the original exception.');
152+
$this->assertEquals('Symfony\Component\Debug\Exception\FatalThrowableError', $flattened->getClass(), 'The class is set to the class of the original exception');
153153
}
154154

155155
/**
@@ -259,7 +259,7 @@ function () {},
259259
$this->assertSame(['float', INF], $array[$i++]);
260260

261261
// assertEquals() does not like NAN values.
262-
$this->assertEquals($array[$i][0], 'float');
262+
$this->assertEquals('float', $array[$i][0]);
263263
$this->assertNan($array[$i][1]);
264264
}
265265

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,12 +846,12 @@ public function testfindTaggedServiceIds()
846846
->addTag('bar', ['bar' => 'bar'])
847847
->addTag('foo', ['foofoo' => 'foofoo'])
848848
;
849-
$this->assertEquals($builder->findTaggedServiceIds('foo'), [
849+
$this->assertEquals([
850850
'foo' => [
851851
['foo' => 'foo'],
852852
['foofoo' => 'foofoo'],
853853
],
854-
], '->findTaggedServiceIds() returns an array of service ids and its tag attributes');
854+
], $builder->findTaggedServiceIds('foo'), '->findTaggedServiceIds() returns an array of service ids and its tag attributes');
855855
$this->assertEquals([], $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services');
856856
}
857857

src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ public function testTags()
224224
$def->addTag('foo', ['foo' => 'bar']);
225225
$this->assertEquals([[], ['foo' => 'bar']], $def->getTag('foo'), '->addTag() can adds the same tag several times');
226226
$def->addTag('bar', ['bar' => 'bar']);
227-
$this->assertEquals($def->getTags(), [
227+
$this->assertEquals([
228228
'foo' => [[], ['foo' => 'bar']],
229229
'bar' => [['bar' => 'bar']],
230-
], '->getTags() returns all tags');
230+
], $def->getTags(), '->getTags() returns all tags');
231231
}
232232

233233
public function testSetArgument()

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,28 @@ public function testMultiValuedFields()
170170
');
171171

172172
$this->assertEquals(
173-
array_keys($form->all()),
174-
['foo[2]', 'foo[3]', 'bar[foo][0]', 'bar[foo][foobar]']
173+
['foo[2]', 'foo[3]', 'bar[foo][0]', 'bar[foo][foobar]'],
174+
array_keys($form->all())
175175
);
176176

177-
$this->assertEquals($form->get('foo[2]')->getValue(), 'foo');
178-
$this->assertEquals($form->get('foo[3]')->getValue(), 'foo');
179-
$this->assertEquals($form->get('bar[foo][0]')->getValue(), 'foo');
180-
$this->assertEquals($form->get('bar[foo][foobar]')->getValue(), 'foo');
177+
$this->assertEquals('foo', $form->get('foo[2]')->getValue());
178+
$this->assertEquals('foo', $form->get('foo[3]')->getValue());
179+
$this->assertEquals('foo', $form->get('bar[foo][0]')->getValue());
180+
$this->assertEquals('foo', $form->get('bar[foo][foobar]')->getValue());
181181

182182
$form['foo[2]'] = 'bar';
183183
$form['foo[3]'] = 'bar';
184184

185-
$this->assertEquals($form->get('foo[2]')->getValue(), 'bar');
186-
$this->assertEquals($form->get('foo[3]')->getValue(), 'bar');
185+
$this->assertEquals('bar', $form->get('foo[2]')->getValue());
186+
$this->assertEquals('bar', $form->get('foo[3]')->getValue());
187187

188188
$form['bar'] = ['foo' => ['0' => 'bar', 'foobar' => 'foobar']];
189189

190-
$this->assertEquals($form->get('bar[foo][0]')->getValue(), 'bar');
191-
$this->assertEquals($form->get('bar[foo][foobar]')->getValue(), 'foobar');
190+
$this->assertEquals('bar', $form->get('bar[foo][0]')->getValue());
191+
$this->assertEquals(
192+
'foobar',
193+
$form->get('bar[foo][foobar]')->getValue()
194+
);
192195
}
193196

194197
/**
@@ -967,7 +970,7 @@ public function testGetPhpValuesWithEmptyTextarea()
967970

968971
$nodes = $dom->getElementsByTagName('form');
969972
$form = new Form($nodes->item(0), 'http://example.com');
970-
$this->assertEquals($form->getPhpValues(), ['example' => '']);
973+
$this->assertEquals(['example' => ''], $form->getPhpValues());
971974
}
972975

973976
public function testGetReturnTypes()

src/Symfony/Component/ExpressionLanguage/Tests/ParserCache/ParserCacheAdapterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function testGetItem()
3838

3939
$cacheItem = $parserCacheAdapter->getItem($key);
4040

41-
$this->assertEquals($cacheItem->get(), $value);
42-
$this->assertEquals($cacheItem->isHit(), true);
41+
$this->assertEquals($value, $cacheItem->get());
42+
$this->assertTrue($cacheItem->isHit());
4343
}
4444

4545
public function testSave()

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,20 +592,20 @@ public function testSetCache()
592592

593593
$options = ['etag' => '"whatever"'];
594594
$response->setCache($options);
595-
$this->assertEquals($response->getEtag(), '"whatever"');
595+
$this->assertEquals('"whatever"', $response->getEtag());
596596

597597
$now = $this->createDateTimeNow();
598598
$options = ['last_modified' => $now];
599599
$response->setCache($options);
600-
$this->assertEquals($response->getLastModified()->getTimestamp(), $now->getTimestamp());
600+
$this->assertEquals($now->getTimestamp(), $response->getLastModified()->getTimestamp());
601601

602602
$options = ['max_age' => 100];
603603
$response->setCache($options);
604-
$this->assertEquals($response->getMaxAge(), 100);
604+
$this->assertEquals(100, $response->getMaxAge());
605605

606606
$options = ['s_maxage' => 200];
607607
$response->setCache($options);
608-
$this->assertEquals($response->getMaxAge(), 200);
608+
$this->assertEquals(200, $response->getMaxAge());
609609

610610
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
611611
$this->assertFalse($response->headers->hasCacheControlDirective('private'));

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testRead()
102102
->method('findOne')
103103
->willReturnCallback(function ($criteria) use ($testTimeout) {
104104
$this->assertArrayHasKey($this->options['id_field'], $criteria);
105-
$this->assertEquals($criteria[$this->options['id_field']], 'foo');
105+
$this->assertEquals('foo', $criteria[$this->options['id_field']]);
106106

107107
$this->assertArrayHasKey($this->options['expiry_field'], $criteria);
108108
$this->assertArrayHasKey('$gte', $criteria[$this->options['expiry_field']]);

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ public function testClear()
8787
$_SESSION['drak'] = 'loves symfony';
8888
$storage->getBag('attributes')->set('symfony', 'greatness');
8989
$key = $storage->getBag('attributes')->getStorageKey();
90-
$this->assertEquals($_SESSION[$key], ['symfony' => 'greatness']);
91-
$this->assertEquals($_SESSION['drak'], 'loves symfony');
90+
$this->assertEquals(['symfony' => 'greatness'], $_SESSION[$key]);
91+
$this->assertEquals('loves symfony', $_SESSION['drak']);
9292
$storage->clear();
93-
$this->assertEquals($_SESSION[$key], []);
94-
$this->assertEquals($_SESSION['drak'], 'loves symfony');
93+
$this->assertEquals([], $_SESSION[$key]);
94+
$this->assertEquals('loves symfony', $_SESSION['drak']);
9595
}
9696
}

src/Symfony/Component/HttpKernel/Tests/Event/FilterControllerArgumentsEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class FilterControllerArgumentsEventTest extends TestCase
1212
public function testFilterControllerArgumentsEvent()
1313
{
1414
$filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1);
15-
$this->assertEquals($filterController->getArguments(), ['test']);
15+
$this->assertEquals(['test'], $filterController->getArguments());
1616
}
1717
}

0 commit comments

Comments
 (0)