diff --git a/psalm.xml b/psalm.xml index 3bcbd74e4..1de17a837 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,7 +14,6 @@ - diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 68c4951e2..f2a6011c9 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -28,7 +28,7 @@ class AppController extends BaseController public function initialize(): void { parent::initialize(); - $this->loadComponent('Security'); + $this->loadComponent('FormProtection'); if ($this->request->getParam('_csrfToken') === false) { $this->loadComponent('Csrf'); } diff --git a/src/Controller/Traits/PasswordManagementTrait.php b/src/Controller/Traits/PasswordManagementTrait.php index 0e8c186f7..f26361604 100644 --- a/src/Controller/Traits/PasswordManagementTrait.php +++ b/src/Controller/Traits/PasswordManagementTrait.php @@ -209,6 +209,6 @@ public function resetOneTimePasswordAuthenticator($id = null) } } - return $this->redirect($this->getRequest()->referer()); + return $this->redirect($this->getRequest()->referer() ?? '/'); } } diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php index d48f6dc55..13db4d856 100644 --- a/tests/Fixture/UsersFixture.php +++ b/tests/Fixture/UsersFixture.php @@ -64,8 +64,9 @@ public function init(): void 'type' => 'Webauthn\TrustPath\EmptyTrustPath', ], 'aaguid' => '00000000-0000-0000-0000-000000000000', - 'credentialPublicKey' => Base64Url::encode('000000000000000000000000000000000000-9999999999999999999999999999999999999999-XXXXXXXXXXXXX-ZZZZZZZZZZZ'), - 'userHandle' => Base64Url::encode('00000000-0000-0000-0000-000000000001'), + //add this when migrated webauthn +// 'credentialPublicKey' => Base64Url::encode('000000000000000000000000000000000000-9999999999999999999999999999999999999999-XXXXXXXXXXXXX-ZZZZZZZZZZZ'), +// 'userHandle' => Base64Url::encode('00000000-0000-0000-0000-000000000001'), 'counter' => 190, 'otherUI' => null, ], diff --git a/tests/TestCase/Authenticator/SocialAuthenticatorTest.php b/tests/TestCase/Authenticator/SocialAuthenticatorTest.php index d20ba65fc..759a36651 100644 --- a/tests/TestCase/Authenticator/SocialAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/SocialAuthenticatorTest.php @@ -36,7 +36,7 @@ */ class SocialAuthenticatorTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Authenticator/SocialPendingEmailAuthenticatorTest.php b/tests/TestCase/Authenticator/SocialPendingEmailAuthenticatorTest.php index 949153707..3309dcded 100644 --- a/tests/TestCase/Authenticator/SocialPendingEmailAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/SocialPendingEmailAuthenticatorTest.php @@ -25,7 +25,7 @@ class SocialPendingEmailAuthenticatorTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Controller/SocialAccountsControllerTest.php b/tests/TestCase/Controller/SocialAccountsControllerTest.php index 47a544d7e..3677a3cb0 100644 --- a/tests/TestCase/Controller/SocialAccountsControllerTest.php +++ b/tests/TestCase/Controller/SocialAccountsControllerTest.php @@ -15,7 +15,7 @@ use Cake\Core\Configure; use Cake\Http\ServerRequest; -use Cake\Mailer\Email; +use Cake\Mailer\Mailer; use Cake\Mailer\TransportFactory; use Cake\TestSuite\TestCase; @@ -26,7 +26,7 @@ class SocialAccountsControllerTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; @@ -46,9 +46,9 @@ public function setUp(): void Configure::write('Users.RememberMe.active', false); TransportFactory::setConfig('test', ['className' => 'Debug']); - $this->configEmail = Email::getConfig('default'); - Email::drop('default'); - Email::setConfig('default', [ + $this->configEmail = Mailer::getConfig('default'); + Mailer::drop('default'); + Mailer::setConfig('default', [ 'transport' => 'test', 'from' => 'cakedc@example.com', ]); @@ -69,9 +69,9 @@ public function setUp(): void */ public function tearDown(): void { - Email::drop('default'); + Mailer::drop('default'); TransportFactory::drop('test'); - //Email::setConfig('default', $this->configEmail); + //Mailer::setConfig('default', $this->configEmail); Configure::write('Opauth', $this->configOpauth); Configure::write('Users.RememberMe.active', $this->configRememberMe); diff --git a/tests/TestCase/Controller/Traits/BaseTraitTest.php b/tests/TestCase/Controller/Traits/BaseTraitTest.php index 693940e8a..0c7bdad5a 100644 --- a/tests/TestCase/Controller/Traits/BaseTraitTest.php +++ b/tests/TestCase/Controller/Traits/BaseTraitTest.php @@ -21,7 +21,8 @@ use Cake\Controller\ComponentRegistry; use Cake\Controller\Controller; use Cake\Event\Event; -use Cake\Mailer\Email; +use Cake\Http\ServerRequest; +use Cake\Mailer\Mailer; use Cake\Mailer\TransportFactory; use Cake\ORM\Entity; use Cake\ORM\TableRegistry; @@ -42,7 +43,7 @@ abstract class BaseTraitTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; @@ -85,6 +86,7 @@ public function setUp(): void try { $this->Trait = $this->getMockBuilder($this->traitClassName) ->setMethods($traitMockMethods) + ->setConstructorArgs([new ServerRequest()]) ->getMock(); $this->Trait->expects($this->any()) ->method('getUsersTable') @@ -98,9 +100,9 @@ public function setUp(): void TransportFactory::setConfig('test', [ 'className' => 'Debug', ]); - $this->configEmail = Email::getConfig('default'); - Email::drop('default'); - Email::setConfig('default', [ + $this->configEmail = Mailer::getConfig('default'); + Mailer::drop('default'); + Mailer::setConfig('default', [ 'transport' => 'test', 'from' => 'cakedc@example.com', ]); @@ -116,9 +118,9 @@ public function tearDown(): void { unset($this->table, $this->Trait); if ($this->mockDefaultEmail) { - Email::drop('default'); + Mailer::drop('default'); TransportFactory::drop('test'); - //Email::setConfig('default', $this->setConfigEmail); + //Mailer::setConfig('default', $this->setConfigEmail); } parent::tearDown(); } diff --git a/tests/TestCase/Controller/Traits/CustomUsersTableTraitTest.php b/tests/TestCase/Controller/Traits/CustomUsersTableTraitTest.php index 8bad2e04b..ebe2b8c88 100644 --- a/tests/TestCase/Controller/Traits/CustomUsersTableTraitTest.php +++ b/tests/TestCase/Controller/Traits/CustomUsersTableTraitTest.php @@ -13,6 +13,7 @@ namespace CakeDC\Users\Test\TestCase\Controller\Traits; +use Cake\Http\ServerRequest; use Cake\ORM\Table; use Cake\TestSuite\TestCase; @@ -23,6 +24,7 @@ public function setUp(): void parent::setUp(); $this->controller = $this->getMockBuilder('Cake\Controller\Controller') ->setMethods(['header', 'redirect', 'render', '_stop']) + ->setConstructorArgs([new ServerRequest()]) ->getMock(); $this->controller->Trait = $this->getMockForTrait('CakeDC\Users\Controller\Traits\CustomUsersTableTrait'); } diff --git a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php index 9bf8d74d4..8d270230c 100644 --- a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php @@ -28,7 +28,7 @@ class LoginTraitIntegrationTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; @@ -72,6 +72,7 @@ public function testLoginGetRequestNoSocialLogin() }); $this->get('/login'); + file_put_contents(TMP . 'testLoginGetRequestNoSocialLogin.html', $this->_response->getBody()); $this->assertResponseOk(); $this->assertResponseNotContains('Username or password is incorrect'); $this->assertResponseContains('
'); diff --git a/tests/TestCase/Controller/Traits/Integration/PasswordManagementTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/PasswordManagementTraitIntegrationTest.php index 47a9e337d..427c24885 100644 --- a/tests/TestCase/Controller/Traits/Integration/PasswordManagementTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/PasswordManagementTraitIntegrationTest.php @@ -27,7 +27,7 @@ class PasswordManagementTraitIntegrationTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Controller/Traits/Integration/ProfileTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/ProfileTraitIntegrationTest.php index ea555a89d..39a304eb5 100644 --- a/tests/TestCase/Controller/Traits/Integration/ProfileTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/ProfileTraitIntegrationTest.php @@ -26,7 +26,7 @@ class ProfileTraitIntegrationTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php index 8c7d4e852..a3bc529cb 100644 --- a/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php @@ -26,7 +26,7 @@ class RegisterTraitIntegrationTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php index 9b606146e..6965f9c6a 100644 --- a/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php @@ -29,7 +29,7 @@ class SimpleCrudTraitIntegrationTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Controller/Traits/LinkSocialTraitTest.php b/tests/TestCase/Controller/Traits/LinkSocialTraitTest.php index d5229da54..fe8cf2e7d 100644 --- a/tests/TestCase/Controller/Traits/LinkSocialTraitTest.php +++ b/tests/TestCase/Controller/Traits/LinkSocialTraitTest.php @@ -18,7 +18,7 @@ use Cake\Http\Response; use Cake\Http\ServerRequest; use Cake\Http\ServerRequestFactory; -use Cake\I18n\FrozenTime; +use Cake\I18n\DateTime; use Cake\ORM\TableRegistry; use Laminas\Diactoros\Uri; use League\OAuth2\Client\Provider\FacebookUser; @@ -30,7 +30,7 @@ class LinkSocialTraitTest extends BaseTraitTest * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; @@ -274,7 +274,7 @@ public function testCallbackLinkSocialHappy() $actual = $Table->SocialAccounts->find('all')->where(['reference' => '9999911112255'])->firstOrFail(); - $expiresTime = new FrozenTime(); + $expiresTime = new DateTime(); $tokenExpires = $expiresTime->setTimestamp($Token->getExpires())->format('Y-m-d H:i:s'); $expected = [ diff --git a/tests/TestCase/Controller/Traits/LoginTraitTest.php b/tests/TestCase/Controller/Traits/LoginTraitTest.php index b29c5d20f..06a47c1ac 100644 --- a/tests/TestCase/Controller/Traits/LoginTraitTest.php +++ b/tests/TestCase/Controller/Traits/LoginTraitTest.php @@ -17,7 +17,7 @@ use Authentication\Authenticator\SessionAuthenticator; use Authentication\Identifier\IdentifierCollection; use Authentication\Identifier\PasswordIdentifier; -use Cake\Auth\DefaultPasswordHasher; +use Authentication\PasswordHasher\DefaultPasswordHasher; use Cake\Controller\ComponentRegistry; use Cake\Event\Event; use Cake\Http\Response; @@ -134,7 +134,7 @@ public function testLoginHappy() $this->assertSame($passwordBefore, $passwordAfter); $lastLoginAfter = $userAfter['last_login']; $this->assertNotEmpty($lastLoginAfter); - $now = \Cake\I18n\FrozenTime::now(); + $now = \Cake\I18n\DateTime::now(); $this->assertEqualsWithDelta($lastLoginAfter->timestamp, $now->timestamp, 2); } diff --git a/tests/TestCase/Controller/Traits/OneTimePasswordVerifyTraitTest.php b/tests/TestCase/Controller/Traits/OneTimePasswordVerifyTraitTest.php index fa1c446e7..7ca5af94b 100644 --- a/tests/TestCase/Controller/Traits/OneTimePasswordVerifyTraitTest.php +++ b/tests/TestCase/Controller/Traits/OneTimePasswordVerifyTraitTest.php @@ -41,6 +41,7 @@ public function setUp(): void $request = new ServerRequest(); $this->Trait = $this->getMockBuilder($this->traitClassName) ->setMethods(['dispatchEvent', 'redirect', 'set', 'getUsersTable']) + ->setConstructorArgs([new ServerRequest()]) ->getMock(); $this->Trait->setRequest($request); diff --git a/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php b/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php index 9a3d8a6ad..a197a2f4e 100644 --- a/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php +++ b/tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php @@ -13,7 +13,7 @@ namespace CakeDC\Users\Test\TestCase\Controller\Traits; -use Cake\Auth\PasswordHasherFactory; +use Authentication\PasswordHasher\PasswordHasherFactory; use Cake\Core\Configure; use Cake\Event\Event; use Cake\TestSuite\TestCase; @@ -72,7 +72,7 @@ public function testChangePasswordHappy() ->method('success') ->with('Password has been changed successfully'); $this->Trait->changePassword(); - $hasher = PasswordHasherFactory::build('Default'); + $hasher = PasswordHasherFactory::build('Authentication.Default'); $this->assertTrue($hasher->check('new', $this->table->get('00000000-0000-0000-0000-000000000001')->password)); } @@ -130,7 +130,7 @@ public function testChangePasswordWithAfterChangeEvent() ->method('success') ->with('Password has been changed successfully'); $this->Trait->changePassword(); - $hasher = PasswordHasherFactory::build('Default'); + $hasher = PasswordHasherFactory::build('Authentication.Default'); $this->assertTrue($hasher->check('new', $this->table->get('00000000-0000-0000-0000-000000000001')->password)); } diff --git a/tests/TestCase/Controller/Traits/ProfileTraitTest.php b/tests/TestCase/Controller/Traits/ProfileTraitTest.php index 24dd1912c..ead9765c4 100644 --- a/tests/TestCase/Controller/Traits/ProfileTraitTest.php +++ b/tests/TestCase/Controller/Traits/ProfileTraitTest.php @@ -20,7 +20,7 @@ class ProfileTraitTest extends BaseTraitTest * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Controller/Traits/ReCaptchaTraitTest.php b/tests/TestCase/Controller/Traits/ReCaptchaTraitTest.php index d05b17e49..86ec61447 100644 --- a/tests/TestCase/Controller/Traits/ReCaptchaTraitTest.php +++ b/tests/TestCase/Controller/Traits/ReCaptchaTraitTest.php @@ -14,6 +14,7 @@ namespace CakeDC\Users\Test\TestCase\Controller\Traits; use Cake\Core\Configure; +use Cake\Http\ServerRequest; use Cake\TestSuite\TestCase; use ReflectionMethod; @@ -29,6 +30,7 @@ public function setUp(): void parent::setUp(); $this->Trait = $this->getMockBuilder('CakeDC\Users\Controller\Traits\ReCaptchaTrait') ->setMethods(['_getReCaptchaInstance']) + ->setConstructorArgs([new ServerRequest()]) ->getMockForTrait(); } diff --git a/tests/TestCase/Controller/Traits/SocialTraitTest.php b/tests/TestCase/Controller/Traits/SocialTraitTest.php index 8b3f23d5d..c40a94930 100644 --- a/tests/TestCase/Controller/Traits/SocialTraitTest.php +++ b/tests/TestCase/Controller/Traits/SocialTraitTest.php @@ -41,6 +41,7 @@ public function setUp(): void $request = new ServerRequest(); $this->Trait = $this->getMockBuilder($this->traitClassName) ->setMethods(['dispatchEvent', 'redirect', 'set', 'loadComponent']) + ->setConstructorArgs([new ServerRequest()]) ->getMock(); $this->Trait->request = $request; diff --git a/tests/TestCase/Controller/Traits/U2fTraitTest.php b/tests/TestCase/Controller/Traits/U2fTraitTest.php index 6d7db567e..6d3c71132 100644 --- a/tests/TestCase/Controller/Traits/U2fTraitTest.php +++ b/tests/TestCase/Controller/Traits/U2fTraitTest.php @@ -35,7 +35,7 @@ class U2fTraitTest extends BaseTraitTest * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Controller/Traits/Webauthn2faTraitTest.php b/tests/TestCase/Controller/Traits/Webauthn2faTraitTest.php index e47f2c661..9e6a89f87 100644 --- a/tests/TestCase/Controller/Traits/Webauthn2faTraitTest.php +++ b/tests/TestCase/Controller/Traits/Webauthn2faTraitTest.php @@ -36,7 +36,7 @@ class Webauthn2faTraitTest extends BaseTraitTest * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Controller/UsersControllerTest.php b/tests/TestCase/Controller/UsersControllerTest.php index 9cebd1f89..da283f8e8 100644 --- a/tests/TestCase/Controller/UsersControllerTest.php +++ b/tests/TestCase/Controller/UsersControllerTest.php @@ -28,7 +28,7 @@ class UsersControllerTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Identifier/SocialIdentifierTest.php b/tests/TestCase/Identifier/SocialIdentifierTest.php index bf93fd11d..ccab2a300 100644 --- a/tests/TestCase/Identifier/SocialIdentifierTest.php +++ b/tests/TestCase/Identifier/SocialIdentifierTest.php @@ -19,7 +19,7 @@ class SocialIdentifierTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Mailer/UsersMailerTest.php b/tests/TestCase/Mailer/UsersMailerTest.php index 294c245e9..3fd6bcb11 100644 --- a/tests/TestCase/Mailer/UsersMailerTest.php +++ b/tests/TestCase/Mailer/UsersMailerTest.php @@ -28,7 +28,7 @@ class UsersMailerTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Middleware/SocialAuthMiddlewareTest.php b/tests/TestCase/Middleware/SocialAuthMiddlewareTest.php index c9889c527..57211c2fd 100644 --- a/tests/TestCase/Middleware/SocialAuthMiddlewareTest.php +++ b/tests/TestCase/Middleware/SocialAuthMiddlewareTest.php @@ -32,7 +32,7 @@ class SocialAuthMiddlewareTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Middleware/SocialEmailMiddlewareTest.php b/tests/TestCase/Middleware/SocialEmailMiddlewareTest.php index 5232e736b..8b92d0296 100644 --- a/tests/TestCase/Middleware/SocialEmailMiddlewareTest.php +++ b/tests/TestCase/Middleware/SocialEmailMiddlewareTest.php @@ -26,7 +26,7 @@ class SocialEmailMiddlewareTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Model/Behavior/AuthFinderBehaviorTest.php b/tests/TestCase/Model/Behavior/AuthFinderBehaviorTest.php index b98fa6dac..c7e5705ce 100644 --- a/tests/TestCase/Model/Behavior/AuthFinderBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/AuthFinderBehaviorTest.php @@ -28,7 +28,7 @@ class AuthFinderBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Model/Behavior/LinkSocialBehaviorTest.php b/tests/TestCase/Model/Behavior/LinkSocialBehaviorTest.php index df6e5620e..c1a9a536b 100644 --- a/tests/TestCase/Model/Behavior/LinkSocialBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/LinkSocialBehaviorTest.php @@ -35,7 +35,7 @@ class LinkSocialBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php index 23b12f02f..e2bcbd835 100644 --- a/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/PasswordBehaviorTest.php @@ -14,7 +14,6 @@ namespace CakeDC\Users\Test\TestCase\Model\Behavior; use Cake\Core\Configure; -use Cake\Mailer\Email; use Cake\Mailer\Mailer; use Cake\Mailer\TransportFactory; use Cake\ORM\TableRegistry; @@ -38,7 +37,7 @@ class PasswordBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; @@ -57,7 +56,7 @@ public function setUp(): void ->getMock(); TransportFactory::drop('test'); TransportFactory::setConfig('test', ['className' => 'Debug']); - //$this->configEmail = Email::getConfig('default'); + //$this->configEmail = Mailer::getConfig('default'); Mailer::drop('default'); Mailer::setConfig('default', [ 'transport' => 'test', @@ -73,7 +72,7 @@ public function setUp(): void public function tearDown(): void { unset($this->table, $this->Behavior); - Email::drop('default'); + Mailer::drop('default'); TransportFactory::drop('test'); parent::tearDown(); } diff --git a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php index 317cc6a80..09cefee54 100644 --- a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php @@ -14,7 +14,7 @@ namespace CakeDC\Users\Test\TestCase\Model\Behavior; use Cake\Core\Configure; -use Cake\Mailer\Email; +use Cake\Mailer\Mailer; use Cake\Mailer\TransportFactory; use Cake\ORM\TableRegistry; use Cake\Routing\Router; @@ -33,7 +33,7 @@ class RegisterBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', ]; @@ -57,7 +57,7 @@ public function setUp(): void $this->Table = $table; $this->Behavior = $table->behaviors()->Register; TransportFactory::setConfig('test', ['className' => 'Debug']); - Email::setConfig('default', [ + Mailer::setConfig('default', [ 'transport' => 'test', 'from' => 'cakedc@example.com', ]); @@ -71,7 +71,7 @@ public function setUp(): void public function tearDown(): void { unset($this->Table, $this->Behavior); - Email::drop('default'); + Mailer::drop('default'); TransportFactory::drop('test'); parent::tearDown(); } diff --git a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php index 5e35cf818..a7c60db4a 100644 --- a/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/SocialAccountBehaviorTest.php @@ -30,7 +30,7 @@ class SocialAccountBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php index 684f6c4db..948befd95 100644 --- a/tests/TestCase/Model/Behavior/SocialBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/SocialBehaviorTest.php @@ -28,7 +28,7 @@ class SocialBehaviorTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Model/Entity/UserTest.php b/tests/TestCase/Model/Entity/UserTest.php index 4f0981f71..2b224b519 100644 --- a/tests/TestCase/Model/Entity/UserTest.php +++ b/tests/TestCase/Model/Entity/UserTest.php @@ -13,8 +13,8 @@ namespace CakeDC\Users\Test\TestCase\Model\Entity; -use Cake\Auth\DefaultPasswordHasher; -use Cake\I18n\FrozenTime; +use Authentication\PasswordHasher\DefaultPasswordHasher; +use Cake\I18n\DateTime; use Cake\I18n\I18n; use Cake\TestSuite\TestCase; use CakeDC\Users\Model\Entity\User; @@ -32,8 +32,8 @@ class UserTest extends TestCase public function setUp(): void { parent::setUp(); - $this->now = FrozenTime::now(); - FrozenTime::setTestNow($this->now); + $this->now = DateTime::now(); + DateTime::setTestNow($this->now); $this->User = new User(); } @@ -45,7 +45,7 @@ public function setUp(): void public function tearDown(): void { unset($this->User); - FrozenTime::setTestNow(); + DateTime::setTestNow(); parent::tearDown(); } diff --git a/tests/TestCase/Model/Table/SocialAccountsTableTest.php b/tests/TestCase/Model/Table/SocialAccountsTableTest.php index 04999b7f5..3328279e3 100644 --- a/tests/TestCase/Model/Table/SocialAccountsTableTest.php +++ b/tests/TestCase/Model/Table/SocialAccountsTableTest.php @@ -26,7 +26,7 @@ class SocialAccountsTableTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.SocialAccounts', 'plugin.CakeDC/Users.Users', ]; diff --git a/tests/TestCase/Model/Table/UsersTableTest.php b/tests/TestCase/Model/Table/UsersTableTest.php index 58b1e7fd6..b9995544f 100644 --- a/tests/TestCase/Model/Table/UsersTableTest.php +++ b/tests/TestCase/Model/Table/UsersTableTest.php @@ -13,7 +13,7 @@ namespace CakeDC\Users\Test\TestCase\Model\Table; -use Cake\Mailer\Email; +use Cake\Mailer\Mailer; use Cake\Mailer\TransportFactory; use Cake\ORM\TableRegistry; use Cake\Routing\Router; @@ -31,7 +31,7 @@ class UsersTableTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; @@ -49,7 +49,7 @@ public function setUp(): void Router::fullBaseUrl('http://users.test'); TransportFactory::drop('test'); TransportFactory::setConfig('test', ['className' => 'Debug']); - Email::setConfig('default', [ + Mailer::setConfig('default', [ 'transport' => 'test', 'from' => 'cakedc@example.com', ]); @@ -64,7 +64,7 @@ public function tearDown(): void { unset($this->Users); Router::fullBaseUrl($this->fullBaseBackup); - Email::drop('default'); + Mailer::drop('default'); parent::tearDown(); } diff --git a/tests/TestCase/Shell/UsersShellTest.php b/tests/TestCase/Shell/UsersShellTest.php index 2ce3ea7c0..65c66fcda 100644 --- a/tests/TestCase/Shell/UsersShellTest.php +++ b/tests/TestCase/Shell/UsersShellTest.php @@ -27,7 +27,7 @@ class UsersShellTest extends TestCase * * @var array */ - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Webauthn/AuthenticateAdapterTest.php b/tests/TestCase/Webauthn/AuthenticateAdapterTest.php index 70c101c90..c9a9f0226 100644 --- a/tests/TestCase/Webauthn/AuthenticateAdapterTest.php +++ b/tests/TestCase/Webauthn/AuthenticateAdapterTest.php @@ -14,7 +14,7 @@ class AuthenticateAdapterTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Webauthn/RegisterAdapterTest.php b/tests/TestCase/Webauthn/RegisterAdapterTest.php index 3ce86a8e8..5ce96be4b 100644 --- a/tests/TestCase/Webauthn/RegisterAdapterTest.php +++ b/tests/TestCase/Webauthn/RegisterAdapterTest.php @@ -14,7 +14,7 @@ class RegisterAdapterTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/TestCase/Webauthn/Repository/UserCredentialSourceRepositoryTest.php b/tests/TestCase/Webauthn/Repository/UserCredentialSourceRepositoryTest.php index 021d08c8b..efb693bfd 100644 --- a/tests/TestCase/Webauthn/Repository/UserCredentialSourceRepositoryTest.php +++ b/tests/TestCase/Webauthn/Repository/UserCredentialSourceRepositoryTest.php @@ -12,7 +12,7 @@ class UserCredentialSourceRepositoryTest extends TestCase { - public $fixtures = [ + protected array $fixtures = [ 'plugin.CakeDC/Users.Users', 'plugin.CakeDC/Users.SocialAccounts', ]; diff --git a/tests/test_app/TestApp/Application.php b/tests/test_app/TestApp/Application.php index f34718450..b89fcea65 100644 --- a/tests/test_app/TestApp/Application.php +++ b/tests/test_app/TestApp/Application.php @@ -37,8 +37,8 @@ public function bootstrap(): void ], ]); } - if (!\Cake\Mailer\Email::getConfig('default')) { - \Cake\Mailer\Email::setConfig([ + if (!\Cake\Mailer\Mailer::getConfig('default')) { + \Cake\Mailer\Mailer::setConfig([ 'default' => [ 'transport' => 'default', 'from' => 'you@localhost', diff --git a/tests/test_app/TestApp/Controller/AppController.php b/tests/test_app/TestApp/Controller/AppController.php index db11ec36d..dee6ddc22 100644 --- a/tests/test_app/TestApp/Controller/AppController.php +++ b/tests/test_app/TestApp/Controller/AppController.php @@ -28,6 +28,5 @@ public function initialize(): void { parent::initialize(); $this->loadComponent('Flash'); - $this->loadComponent('RequestHandler'); } }