diff --git a/src/Authenticator/CookieAuthenticator.php b/src/Authenticator/CookieAuthenticator.php index 0bf2e8c..9725b6f 100644 --- a/src/Authenticator/CookieAuthenticator.php +++ b/src/Authenticator/CookieAuthenticator.php @@ -14,7 +14,7 @@ use Authentication\UrlChecker\UrlCheckerTrait; use Cake\Datasource\EntityInterface; use Cake\Http\Cookie\Cookie; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\ORM\Locator\LocatorAwareTrait; use Cake\Utility\Hash; use InvalidArgumentException; @@ -188,7 +188,7 @@ protected function _saveToken(ArrayAccess|array $identity, string $token): Entit 'foreign_id' => $identity[$userTable->getPrimaryKey()], 'series' => static::_generateToken($identity), 'token' => $token, - 'expires' => new FrozenTime($this->getConfig('cookie.expire')), + 'expires' => new DateTime($this->getConfig('cookie.expire')), ]); return $tokenTable->saveOrFail($entity); @@ -247,10 +247,10 @@ public function clearIdentity(ServerRequestInterface $request, ResponseInterface * Creates a cookie instance with configured defaults. * * @param string $value Cookie value. - * @param \Cake\I18n\FrozenTime|null $expires the Cookie expire + * @param \Cake\I18n\DateTime|null $expires the Cookie expire * @return \Cake\Http\Cookie\Cookie */ - protected function _createCookie(string $value, ?FrozenTime $expires = null): Cookie + protected function _createCookie(string $value, ?DateTime $expires = null): Cookie { $data = $this->getConfig('cookie'); diff --git a/src/Identifier/RememberMeTokenIdentifier.php b/src/Identifier/RememberMeTokenIdentifier.php index 117e029..8b58d6d 100644 --- a/src/Identifier/RememberMeTokenIdentifier.php +++ b/src/Identifier/RememberMeTokenIdentifier.php @@ -9,7 +9,7 @@ use Authentication\Identifier\Resolver\ResolverAwareTrait; use Authentication\Identifier\Resolver\ResolverInterface; use Cake\Datasource\EntityInterface; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use InvalidArgumentException; use RuntimeException; @@ -158,7 +158,7 @@ protected function _verifyToken(EntityInterface $token, string $verifyToken): bo return false; } - if (FrozenTime::now()->greaterThan($token['expires'])) { + if (DateTime::now()->greaterThan($token['expires'])) { $this->_errors[] = 'token expired'; return false; diff --git a/src/Model/Entity/RememberMeToken.php b/src/Model/Entity/RememberMeToken.php index 21b4efc..4b2ca22 100644 --- a/src/Model/Entity/RememberMeToken.php +++ b/src/Model/Entity/RememberMeToken.php @@ -9,13 +9,13 @@ * RememberMeToken Entity * * @property int $id - * @property \Cake\I18n\FrozenTime $created - * @property \Cake\I18n\FrozenTime $modified + * @property \Cake\I18n\DateTime $created + * @property \Cake\I18n\DateTime $modified * @property string $model * @property string $foreign_id * @property string $series * @property string $token - * @property \Cake\I18n\FrozenTime $expires + * @property \Cake\I18n\DateTime $expires */ class RememberMeToken extends Entity { diff --git a/src/Model/Table/RememberMeTokensTable.php b/src/Model/Table/RememberMeTokensTable.php index a4b65cf..6b11aff 100644 --- a/src/Model/Table/RememberMeTokensTable.php +++ b/src/Model/Table/RememberMeTokensTable.php @@ -3,7 +3,7 @@ namespace RememberMe\Model\Table; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\ORM\RulesChecker; use Cake\ORM\Table; use Cake\Validation\Validator; @@ -99,7 +99,7 @@ public function buildRules(RulesChecker $rules): RulesChecker public function dropExpired(?string $userModel = null, string|int|null $foreignId = null): int { $conditions = [ - $this->aliasField('expires <') => FrozenTime::now(), + $this->aliasField('expires <') => DateTime::now(), ]; if ($userModel !== null) { $conditions[$this->aliasField('model')] = $userModel; diff --git a/tests/TestCase/Authenticator/CookieAuthenticatorTest.php b/tests/TestCase/Authenticator/CookieAuthenticatorTest.php index b28b737..a7504dd 100644 --- a/tests/TestCase/Authenticator/CookieAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/CookieAuthenticatorTest.php @@ -11,7 +11,7 @@ use Cake\Http\Cookie\CookieInterface; use Cake\Http\Response; use Cake\Http\ServerRequestFactory; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\ORM\Entity; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -39,7 +39,7 @@ public function setUp(): void */ public function tearDown(): void { - FrozenTime::setTestNow(); + DateTime::setTestNow(); parent::tearDown(); } @@ -166,7 +166,7 @@ public function testAuthenticateInvalidCookie(): void */ public function testAuthenticateExpired(): void { - FrozenTime::setTestNow('2017-10-01 11:22:34'); + DateTime::setTestNow('2017-10-01 11:22:34'); $identifiers = new IdentifierCollection([ 'RememberMe.RememberMeToken' => [ 'resolver' => [ @@ -199,7 +199,7 @@ public function testAuthenticateExpired(): void */ public function testAuthenticateValid(): void { - FrozenTime::setTestNow('2017-10-01 11:22:33'); + DateTime::setTestNow('2017-10-01 11:22:33'); $identifiers = new IdentifierCollection([ 'RememberMe.RememberMeToken' => [ 'resolver' => [ diff --git a/tests/TestCase/Identifier/RememberMeTokenIdentifierTest.php b/tests/TestCase/Identifier/RememberMeTokenIdentifierTest.php index dfcd941..3392817 100644 --- a/tests/TestCase/Identifier/RememberMeTokenIdentifierTest.php +++ b/tests/TestCase/Identifier/RememberMeTokenIdentifierTest.php @@ -4,7 +4,7 @@ namespace RememberMe\Test\TestCase\Identifier; use Authentication\Identifier\Resolver\OrmResolver; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\ORM\Entity; use RememberMe\Identifier\RememberMeTokenIdentifier; use RememberMe\Model\Entity\RememberMeToken; @@ -20,7 +20,7 @@ class RememberMeTokenIdentifierTest extends TestCase */ public function tearDown(): void { - FrozenTime::setTestNow(); + DateTime::setTestNow(); parent::tearDown(); } @@ -29,7 +29,7 @@ public function tearDown(): void */ public function testIdentifyValid(): void { - FrozenTime::setTestNow('2017-10-01 11:22:33'); + DateTime::setTestNow('2017-10-01 11:22:33'); $resolver = $this->getMockBuilder(OrmResolver::class) ->disableOriginalConstructor() ->onlyMethods(['find']) @@ -65,7 +65,7 @@ public function testIdentifyValid(): void */ public function testIdentifyNotMatchSeries(): void { - FrozenTime::setTestNow('2017-10-01 11:22:33'); + DateTime::setTestNow('2017-10-01 11:22:33'); $resolver = $this->getMockBuilder(OrmResolver::class) ->disableOriginalConstructor() ->onlyMethods(['find']) @@ -94,7 +94,7 @@ public function testIdentifyNotMatchSeries(): void */ public function testIdentifyNotMatchToken(): void { - FrozenTime::setTestNow('2017-10-01 11:22:33'); + DateTime::setTestNow('2017-10-01 11:22:33'); $resolver = $this->getMockBuilder(OrmResolver::class) ->disableOriginalConstructor() ->onlyMethods(['find']) @@ -123,7 +123,7 @@ public function testIdentifyNotMatchToken(): void */ public function testIdentifyExpired(): void { - FrozenTime::setTestNow('2017-10-01 11:22:34'); + DateTime::setTestNow('2017-10-01 11:22:34'); $resolver = $this->getMockBuilder(OrmResolver::class) ->disableOriginalConstructor() ->onlyMethods(['find']) diff --git a/tests/TestCase/Model/Table/RememberMeTokensTableTest.php b/tests/TestCase/Model/Table/RememberMeTokensTableTest.php index 9efdf31..556b2c3 100644 --- a/tests/TestCase/Model/Table/RememberMeTokensTableTest.php +++ b/tests/TestCase/Model/Table/RememberMeTokensTableTest.php @@ -3,7 +3,7 @@ namespace RememberMe\Test\TestCase\Model\Table; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\TestSuite\TestCase; use RememberMe\Model\Table\RememberMeTokensTable; @@ -85,12 +85,12 @@ public function testBuildRules(): void public function testDropExpired(): void { - FrozenTime::setTestNow('2017-10-01 11:22:33'); + DateTime::setTestNow('2017-10-01 11:22:33'); $deleteCount = $this->RememberMeTokens->dropExpired(); $this->assertSame(0, $deleteCount, 'not change'); $this->assertCount(6, $this->RememberMeTokens->find()->all(), 'not change'); - FrozenTime::setTestNow('2017-10-01 11:22:34'); + DateTime::setTestNow('2017-10-01 11:22:34'); $deleteCount = $this->RememberMeTokens->dropExpired(); $this->assertSame(3, $deleteCount); $this->assertCount(3, $this->RememberMeTokens->find()->all()); @@ -98,7 +98,7 @@ public function testDropExpired(): void public function testDropExpiredWithArgs(): void { - FrozenTime::setTestNow('2017-10-01 11:22:34'); + DateTime::setTestNow('2017-10-01 11:22:34'); $deleteCount = $this->RememberMeTokens->dropExpired('Users'); $this->assertSame(0, $deleteCount, 'not matching'); $this->assertCount(6, $this->RememberMeTokens->find()->all(), 'not matching');