-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests when $this->call(UsersTableSeeder::class) runs #206
Conversation
…stom users count assertions fail.
…last content on the line jeremykenedy#49
@@ -27,7 +32,7 @@ protected function setUp(): void | |||
$this->assertEquals($this->rolesCount, config('roles.models.role')::count()); | |||
$this->assertEquals($this->permissionsCount, config('roles.models.permission')::count()); | |||
|
|||
DB::listen(function (QueryExecuted $query) { | |||
DB::listen(function(QueryExecuted $query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
@@ -38,27 +43,28 @@ public function canPreloadRolesOnCollection(): void | |||
$roleIds = config('roles.models.role')::pluck('id'); | |||
|
|||
User::factory($this->usersCount)->create() | |||
->each(function (User $user) use ($roleIds) { | |||
->each(function(User $user) use ($roleIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
|
||
$this->queries = 0; | ||
|
||
// without eager load | ||
$users = User::get(); | ||
$this->assertQueries(1); | ||
|
||
$users->each(function (User $user) { | ||
$users->each(function(User $user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
$this->assertQueries($this->usersCount); | ||
|
||
// with eager load | ||
$users = User::with('roles')->get(); | ||
$this->assertQueries(2); | ||
|
||
$users->each(function (User $user) { | ||
$users->each(function(User $user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
@@ -136,33 +142,33 @@ public function canPreloadPermissionsOnCollection(): void | |||
$roleIds = config('roles.models.role')::pluck('id'); | |||
|
|||
User::factory($this->usersCount)->create() | |||
->each(function (User $user) use ($roleIds) { | |||
->each(function(User $user) use ($roleIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
|
||
$this->queries = 0; | ||
|
||
// without eager load | ||
$users = User::get(); | ||
$this->assertQueries(1); | ||
|
||
$users->each(function (User $user) { | ||
$users->each(function(User $user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
|
||
// with eager load | ||
// TODO: 'rolePermissions' relation | ||
$users = User::with('roles', 'userPermissions')->get(); | ||
$this->assertQueries(3); | ||
|
||
$users->each(function (User $user) { | ||
$users->each(function(User $user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FUNCTION keyword; 0 found
When DatabaseSeeder runs
$this->call(UsersTableSeeder::class)
with custom users, count assertions fails.