Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b1e4ea

Browse filesBrowse files
minor #35793 Use strict assertSame instead of assertEquals in Asset component tests (GromNaN)
This PR was merged into the 3.4 branch. Discussion ---------- Use strict assertSame instead of assertEquals in Asset component tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #35762 (comment) | License | MIT | Doc PR | N/A Using `assertSame` instead of `assertEquals` is recommended when possible (see sebastianbergmann/phpunit-documentation-english#3). It is stricter and must be more efficient ([`===`](https://github.com/sebastianbergmann/phpunit/blob/8.5.2/src/Framework/Constraint/IsIdentical.php#L63) vs a [comparator class](https://github.com/sebastianbergmann/phpunit/blob/8.5.2/src/Framework/Constraint/IsEqual.php#L79)). ~~Also, removing useless string cast.~~ Commits ------- e8f3e84 Use strict assertion in asset tests
2 parents aa3637d + e8f3e84 commit 7b1e4ea
Copy full SHA for 7b1e4ea

8 files changed

+23
-23
lines changed

‎src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testGetBasePathSet()
3737

3838
$requestStackContext = new RequestStackContext($requestStack);
3939

40-
$this->assertEquals($testBasePath, $requestStackContext->getBasePath());
40+
$this->assertSame($testBasePath, $requestStackContext->getBasePath());
4141
}
4242

4343
public function testIsSecureFalse()

‎src/Symfony/Component/Asset/Tests/PackageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/PackageTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class PackageTest extends TestCase
2424
public function testGetUrl($version, $format, $path, $expected)
2525
{
2626
$package = new Package($version ? new StaticVersionStrategy($version, $format) : new EmptyVersionStrategy());
27-
$this->assertEquals($expected, $package->getUrl($path));
27+
$this->assertSame($expected, $package->getUrl($path));
2828
}
2929

3030
public function getConfigs()
@@ -50,6 +50,6 @@ public function getConfigs()
5050
public function testGetVersion()
5151
{
5252
$package = new Package(new StaticVersionStrategy('v1'));
53-
$this->assertEquals('v1', $package->getVersion('/foo'));
53+
$this->assertSame('v1', $package->getVersion('/foo'));
5454
}
5555
}

‎src/Symfony/Component/Asset/Tests/PackagesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/PackagesTest.php
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public function testGetterSetters()
2424
$packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
2525
$packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
2626

27-
$this->assertEquals($default, $packages->getPackage());
28-
$this->assertEquals($a, $packages->getPackage('a'));
27+
$this->assertSame($default, $packages->getPackage());
28+
$this->assertSame($a, $packages->getPackage('a'));
2929

3030
$packages = new Packages($default, ['a' => $a]);
3131

32-
$this->assertEquals($default, $packages->getPackage());
33-
$this->assertEquals($a, $packages->getPackage('a'));
32+
$this->assertSame($default, $packages->getPackage());
33+
$this->assertSame($a, $packages->getPackage('a'));
3434
}
3535

3636
public function testGetVersion()
@@ -40,8 +40,8 @@ public function testGetVersion()
4040
['a' => new Package(new StaticVersionStrategy('a'))]
4141
);
4242

43-
$this->assertEquals('default', $packages->getVersion('/foo'));
44-
$this->assertEquals('a', $packages->getVersion('/foo', 'a'));
43+
$this->assertSame('default', $packages->getVersion('/foo'));
44+
$this->assertSame('a', $packages->getVersion('/foo', 'a'));
4545
}
4646

4747
public function testGetUrl()
@@ -51,8 +51,8 @@ public function testGetUrl()
5151
['a' => new Package(new StaticVersionStrategy('a'))]
5252
);
5353

54-
$this->assertEquals('/foo?default', $packages->getUrl('/foo'));
55-
$this->assertEquals('/foo?a', $packages->getUrl('/foo', 'a'));
54+
$this->assertSame('/foo?default', $packages->getUrl('/foo'));
55+
$this->assertSame('/foo?a', $packages->getUrl('/foo', 'a'));
5656
}
5757

5858
public function testNoDefaultPackage()

‎src/Symfony/Component/Asset/Tests/PathPackageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/PathPackageTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PathPackageTest extends TestCase
2323
public function testGetUrl($basePath, $format, $path, $expected)
2424
{
2525
$package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format));
26-
$this->assertEquals($expected, $package->getUrl($path));
26+
$this->assertSame($expected, $package->getUrl($path));
2727
}
2828

2929
public function getConfigs()
@@ -55,7 +55,7 @@ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $pat
5555
{
5656
$package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format), $this->getContext($basePathRequest));
5757

58-
$this->assertEquals($expected, $package->getUrl($path));
58+
$this->assertSame($expected, $package->getUrl($path));
5959
}
6060

6161
public function getContextConfigs()
@@ -83,7 +83,7 @@ public function testVersionStrategyGivesAbsoluteURL()
8383
->willReturn('https://cdn.com/bar/main.css');
8484
$package = new PathPackage('/subdirectory', $versionStrategy, $this->getContext('/bar'));
8585

86-
$this->assertEquals('https://cdn.com/bar/main.css', $package->getUrl('main.css'));
86+
$this->assertSame('https://cdn.com/bar/main.css', $package->getUrl('main.css'));
8787
}
8888

8989
private function getContext($basePath)

‎src/Symfony/Component/Asset/Tests/UrlPackageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/UrlPackageTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UrlPackageTest extends TestCase
2424
public function testGetUrl($baseUrls, $format, $path, $expected)
2525
{
2626
$package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format));
27-
$this->assertEquals($expected, $package->getUrl($path));
27+
$this->assertSame($expected, $package->getUrl($path));
2828
}
2929

3030
public function getConfigs()
@@ -58,7 +58,7 @@ public function testGetUrlWithContext($secure, $baseUrls, $format, $path, $expec
5858
{
5959
$package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format), $this->getContext($secure));
6060

61-
$this->assertEquals($expected, $package->getUrl($path));
61+
$this->assertSame($expected, $package->getUrl($path));
6262
}
6363

6464
public function getContextConfigs()
@@ -85,7 +85,7 @@ public function testVersionStrategyGivesAbsoluteURL()
8585
->willReturn('https://cdn.com/bar/main.css');
8686
$package = new UrlPackage('https://example.com', $versionStrategy);
8787

88-
$this->assertEquals('https://cdn.com/bar/main.css', $package->getUrl('main.css'));
88+
$this->assertSame('https://cdn.com/bar/main.css', $package->getUrl('main.css'));
8989
}
9090

9191
public function testNoBaseUrls()

‎src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/VersionStrategy/EmptyVersionStrategyTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function testApplyVersion()
2929
$emptyVersionStrategy = new EmptyVersionStrategy();
3030
$path = 'test-path';
3131

32-
$this->assertEquals($path, $emptyVersionStrategy->applyVersion($path));
32+
$this->assertSame($path, $emptyVersionStrategy->applyVersion($path));
3333
}
3434
}

‎src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public function testGetVersion()
2020
{
2121
$strategy = $this->createStrategy('manifest-valid.json');
2222

23-
$this->assertEquals('main.123abc.js', $strategy->getVersion('main.js'));
23+
$this->assertSame('main.123abc.js', $strategy->getVersion('main.js'));
2424
}
2525

2626
public function testApplyVersion()
2727
{
2828
$strategy = $this->createStrategy('manifest-valid.json');
2929

30-
$this->assertEquals('css/styles.555def.css', $strategy->getVersion('css/styles.css'));
30+
$this->assertSame('css/styles.555def.css', $strategy->getVersion('css/styles.css'));
3131
}
3232

3333
public function testApplyVersionWhenKeyDoesNotExistInManifest()
3434
{
3535
$strategy = $this->createStrategy('manifest-valid.json');
3636

37-
$this->assertEquals('css/other.css', $strategy->getVersion('css/other.css'));
37+
$this->assertSame('css/other.css', $strategy->getVersion('css/other.css'));
3838
}
3939

4040
public function testMissingManifestFileThrowsException()

‎src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testGetVersion()
2121
$version = 'v1';
2222
$path = 'test-path';
2323
$staticVersionStrategy = new StaticVersionStrategy($version);
24-
$this->assertEquals($version, $staticVersionStrategy->getVersion($path));
24+
$this->assertSame($version, $staticVersionStrategy->getVersion($path));
2525
}
2626

2727
/**
@@ -31,7 +31,7 @@ public function testApplyVersion($path, $version, $format)
3131
{
3232
$staticVersionStrategy = new StaticVersionStrategy($version, $format);
3333
$formatted = sprintf($format ?: '%s?%s', $path, $version);
34-
$this->assertEquals($formatted, $staticVersionStrategy->applyVersion($path));
34+
$this->assertSame($formatted, $staticVersionStrategy->applyVersion($path));
3535
}
3636

3737
public function getConfigs()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.