Skip to content

Commit 982a5c7

Browse files
authored
Merge pull request #1115 from ajibarra/14.next-cake5
Fix plugin loaded twice in tests/bootstrap.php
2 parents 6954c72 + a464935 commit 982a5c7

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

src/Model/Behavior/SocialAccountBehavior.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class SocialAccountBehavior extends Behavior
3838
public function initialize(array $config): void
3939
{
4040
parent::initialize($config);
41-
$this->_table
42-
->belongsTo('Users')
43-
->setForeignKey('user_id')
44-
->setJoinType('INNER')
45-
->setClassName(Configure::read('Users.table'));
41+
if (!$this->_table->hasAssociation('Users')) {
42+
$this->_table
43+
->belongsTo('Users')
44+
->setForeignKey('user_id')
45+
->setJoinType('INNER')
46+
->setClassName(Configure::read('Users.table'));
47+
}
4648
}
4749

4850
/**

tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public function testLoginGetRequestNoSocialLogin()
8888
$this->assertResponseNotContains('Username or password is incorrect');
8989
$this->assertResponseContains('<form method="post" accept-charset="utf-8" action="/login">');
9090
$this->assertResponseContains('<legend>Please enter your username and password</legend>');
91-
$this->assertResponseContains('<input type="text" name="username" required="required" id="username" aria-required="true"');
92-
$this->assertResponseContains('<input type="password" name="password" required="required" id="password" aria-required="true"');
91+
$this->assertResponseContains('<input type="text" name="username" required="required" id="username"');
92+
$this->assertResponseContains('<input type="password" name="password" required="required" id="password"');
9393
$this->assertResponseContains('<input type="checkbox" name="remember_me" value="1" checked="checked" id="remember-me"');
9494
$this->assertResponseContains('<button type="submit">Login</button>');
9595
$this->assertResponseContains('<a href="/register">Register</a>');
@@ -114,8 +114,8 @@ public function testLoginGetRequest()
114114
$this->assertResponseNotContains('Username or password is incorrect');
115115
$this->assertResponseContains('<form method="post" accept-charset="utf-8" action="/login">');
116116
$this->assertResponseContains('<legend>Please enter your username and password</legend>');
117-
$this->assertResponseContains('<input type="text" name="username" required="required" id="username" aria-required="true"');
118-
$this->assertResponseContains('<input type="password" name="password" required="required" id="password" aria-required="true"');
117+
$this->assertResponseContains('<input type="text" name="username" required="required" id="username"');
118+
$this->assertResponseContains('<input type="password" name="password" required="required" id="password"');
119119
$this->assertResponseContains('<input type="checkbox" name="remember_me" value="1" checked="checked" id="remember-me"');
120120
$this->assertResponseContains('<button type="submit">Login</button>');
121121
$this->assertResponseContains('<a href="/register">Register</a>');
@@ -143,8 +143,8 @@ public function testLoginPostRequestInvalidPassword()
143143
$this->assertResponseContains('Username or password is incorrect');
144144
$this->assertResponseContains('<form method="post" accept-charset="utf-8" action="/login">');
145145
$this->assertResponseContains('<legend>Please enter your username and password</legend>');
146-
$this->assertResponseContains('<input type="text" name="username" required="required" id="username" aria-required="true" value="user-2"');
147-
$this->assertResponseContains('<input type="password" name="password" required="required" id="password" aria-required="true" value="123456789"');
146+
$this->assertResponseContains('<input type="text" name="username" required="required" id="username" value="user-2"');
147+
$this->assertResponseContains('<input type="password" name="password" required="required" id="password" value="123456789"');
148148
$this->assertResponseContains('<input type="checkbox" name="remember_me" value="1" checked="checked" id="remember-me"');
149149
$this->assertResponseContains('<button type="submit">Login</button>');
150150
}

tests/TestCase/Controller/Traits/Integration/RegisterTraitIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testRegister()
4848
$this->assertResponseContains('<input type="text" name="first_name" id="first-name" maxlength="50"');
4949
$this->assertResponseContains('<input type="text" name="last_name" id="last-name" maxlength="50"');
5050
$this->assertResponseContains('<input type="hidden" name="tos" value="0"');
51-
$this->assertResponseContains('<label for="tos"><input type="checkbox" name="tos" value="1" required="required" id="tos" aria-required="true">Accept TOS conditions?</label>');
51+
$this->assertResponseContains('<label for="tos"><input type="checkbox" name="tos" value="1" required="required" id="tos">Accept TOS conditions?</label>');
5252
$this->assertResponseContains('<button id="btn-submit" type="submit">Submit</button>');
5353
}
5454

@@ -83,7 +83,7 @@ public function testRegisterPostWithErrors()
8383
$this->assertResponseContains('<input type="text" name="first_name" id="first-name" value="" maxlength="50"');
8484
$this->assertResponseContains('<input type="text" name="last_name" id="last-name" value="" maxlength="50"');
8585
$this->assertResponseContains('<input type="hidden" name="tos" value="0"');
86-
$this->assertResponseContains('<label for="tos"><input type="checkbox" name="tos" value="1" required="required" id="tos" aria-required="true">Accept TOS conditions?</label>');
86+
$this->assertResponseContains('<label for="tos"><input type="checkbox" name="tos" value="1" required="required" id="tos">Accept TOS conditions?</label>');
8787
$this->assertResponseContains('<button id="btn-submit" type="submit">Submit</button>');
8888
}
8989

tests/TestCase/Controller/Traits/Integration/SimpleCrudTraitIntegrationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testCrud()
5959
$this->assertResponseContains('<a href="/users/view/00000000-0000-0000-0000-000000000001">View</a>');
6060
$this->assertResponseContains('<a href="/users/change-password/00000000-0000-0000-0000-000000000001">Change password</a>');
6161
$this->assertResponseContains('<a href="/users/edit/00000000-0000-0000-0000-000000000001">Edit</a>');
62-
$this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000001"');
62+
$this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000001"');
6363
$this->assertResponseContains('>Delete<');
6464

6565
$this->assertResponseContains('<td>user-6</td>');
@@ -69,7 +69,7 @@ public function testCrud()
6969
$this->assertResponseContains('<a href="/users/view/00000000-0000-0000-0000-000000000006">View</a>');
7070
$this->assertResponseContains('<a href="/users/change-password/00000000-0000-0000-0000-000000000006">Change password</a>');
7171
$this->assertResponseContains('<a href="/users/edit/00000000-0000-0000-0000-000000000006">Edit</a>');
72-
$this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"');
72+
$this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"');
7373

7474
$this->get('/users/change-password/00000000-0000-0000-0000-000000000006');
7575
$this->assertFlashMessage('Changing another user\'s password is not allowed');
@@ -95,13 +95,13 @@ public function testCrud()
9595

9696
$this->get('/users/edit/00000000-0000-0000-0000-000000000006');
9797
$this->assertResponseContains('<input type="text" name="username" required="required');
98-
$this->assertResponseContains('id="username" aria-required="true" value="user-6"');
98+
$this->assertResponseContains('id="username" value="user-6"');
9999
$this->assertResponseContains('<input type="email" name="email" required="required');
100-
$this->assertResponseContains('id="email" aria-required="true" value="6@example.com"');
100+
$this->assertResponseContains('id="email" value="6@example.com"');
101101
$this->assertResponseContains('<input type="text" name="first_name" id="first-name" value="first-user-6');
102102
$this->assertResponseContains('<input type="text" name="last_name" id="last-name" value="firts name 6');
103103
$this->assertResponseContains('<label for="active"><input type="checkbox" name="active" value="1" id="active" checked="checked">Active</label>');
104-
$this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"');
104+
$this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"');
105105
$this->assertResponseContains('<a href="/users/index">List Users</a>');
106106

107107
$this->enableSecurityToken();
@@ -124,7 +124,7 @@ public function testCrud()
124124
$this->assertResponseContains('<a href="/users/edit/00000000-0000-0000-0000-000000000006">Edit User</a>');
125125
$this->assertResponseContains('<a href="/users/add">New User</a>');
126126
$this->assertResponseContains('<a href="/users/index">List Users</a>');
127-
$this->assertResponseContains('style="display:none;" method="post" action="/users/delete/00000000-0000-0000-0000-000000000006"');
127+
$this->assertResponseContains('method="post" style="display:none;" action="/users/delete/00000000-0000-0000-0000-000000000006"');
128128

129129
$this->post('/users/delete/00000000-0000-0000-0000-000000000006');
130130
$this->assertRedirect('/users/index');

tests/bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@
9595
Cake\Core\Configure::write('Session', [
9696
'defaults' => 'php',
9797
]);
98+
session_id('cli');
9899

99100
Plugin::getCollection()->add(new \CakeDC\Users\Plugin([
100101
'path' => dirname(dirname(__FILE__)) . DS,
101102
'routes' => true,
102103
]));
104+
103105
if (file_exists($root . '/config/bootstrap.php')) {
104106
require $root . '/config/bootstrap.php';
105107
}
@@ -136,9 +138,6 @@ class_alias('TestApp\Controller\AppController', 'App\Controller\AppController');
136138
]);
137139
\Cake\Utility\Security::setSalt('yoyz186elmi66ab9pz4imbb3tgy9vnsgsfgwe2r8tyxbbfdygu9e09tlxyg8p7dq');
138140

139-
Plugin::getCollection()->add(new \CakeDC\Users\Plugin());
140-
session_id('cli');
141-
142141
\Cake\Core\Configure::write('Users.AllowedRedirectHosts', [
143142
'localhost',
144143
'example.com',

0 commit comments

Comments
 (0)