-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1252 - Column not found when extending the User (or Group) model
- Loading branch information
Showing
5 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
use Illuminate\Cache\Repository as Cache; | ||
use Mockery; | ||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; | ||
use PHPUnit\Framework\Attributes\TestWith; | ||
use UserFrosting\Config\Config; | ||
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface; | ||
use UserFrosting\Sprinkle\Account\Database\Models\User; | ||
|
@@ -204,4 +205,38 @@ public function testFindCacheWithNullUser(): void | |
// N.B.: Laravel cache won't store anything if the value is null. | ||
$this->assertFalse($cache->has($key)); | ||
} | ||
|
||
/** | ||
* Test relations setup are working, even if the class is extended | ||
* @see https://github.com/userfrosting/UserFrosting/issues/1252 | ||
* | ||
* @param class-string<UserInterface> $model | ||
*/ | ||
#[TestWith([User::class])] | ||
#[TestWith([Member::class])] | ||
public function testRelations(string $model): void | ||
{ | ||
$object = new $model([ | ||
'user_name' => 'testing', | ||
'email' => '[email protected]', | ||
'first_name' => 'Test', | ||
'last_name' => 'Ing', | ||
'password' => 'secret', | ||
]); | ||
$object->save(); | ||
|
||
// Fetch each relation - They each will be empty | ||
// A real query is required to trigger a SQL Exception | ||
$this->assertCount(0, $object->activities()->get()); | ||
$this->assertCount(0, $object->group()->get()); | ||
$this->assertCount(0, $object->passwordResets()->get()); | ||
$this->assertCount(0, $object->verifications()->get()); | ||
$this->assertCount(0, $object->persistences()->get()); | ||
$this->assertCount(0, $object->permissions()->get()); | ||
$this->assertCount(0, $object->roles()->get()); | ||
} | ||
} | ||
|
||
class Member extends User | ||
{ | ||
} |