Skip to content

Commit c0602d8

Browse files
committed
Model::preventsLazyLoading() check added
1 parent 8d45011 commit c0602d8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/HasPermissionsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spatie\Permission\Tests;
44

5+
use Illuminate\Database\Eloquent\Model;
56
use DB;
67
use Spatie\Permission\Contracts\Permission;
78
use Spatie\Permission\Contracts\Role;
@@ -769,6 +770,8 @@ public function it_can_reject_permission_based_on_logged_in_user_guard()
769770
/** @test */
770771
public function it_can_be_given_a_permission_on_role_when_lazy_loading_is_restricted()
771772
{
773+
$this->assertTrue(Model::preventsLazyLoading());
774+
772775
try {
773776
$testRole = app(Role::class)->with('permissions')->get()->first();
774777

@@ -783,6 +786,8 @@ public function it_can_be_given_a_permission_on_role_when_lazy_loading_is_restri
783786
/** @test */
784787
public function it_can_be_given_a_permission_on_user_when_lazy_loading_is_restricted()
785788
{
789+
$this->assertTrue(Model::preventsLazyLoading());
790+
786791
try {
787792
User::create(['email' => '[email protected]']);
788793
$testUser = User::with('permissions')->get()->first();

tests/HasRolesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spatie\Permission\Tests;
44

5+
use Illuminate\Database\Eloquent\Model;
56
use Illuminate\Support\Facades\DB;
67
use Spatie\Permission\Contracts\Permission;
78
use Spatie\Permission\Contracts\Role;
@@ -861,6 +862,8 @@ public function it_does_not_detach_roles_when_user_soft_deleting()
861862
/** @test */
862863
public function it_can_be_given_a_role_on_permission_when_lazy_loading_is_restricted()
863864
{
865+
$this->assertTrue(Model::preventsLazyLoading());
866+
864867
try {
865868
$testPermission = app(Permission::class)->with('roles')->get()->first();
866869

@@ -875,6 +878,8 @@ public function it_can_be_given_a_role_on_permission_when_lazy_loading_is_restri
875878
/** @test */
876879
public function it_can_be_given_a_role_on_user_when_lazy_loading_is_restricted()
877880
{
881+
$this->assertTrue(Model::preventsLazyLoading());
882+
878883
try {
879884
User::create(['email' => '[email protected]']);
880885
$user = User::with('roles')->get()->first();

0 commit comments

Comments
 (0)