Skip to content

Commit 8308710

Browse files
authored
Merge pull request #669 from cakephp/3.2-php-8.4
Fix test on PHP 8.4
2 parents 55330b5 + 09aae2c commit 8308710

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tests/TestCase/Authenticator/CookieAuthenticatorTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,12 @@ public function testPersistIdentity()
301301
$this->assertArrayHasKey('response', $result);
302302
$this->assertInstanceOf(RequestInterface::class, $result['request']);
303303
$this->assertInstanceOf(ResponseInterface::class, $result['response']);
304+
$hashCost = '10';
305+
if (PHP_VERSION_ID >= 80400) {
306+
$hashCost = '12';
307+
}
304308
$this->assertStringContainsString(
305-
'CookieAuth=%5B%22mariano%22%2C%22%242y%2410%24', // `CookieAuth=["mariano","$2y$10$`
309+
'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24', // `CookieAuth=["mariano","$2y$10$`
306310
$result['response']->getHeaderLine('Set-Cookie')
307311
);
308312
$this->assertStringContainsString(
@@ -333,7 +337,7 @@ public function testPersistIdentity()
333337
]);
334338
$result = $authenticator->persistIdentity($request, $response, $identity);
335339
$this->assertStringContainsString(
336-
'CookieAuth=%5B%22mariano%22%2C%22%242y%2410%24',
340+
'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24',
337341
$result['response']->getHeaderLine('Set-Cookie')
338342
);
339343
}

tests/TestCase/PasswordHasher/LegacyPasswordHasherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public function testNeedsRehash()
4747
$hasher = new LegacyPasswordHasher();
4848
$this->assertTrue($hasher->needsRehash(md5('foo')));
4949
$this->assertTrue($hasher->needsRehash('bar'));
50-
$this->assertFalse($hasher->needsRehash('$2y$10$juOA0XVFpvZa0KTxRxEYVuX5kIS7U1fKDRcxyYhhUQECN1oHYnBMy'));
50+
$hashCost = '10';
51+
if (PHP_VERSION_ID >= 80400) {
52+
$hashCost = '12';
53+
}
54+
$this->assertFalse($hasher->needsRehash('$2y$' . $hashCost . '$juOA0XVFpvZa0KTxRxEYVuX5kIS7U1fKDRcxyYhhUQECN1oHYnBMy'));
5155
}
5256

5357
/**

0 commit comments

Comments
 (0)