Skip to content

Use strict assertSame instead of assertEquals in Asset component tests #35793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testGetBasePathSet()

$requestStackContext = new RequestStackContext($requestStack);

$this->assertEquals($testBasePath, $requestStackContext->getBasePath());
$this->assertSame($testBasePath, $requestStackContext->getBasePath());
}

public function testIsSecureFalse()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Asset/Tests/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PackageTest extends TestCase
public function testGetUrl($version, $format, $path, $expected)
{
$package = new Package($version ? new StaticVersionStrategy($version, $format) : new EmptyVersionStrategy());
$this->assertEquals($expected, $package->getUrl($path));
$this->assertSame($expected, $package->getUrl($path));
}

public function getConfigs()
Expand All @@ -50,6 +50,6 @@ public function getConfigs()
public function testGetVersion()
{
$package = new Package(new StaticVersionStrategy('v1'));
$this->assertEquals('v1', $package->getVersion('/foo'));
$this->assertSame('v1', $package->getVersion('/foo'));
}
}
16 changes: 8 additions & 8 deletions src/Symfony/Component/Asset/Tests/PackagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public function testGetterSetters()
$packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());
$packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock());

$this->assertEquals($default, $packages->getPackage());
$this->assertEquals($a, $packages->getPackage('a'));
$this->assertSame($default, $packages->getPackage());
$this->assertSame($a, $packages->getPackage('a'));

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

$this->assertEquals($default, $packages->getPackage());
$this->assertEquals($a, $packages->getPackage('a'));
$this->assertSame($default, $packages->getPackage());
$this->assertSame($a, $packages->getPackage('a'));
}

public function testGetVersion()
Expand All @@ -40,8 +40,8 @@ public function testGetVersion()
['a' => new Package(new StaticVersionStrategy('a'))]
);

$this->assertEquals('default', $packages->getVersion('/foo'));
$this->assertEquals('a', $packages->getVersion('/foo', 'a'));
$this->assertSame('default', $packages->getVersion('/foo'));
$this->assertSame('a', $packages->getVersion('/foo', 'a'));
}

public function testGetUrl()
Expand All @@ -51,8 +51,8 @@ public function testGetUrl()
['a' => new Package(new StaticVersionStrategy('a'))]
);

$this->assertEquals('/foo?default', $packages->getUrl('/foo'));
$this->assertEquals('/foo?a', $packages->getUrl('/foo', 'a'));
$this->assertSame('/foo?default', $packages->getUrl('/foo'));
$this->assertSame('/foo?a', $packages->getUrl('/foo', 'a'));
}

public function testNoDefaultPackage()
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Asset/Tests/PathPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PathPackageTest extends TestCase
public function testGetUrl($basePath, $format, $path, $expected)
{
$package = new PathPackage($basePath, new StaticVersionStrategy('v1', $format));
$this->assertEquals($expected, $package->getUrl($path));
$this->assertSame($expected, $package->getUrl($path));
}

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

$this->assertEquals($expected, $package->getUrl($path));
$this->assertSame($expected, $package->getUrl($path));
}

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

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

private function getContext($basePath)
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Asset/Tests/UrlPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UrlPackageTest extends TestCase
public function testGetUrl($baseUrls, $format, $path, $expected)
{
$package = new UrlPackage($baseUrls, new StaticVersionStrategy('v1', $format));
$this->assertEquals($expected, $package->getUrl($path));
$this->assertSame($expected, $package->getUrl($path));
}

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

$this->assertEquals($expected, $package->getUrl($path));
$this->assertSame($expected, $package->getUrl($path));
}

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

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

public function testNoBaseUrls()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function testApplyVersion()
$emptyVersionStrategy = new EmptyVersionStrategy();
$path = 'test-path';

$this->assertEquals($path, $emptyVersionStrategy->applyVersion($path));
$this->assertSame($path, $emptyVersionStrategy->applyVersion($path));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public function testGetVersion()
{
$strategy = $this->createStrategy('manifest-valid.json');

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

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

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

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

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

public function testMissingManifestFileThrowsException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testGetVersion()
$version = 'v1';
$path = 'test-path';
$staticVersionStrategy = new StaticVersionStrategy($version);
$this->assertEquals($version, $staticVersionStrategy->getVersion($path));
$this->assertSame($version, $staticVersionStrategy->getVersion($path));
}

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

public function getConfigs()
Expand Down