Skip to content

Commit 0ae5e40

Browse files
authored
Fix inconsistencies across assertion traits (#229)
1 parent 223867b commit 0ae5e40

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/Codeception/Module/Symfony.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,10 @@ protected function debugResponse(mixed $url): void
389389
return;
390390
}
391391

392-
$this->debugCollector($profile, DataCollectorName::SECURITY->value);
393-
$this->debugCollector($profile, DataCollectorName::MAILER->value);
394-
$this->debugCollector($profile, DataCollectorName::NOTIFIER->value);
395-
$this->debugCollector($profile, DataCollectorName::TIME->value);
392+
$this->debugCollector($profile, DataCollectorName::SECURITY);
393+
$this->debugCollector($profile, DataCollectorName::MAILER);
394+
$this->debugCollector($profile, DataCollectorName::NOTIFIER);
395+
$this->debugCollector($profile, DataCollectorName::TIME);
396396
}
397397

398398
protected function doRebootClientKernel(): void
@@ -463,13 +463,13 @@ private function debugTimeData(TimeDataCollector $timeCollector): void
463463
$this->debugSection('Time', sprintf('%.2f ms', $timeCollector->getDuration()));
464464
}
465465

466-
private function debugCollector(Profile $profile, string $name): void
466+
private function debugCollector(Profile $profile, DataCollectorName $name): void
467467
{
468-
if (!$profile->hasCollector($name)) {
468+
if (!$profile->hasCollector($name->value)) {
469469
return;
470470
}
471471

472-
$collector = $profile->getCollector($name);
472+
$collector = $profile->getCollector($name->value);
473473
match (true) {
474474
$collector instanceof SecurityDataCollector => $this->debugSecurityData($collector),
475475
$collector instanceof MessageDataCollector => $this->debugMailerData($collector),

src/Codeception/Module/Symfony/SessionAssertionsTrait.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
use function class_exists;
2222
use function get_debug_type;
23-
use function in_array;
2423
use function is_int;
2524
use function is_string;
2625
use function serialize;
@@ -125,8 +124,9 @@ public function logoutProgrammatically(): void
125124

126125
$cookieJar = $this->getClient()->getCookieJar();
127126
foreach ($cookieJar->all() as $cookie) {
128-
if (in_array($cookie->getName(), ['MOCKSESSID', 'REMEMBERME', $sessionName], true)) {
129-
$cookieJar->expire($cookie->getName());
127+
$cookieName = $cookie->getName();
128+
if ($cookieName === 'MOCKSESSID' || $cookieName === 'REMEMBERME' || $cookieName === $sessionName) {
129+
$cookieJar->expire($cookieName);
130130
}
131131
}
132132
$cookieJar->flushExpiredCookies();
@@ -164,15 +164,18 @@ public function seeInSession(string $attribute, mixed $value = null): void
164164
*/
165165
public function seeSessionHasValues(array $bindings): void
166166
{
167+
$session = $this->getCurrentSession();
168+
167169
foreach ($bindings as $key => $value) {
168170
if (!is_int($key)) {
169-
$this->seeInSession($key, $value);
171+
$this->assertTrue($session->has($key), "No session attribute with name '{$key}'");
172+
$this->assertSame($value, $session->get($key));
170173
continue;
171174
}
172175
if (!is_string($value)) {
173176
throw new InvalidArgumentException(sprintf('Attribute name must be string, %s given.', get_debug_type($value)));
174177
}
175-
$this->seeInSession($value);
178+
$this->assertTrue($session->has($value), "No session attribute with name '{$value}'");
176179
}
177180
}
178181

0 commit comments

Comments
 (0)