Skip to content

Commit

Permalink
scrutinizer-ci fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyEvrica committed Mar 12, 2024
1 parent cb13d23 commit 55190e8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/Feature/NPlusOneQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,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) {
$this->queries++;
});
}
Expand All @@ -43,7 +43,7 @@ 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) {
$user->roles()->attach($roleIds);
});
$this->assertEquals($this->usersCount, User::count() - $this->usersCountCorrection);
Expand All @@ -54,7 +54,7 @@ public function canPreloadRolesOnCollection(): void
$users = User::get();
$this->assertQueries(1);

$users->each(function (User $user) {
$users->each(function(User $user) {
$user->getRoles();
});
$this->queries = $this->queries - $this->usersCountCorrection;
Expand All @@ -64,7 +64,7 @@ public function canPreloadRolesOnCollection(): void
$users = User::with('roles')->get();
$this->assertQueries(2);

$users->each(function (User $user) {
$users->each(function(User $user) {
$user->getRoles();
});
$this->assertQueries(0);
Expand Down Expand Up @@ -142,7 +142,7 @@ 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) {
$user->roles()->attach($roleIds);
});
$this->assertEquals($this->usersCount, User::count() - $this->usersCountCorrection);
Expand All @@ -153,7 +153,7 @@ public function canPreloadPermissionsOnCollection(): void
$users = User::get();
$this->assertQueries(1);

$users->each(function (User $user) {
$users->each(function(User $user) {
$user->getPermissions();
});
// rolePermissions(+getRoles) + userPermissions
Expand All @@ -164,7 +164,7 @@ public function canPreloadPermissionsOnCollection(): void
$users = User::with('roles', 'userPermissions')->get();
$this->assertQueries(3);

$users->each(function (User $user) {
$users->each(function(User $user) {
$user->getPermissions();
});
// TODO: optimize via relations: userPermissions and rolePermissions
Expand Down

0 comments on commit 55190e8

Please sign in to comment.