Skip to content

Commit

Permalink
Merge pull request #669 from cakephp/3.2-php-8.4
Browse files Browse the repository at this point in the history
Fix test on PHP 8.4
  • Loading branch information
ADmad authored Jul 25, 2024
2 parents 55330b5 + 09aae2c commit 8308710
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tests/TestCase/Authenticator/CookieAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,12 @@ public function testPersistIdentity()
$this->assertArrayHasKey('response', $result);
$this->assertInstanceOf(RequestInterface::class, $result['request']);
$this->assertInstanceOf(ResponseInterface::class, $result['response']);
$hashCost = '10';
if (PHP_VERSION_ID >= 80400) {
$hashCost = '12';
}
$this->assertStringContainsString(
'CookieAuth=%5B%22mariano%22%2C%22%242y%2410%24', // `CookieAuth=["mariano","$2y$10$`
'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24', // `CookieAuth=["mariano","$2y$10$`
$result['response']->getHeaderLine('Set-Cookie')
);
$this->assertStringContainsString(
Expand Down Expand Up @@ -333,7 +337,7 @@ public function testPersistIdentity()
]);
$result = $authenticator->persistIdentity($request, $response, $identity);
$this->assertStringContainsString(
'CookieAuth=%5B%22mariano%22%2C%22%242y%2410%24',
'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24',
$result['response']->getHeaderLine('Set-Cookie')
);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/PasswordHasher/LegacyPasswordHasherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public function testNeedsRehash()
$hasher = new LegacyPasswordHasher();
$this->assertTrue($hasher->needsRehash(md5('foo')));
$this->assertTrue($hasher->needsRehash('bar'));
$this->assertFalse($hasher->needsRehash('$2y$10$juOA0XVFpvZa0KTxRxEYVuX5kIS7U1fKDRcxyYhhUQECN1oHYnBMy'));
$hashCost = '10';
if (PHP_VERSION_ID >= 80400) {
$hashCost = '12';
}
$this->assertFalse($hasher->needsRehash('$2y$' . $hashCost . '$juOA0XVFpvZa0KTxRxEYVuX5kIS7U1fKDRcxyYhhUQECN1oHYnBMy'));
}

/**
Expand Down

0 comments on commit 8308710

Please sign in to comment.