diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php index a0a84650..f1bfd4cf 100644 --- a/src/Model/Behavior/SocialAccountBehavior.php +++ b/src/Model/Behavior/SocialAccountBehavior.php @@ -38,11 +38,13 @@ class SocialAccountBehavior extends Behavior public function initialize(array $config): void { parent::initialize($config); - $this->_table - ->belongsTo('Users') - ->setForeignKey('user_id') - ->setJoinType('INNER') - ->setClassName(Configure::read('Users.table')); + if (!$this->_table->hasAssociation('Users')) { + $this->_table + ->belongsTo('Users') + ->setForeignKey('user_id') + ->setJoinType('INNER') + ->setClassName(Configure::read('Users.table')); + } } /** diff --git a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php index ad20dbae..9ac15300 100644 --- a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php @@ -88,8 +88,8 @@ public function testLoginGetRequestNoSocialLogin() $this->assertResponseNotContains('Username or password is incorrect'); $this->assertResponseContains('
'); $this->assertResponseContains('Please enter your username and password'); - $this->assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains(''); $this->assertResponseContains('Register'); @@ -114,8 +114,8 @@ public function testLoginGetRequest() $this->assertResponseNotContains('Username or password is incorrect'); $this->assertResponseContains(''); $this->assertResponseContains('Please enter your username and password'); - $this->assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains(''); $this->assertResponseContains('Register'); @@ -143,8 +143,8 @@ public function testLoginPostRequestInvalidPassword() $this->assertResponseContains('Username or password is incorrect'); $this->assertResponseContains(''); $this->assertResponseContains('Please enter your username and password'); - $this->assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains(''); } diff --git a/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php index 5e27ef5e..82c93849 100644 --- a/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php @@ -48,7 +48,7 @@ public function testRegister() $this->assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains(''); + $this->assertResponseContains(''); $this->assertResponseContains(''); } @@ -83,7 +83,7 @@ public function testRegisterPostWithErrors() $this->assertResponseContains('assertResponseContains('assertResponseContains('assertResponseContains(''); + $this->assertResponseContains(''); $this->assertResponseContains(''); } diff --git a/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php index 9a35d74b..71c3cdeb 100644 --- a/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php @@ -59,7 +59,7 @@ public function testCrud() $this->assertResponseContains('View'); $this->assertResponseContains('Change password'); $this->assertResponseContains('Edit'); - $this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000001"'); + $this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000001"'); $this->assertResponseContains('>Delete<'); $this->assertResponseContains('user-6'); @@ -69,7 +69,7 @@ public function testCrud() $this->assertResponseContains('View'); $this->assertResponseContains('Change password'); $this->assertResponseContains('Edit'); - $this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"'); + $this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"'); $this->get('/users/change-password/00000000-0000-0000-0000-000000000006'); $this->assertFlashMessage('Changing another user\'s password is not allowed'); @@ -95,13 +95,13 @@ public function testCrud() $this->get('/users/edit/00000000-0000-0000-0000-000000000006'); $this->assertResponseContains('assertResponseContains('id="username" value="user-6"'); $this->assertResponseContains('assertResponseContains('id="email" value="6@example.com"'); $this->assertResponseContains('Active'); - $this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"'); + $this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"'); $this->assertResponseContains('List Users'); $this->enableSecurityToken(); @@ -124,7 +124,7 @@ public function testCrud() $this->assertResponseContains('Edit User'); $this->assertResponseContains('New User'); $this->assertResponseContains('List Users'); - $this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"'); + $this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"'); $this->post('/users/delete/00000000-0000-0000-0000-000000000006'); $this->assertRedirect('/users/index'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2d7e543c..1466db70 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -95,11 +95,13 @@ Cake\Core\Configure::write('Session', [ 'defaults' => 'php', ]); +session_id('cli'); Plugin::getCollection()->add(new \CakeDC\Users\Plugin([ 'path' => dirname(dirname(__FILE__)) . DS, 'routes' => true, ])); + if (file_exists($root . '/config/bootstrap.php')) { require $root . '/config/bootstrap.php'; } @@ -136,9 +138,6 @@ class_alias('TestApp\Controller\AppController', 'App\Controller\AppController'); ]); \Cake\Utility\Security::setSalt('yoyz186elmi66ab9pz4imbb3tgy9vnsgsfgwe2r8tyxbbfdygu9e09tlxyg8p7dq'); -Plugin::getCollection()->add(new \CakeDC\Users\Plugin()); -session_id('cli'); - \Cake\Core\Configure::write('Users.AllowedRedirectHosts', [ 'localhost', 'example.com',