Skip to content

Commit cb0f3c1

Browse files
committed
Update master user find so the config is used
1 parent 8692647 commit cb0f3c1

1 file changed

Lines changed: 33 additions & 9 deletions

File tree

app/sprinkles/admin/tests/Integration/Controller/UserControllerTest.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,17 @@ public function testGetModalCreate(UserController $controller)
455455
*/
456456
public function testGetModalCreateWithNoLocale(UserController $controller)
457457
{
458-
// Admin user, WILL have access
459-
$testUser = User::find(1)->first();
460-
$this->loginUser($testUser);
458+
// Default should be the existing admin user.
459+
$user = User::find($this->ci->config['reserved_user_ids.master']);
460+
461+
// In case the user don't exist
462+
if (!$user) {
463+
$user = $fm->create('UserFrosting\Sprinkle\Account\Database\Models\User', [
464+
'id' => $this->ci->config['reserved_user_ids.master']
465+
]);
466+
}
467+
468+
$this->loginUser($user);
461469

462470
// Change config
463471
$this->ci->config['site.locales.available'] = [];
@@ -492,9 +500,17 @@ public function testGetModalEdit(UserController $controller)
492500
*/
493501
public function testGetModalEditWithNoLocale(UserController $controller)
494502
{
495-
// Admin user, WILL have access
496-
$testUser = User::find(1)->first();
497-
$this->loginUser($testUser);
503+
// Default should be the existing admin user.
504+
$user = User::find($this->ci->config['reserved_user_ids.master']);
505+
506+
// In case the user don't exist
507+
if (!$user) {
508+
$user = $fm->create('UserFrosting\Sprinkle\Account\Database\Models\User', [
509+
'id' => $this->ci->config['reserved_user_ids.master']
510+
]);
511+
}
512+
513+
$this->loginUser($user);
498514

499515
// Change config
500516
$this->ci->config['site.locales.available'] = [];
@@ -644,9 +660,17 @@ public function testPageInfo(UserController $controller)
644660
*/
645661
public function testPageInfoWithNoLocale(UserController $controller)
646662
{
647-
// Admin user, WILL have access
648-
$testUser = User::find(1)->first();
649-
$this->loginUser($testUser);
663+
// Default should be the existing admin user.
664+
$user = User::find($this->ci->config['reserved_user_ids.master']);
665+
666+
// In case the user don't exist
667+
if (!$user) {
668+
$user = $fm->create('UserFrosting\Sprinkle\Account\Database\Models\User', [
669+
'id' => $this->ci->config['reserved_user_ids.master']
670+
]);
671+
}
672+
673+
$this->loginUser($user);
650674

651675
// Change config
652676
$this->ci->config['site.locales.available'] = [];

0 commit comments

Comments
 (0)