Skip to content

Use AssertSame instead of AssertEquals #113

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 4, 2021
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
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function runSymfonyConsoleCommand(string $command, array $parameters = []
$exitCode = $commandTester->execute($parameters);
$output = $commandTester->getDisplay();

$this->assertEquals(
$this->assertSame(
$expectedExitCode,
$exitCode,
'Command did not exit with code '.$expectedExitCode
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function seeNumRecords(int $expectedNum, string $className, array $criter
{
$currentNum = $this->grabNumRecords($className, $criteria);

$this->assertEquals(
$this->assertSame(
$expectedNum,
$currentNum,
sprintf(
Expand Down
6 changes: 4 additions & 2 deletions src/Codeception/Module/Symfony/FormAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public function dontSeeFormErrors(): void
{
$formCollector = $this->grabFormCollector(__FUNCTION__);

$this->assertEquals(
$errors = (int) $formCollector->getData()->offsetGet('nb_errors');

$this->assertSame(
0,
$formCollector->getData()->offsetGet('nb_errors'),
$errors,
'Expecting that the form does not have errors, but there were!'
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Codeception/Module/Symfony/RouterAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function seeCurrentRouteIs(string $routeName, array $params = []): void
$expected = array_merge(['_route' => $routeName], $params);
$intersection = array_intersect_assoc($expected, $match);

$this->assertEquals($expected, $intersection);
$this->assertSame($expected, $intersection);
}

/**
Expand All @@ -163,12 +163,12 @@ public function seeInCurrentRoute(string $routeName): void

$uri = explode('?', $this->grabFromCurrentUrl())[0];
try {
$matchedRouteName = $router->match($uri)['_route'];
$matchedRouteName = (string) $router->match($uri)['_route'];
} catch (ResourceNotFoundException $e) {
$this->fail(sprintf('The "%s" url does not match with any route', $uri));
}

$this->assertEquals($matchedRouteName, $routeName);
$this->assertSame($matchedRouteName, $routeName);
}

protected function grabRouterService(): RouterInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/SessionAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function dontSeeInSession(string $attribute, $value = null): void
}
}
else {
$this->assertNotEquals($value, $session->get($attribute));
$this->assertNotSame($value, $session->get($attribute));
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public function seeInSession(string $attribute, $value = null): void
}

if (null !== $value) {
$this->assertEquals($value, $session->get($attribute));
$this->assertSame($value, $session->get($attribute));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/TwigAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function seeCurrentTemplateIs(string $expectedTemplate): void
$twigCollector = $this->grabTwigCollector(__FUNCTION__);

$templates = (array) $twigCollector->getTemplates();
$actualTemplate = array_key_first($templates);
$actualTemplate = (string) array_key_first($templates);

$this->assertEquals(
$this->assertSame(
$expectedTemplate,
$actualTemplate,
"Actual template {$actualTemplate} does not match expected template {$expectedTemplate}."
Expand Down