Skip to content

Commit 4f75329

Browse files
Merge pull request #154 from brahimrizqHireme/update-laravel-11-support
2 parents c46c2b9 + ed5505b commit 4f75329

15 files changed

+54
-53
lines changed

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ build:
33
environment:
44
mongodb: true
55
selenium: true
6+
php:
7+
version: 8.1
68
tests:
79
override:
810
-

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "mostafamaklad/laravel-permission-mongodb",
33
"description": "Permission handling for Laravel 5.2 and up using mongodb",
4+
"version": "dev-master",
45
"keywords": [
56
"laravel",
67
"security",
@@ -31,15 +32,15 @@
3132
],
3233
"require": {
3334
"php": "^8.1",
34-
"illuminate/auth": "^10.0",
35-
"illuminate/container": "^10.0",
36-
"illuminate/contracts": "^10.0",
37-
"mongodb/laravel-mongodb": "^3.9"
35+
"illuminate/auth": "^11.0",
36+
"illuminate/container": "^11.0",
37+
"illuminate/contracts": "^11.0",
38+
"mongodb/laravel-mongodb": "^4.6"
3839
},
3940
"require-dev": {
4041
"monolog/monolog": "^3.2",
41-
"orchestra/testbench": "^8.0",
42-
"phpunit/phpunit": "^9.5.10",
42+
"orchestra/testbench": "^9.0",
43+
"phpunit/phpunit": "^10.0",
4344
"squizlabs/php_codesniffer": "^3.7"
4445
},
4546
"autoload": {

phpunit.xml.dist

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
123
<coverage>
13-
<include>
14-
<directory suffix=".php">src/</directory>
15-
</include>
164
<report>
175
<clover outputFile="build/logs/clover.xml"/>
186
<html outputDirectory="build/coverage"/>
@@ -27,4 +15,9 @@
2715
<logging>
2816
<junit outputFile="build/report.junit.xml"/>
2917
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
3023
</phpunit>

src/Models/Permission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Maklad\Permission\Models;
44

55
use Illuminate\Support\Collection;
6-
use Jenssegers\Mongodb\Eloquent\Model;
76
use Maklad\Permission\Contracts\PermissionInterface;
87
use Maklad\Permission\Exceptions\PermissionAlreadyExists;
98
use Maklad\Permission\Exceptions\PermissionDoesNotExist;
@@ -12,6 +11,7 @@
1211
use Maklad\Permission\PermissionRegistrar;
1312
use Maklad\Permission\Traits\HasRoles;
1413
use Maklad\Permission\Traits\RefreshesPermissionCache;
14+
use MongoDB\Laravel\Eloquent\Model;
1515
use ReflectionException;
1616
use function app;
1717

src/Models/Role.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Maklad\Permission\Models;
44

55
use Illuminate\Database\Eloquent\Builder;
6-
use Jenssegers\Mongodb\Eloquent\Model;
76
use Maklad\Permission\Contracts\PermissionInterface;
87
use Maklad\Permission\Contracts\RoleInterface;
98
use Maklad\Permission\Exceptions\GuardDoesNotMatch;
@@ -13,6 +12,7 @@
1312
use Maklad\Permission\Helpers;
1413
use Maklad\Permission\Traits\HasPermissions;
1514
use Maklad\Permission\Traits\RefreshesPermissionCache;
15+
use MongoDB\Laravel\Eloquent\Model;
1616
use ReflectionException;
1717
use function is_string;
1818

src/Traits/HasPermissions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace Maklad\Permission\Traits;
44

55
use Illuminate\Support\Collection;
6-
use Jenssegers\Mongodb\Eloquent\Builder;
7-
use Jenssegers\Mongodb\Eloquent\Model;
86
use Maklad\Permission\Contracts\PermissionInterface;
97
use Maklad\Permission\Contracts\PermissionInterface as Permission;
108
use Maklad\Permission\Exceptions\GuardDoesNotMatch;
119
use Maklad\Permission\Guard;
1210
use Maklad\Permission\Helpers;
1311
use Maklad\Permission\PermissionRegistrar;
12+
use MongoDB\Laravel\Eloquent\Model;
13+
use MongoDB\Laravel\Eloquent\Builder;
1414
use ReflectionException;
1515
use function collect;
1616
use function is_array;

src/Traits/HasRoles.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Maklad\Permission\Traits;
44

55
use Illuminate\Support\Collection;
6-
use Jenssegers\Mongodb\Eloquent\Builder;
7-
use Jenssegers\Mongodb\Eloquent\Model;
8-
use Jenssegers\Mongodb\Relations\BelongsToMany;
96
use Maklad\Permission\Contracts\RoleInterface as Role;
107
use Maklad\Permission\Helpers;
118
use Maklad\Permission\PermissionRegistrar;
9+
use MongoDB\Laravel\Eloquent\Model;
10+
use MongoDB\Laravel\Eloquent\Builder;
11+
use MongoDB\Laravel\Relations\BelongsToMany;
1212
use ReflectionException;
1313
use function collect;
1414

tests/Admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
77
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
88
use Illuminate\Foundation\Auth\Access\Authorizable;
9-
use Jenssegers\Mongodb\Eloquent\Model;
109
use Maklad\Permission\Traits\HasRoles;
10+
use MongoDB\Laravel\Eloquent\Model;
1111

1212
class Admin extends Model implements AuthorizableContract, AuthenticatableContract
1313
{

tests/HasPermissionsTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Maklad\Permission\Exceptions\PermissionDoesNotExist;
77
use Maklad\Permission\Models\Permission;
88
use Maklad\Permission\Models\Role;
9+
use Monolog\Level;
910
use Monolog\Logger;
1011

1112
class HasPermissionsTest extends TestCase
@@ -34,7 +35,7 @@ public function it_throws_an_exception_when_assigning_a_permission_that_does_not
3435
$this->testUser->givePermissionTo('permission-does-not-exist');
3536
} finally {
3637
$message = $this->helpers->getPermissionDoesNotExistMessage('permission-does-not-exist', 'web');
37-
$this->assertLogMessage($message, Logger::ALERT);
38+
$this->assertLogMessage($message, Level::Alert);
3839
}
3940
}
4041
}
@@ -53,7 +54,7 @@ public function it_throws_an_exception_when_assigning_a_permission_to_a_user_fro
5354
$this->testUser->givePermissionTo($this->testAdminPermission);
5455
} finally {
5556
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
56-
$this->assertLogMessage($message, Logger::ALERT);
57+
$this->assertLogMessage($message, Level::Alert);
5758
}
5859
}
5960
}
@@ -327,7 +328,7 @@ public function it_throws_an_exception_when_the_permission_does_not_exist()
327328
$this->testUser->hasPermissionTo('does-not-exist');
328329
} finally {
329330
$message = $this->helpers->getPermissionDoesNotExistMessage('does-not-exist', 'web');
330-
$this->assertLogMessage($message, Logger::ALERT);
331+
$this->assertLogMessage($message, Level::Alert);
331332
}
332333
}
333334
}
@@ -346,7 +347,7 @@ public function it_throws_an_exception_when_the_permission_does_not_exist_for_th
346347
$this->testUser->hasPermissionTo('admin-permission');
347348
} finally {
348349
$message = $this->helpers->getPermissionDoesNotExistMessage('admin-permission', 'web');
349-
$this->assertLogMessage($message, Logger::ALERT);
350+
$this->assertLogMessage($message, Level::Alert);
350351
}
351352
}
352353
}

tests/HasRolesTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Maklad\Permission\Exceptions\GuardDoesNotMatch;
66
use Maklad\Permission\Exceptions\RoleDoesNotExist;
77
use Maklad\Permission\Models\Role;
8+
use Monolog\Level;
89
use Monolog\Logger;
910

1011
class HasRolesTest extends TestCase
@@ -73,7 +74,7 @@ public function it_throws_an_exception_when_assigning_a_role_that_does_not_exist
7374
$this->testUser->assignRole('evil-emperor');
7475
} finally {
7576
$message = $this->helpers->getRoleDoesNotExistMessage('evil-emperor', 'web');
76-
$this->assertLogMessage($message, Logger::ALERT);
77+
$this->assertLogMessage($message, Level::Alert);
7778
}
7879
}
7980
}
@@ -92,7 +93,7 @@ public function it_can_only_assign_roles_from_the_correct_guard()
9293
$this->testUser->assignRole('testAdminRole');
9394
} finally {
9495
$message = $this->helpers->getRoleDoesNotExistMessage('testAdminRole', 'web');
95-
$this->assertLogMessage($message, Logger::ALERT);
96+
$this->assertLogMessage($message, Level::Alert);
9697
}
9798
}
9899
}
@@ -111,7 +112,7 @@ public function it_throws_an_exception_when_assigning_a_role_from_a_different_gu
111112
$this->testUser->assignRole($this->testAdminRole);
112113
} finally {
113114
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
114-
$this->assertLogMessage($message, Logger::ALERT);
115+
$this->assertLogMessage($message, Level::Alert);
115116
}
116117
}
117118
}
@@ -176,7 +177,7 @@ public function it_throws_an_exception_when_syncing_a_role_from_another_guard()
176177
$this->testUser->syncRoles('testRole', $this->testAdminRole);
177178
} finally {
178179
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
179-
$this->assertLogMessage($message, Logger::ALERT);
180+
$this->assertLogMessage($message, Level::Alert);
180181
}
181182
}
182183
}

tests/MiddlewareTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Maklad\Permission\Exceptions\UnauthorizedException;
99
use Maklad\Permission\Middlewares\PermissionMiddleware;
1010
use Maklad\Permission\Middlewares\RoleMiddleware;
11+
use Monolog\Level;
1112
use Monolog\Logger;
1213

1314
class MiddlewareTest extends TestCase
@@ -41,7 +42,7 @@ public function a_guest_cannot_access_a_route_protected_by_the_role_middleware()
4142
);
4243

4344
$message = $this->helpers->getUserNotLoggedINMessage();
44-
$this->assertLogMessage($message, Logger::ALERT);
45+
$this->assertLogMessage($message, Level::Alert);
4546
}
4647
}
4748

@@ -109,7 +110,7 @@ public function a_user_cannot_access_a_route_protected_by_the_role_middleware_if
109110
config('permission.display_permission_in_exception', $show_permission);
110111
$message = $this->helpers->getUnauthorizedRoleMessage('testRole2');
111112
$this->assertShowPermission($message, 'testRole2');
112-
$this->assertLogMessage($message, Logger::ALERT);
113+
$this->assertLogMessage($message, Level::Alert);
113114
}
114115
}
115116
}
@@ -138,7 +139,7 @@ public function a_user_cannot_access_a_route_protected_by_role_middleware_if_hav
138139
$message = $this->helpers->getUnauthorizedRoleMessage('testRole, testRole2');
139140
$this->assertShowPermission($message, 'testRole');
140141
$this->assertShowPermission($message, 'testRole2');
141-
$this->assertLogMessage($message, Logger::ALERT);
142+
$this->assertLogMessage($message, Level::Alert);
142143
}
143144
}
144145
}
@@ -166,7 +167,7 @@ public function a_user_cannot_access_a_route_protected_by_role_middleware_if_rol
166167
config('permission.display_permission_in_exception', $show_permission);
167168
$message = $this->helpers->getUnauthorizedRoleMessage('test');
168169
$this->assertShowPermission($message, 'test');
169-
$this->assertLogMessage($message, Logger::ALERT);
170+
$this->assertLogMessage($message, Level::Alert);
170171
}
171172
}
172173
}
@@ -188,7 +189,7 @@ public function a_guest_cannot_access_a_route_protected_by_the_permission_middle
188189
);
189190

190191
$message = $this->helpers->getUserNotLoggedINMessage();
191-
$this->assertLogMessage($message, Logger::ALERT);
192+
$this->assertLogMessage($message, Level::Alert);
192193
}
193194
}
194195

@@ -257,7 +258,7 @@ public function a_user_cannot_access_a_route_protected_by_the_permission_middlew
257258
config('permission.display_permission_in_exception', $show_permission);
258259
$message = $this->helpers->getUnauthorizedPermissionMessage('edit-news');
259260
$this->assertShowPermission($message, 'edit-news');
260-
$this->assertLogMessage($message, Logger::ALERT);
261+
$this->assertLogMessage($message, Level::Alert);
261262
}
262263
}
263264
}
@@ -286,7 +287,7 @@ public function a_user_cannot_access_a_route_protected_by_permission_middleware_
286287
$message = $this->helpers->getUnauthorizedPermissionMessage('edit-articles, edit-news');
287288
$this->assertShowPermission($message, 'edit-articles');
288289
$this->assertShowPermission($message, 'edit-news');
289-
$this->assertLogMessage($message, Logger::ALERT);
290+
$this->assertLogMessage($message, Level::Alert);
290291
}
291292
}
292293
}

tests/PermissionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Maklad\Permission\Exceptions\PermissionAlreadyExists;
66
use Maklad\Permission\Models\Permission;
7+
use Monolog\Level;
78
use Monolog\Logger;
89

910
class PermissionTest extends TestCase
@@ -23,7 +24,7 @@ public function it_throws_an_exception_when_the_permission_already_exists()
2324
\app(\config('permission.models.permission'))->create(['name' => 'test-permission']);
2425
} finally {
2526
$message = $this->helpers->getPermissionAlreadyExistsMessage('test-permission', 'web');
26-
$this->assertLogMessage($message, Logger::ALERT);
27+
$this->assertLogMessage($message, Level::Alert);
2728
}
2829
}
2930
}

tests/RoleTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Maklad\Permission\Exceptions\RoleAlreadyExists;
88
use Maklad\Permission\Models\Permission;
99
use Maklad\Permission\Models\Role;
10+
use Monolog\Level;
1011
use Monolog\Logger;
1112

1213
class RoleTest extends TestCase
@@ -50,7 +51,7 @@ public function it_throws_an_exception_when_the_role_already_exists()
5051
\app(\config('permission.models.role'))->create(['name' => 'test-role']);
5152
} finally {
5253
$message = $this->helpers->getRoleAlreadyExistsMessage('test-role', 'web');
53-
$this->assertLogMessage($message, Logger::ALERT);
54+
$this->assertLogMessage($message, Level::Alert);
5455
}
5556
}
5657
}
@@ -77,7 +78,7 @@ public function it_throws_an_exception_when_given_a_permission_that_does_not_exi
7778
$this->testUserRole->givePermissionTo('create-evil-empire');
7879
} finally {
7980
$message = $this->helpers->getPermissionDoesNotExistMessage('create-evil-empire', 'web');
80-
$this->assertLogMessage($message, Logger::ALERT);
81+
$this->assertLogMessage($message, Level::Alert);
8182
}
8283
}
8384
}
@@ -96,7 +97,7 @@ public function it_throws_an_exception_when_given_a_permission_that_belongs_to_a
9697
$this->testUserRole->givePermissionTo($this->testAdminPermission);
9798
} finally {
9899
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
99-
$this->assertLogMessage($message, Logger::ALERT);
100+
$this->assertLogMessage($message, Level::Alert);
100101
}
101102
}
102103
}
@@ -147,7 +148,7 @@ public function it_throws_an_exception_when_syncing_permissions_that_do_not_exis
147148
$this->testUserRole->syncPermissions('permission-does-not-exist');
148149
} finally {
149150
$message = $this->helpers->getPermissionDoesNotExistMessage('permission-does-not-exist', 'web');
150-
$this->assertLogMessage($message, Logger::ALERT);
151+
$this->assertLogMessage($message, Level::Alert);
151152
}
152153
}
153154
}
@@ -166,7 +167,7 @@ public function it_throws_an_exception_when_syncing_permissions_that_belong_to_a
166167
$this->testUserRole->syncPermissions($this->testAdminPermission);
167168
} finally {
168169
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
169-
$this->assertLogMessage($message, Logger::ALERT);
170+
$this->assertLogMessage($message, Level::Alert);
170171
}
171172
}
172173
}
@@ -227,7 +228,7 @@ public function it_throws_an_exception_if_the_permission_does_not_exist()
227228
$this->testUserRole->hasPermissionTo('doesnt-exist');
228229
} finally {
229230
$message = $this->helpers->getPermissionDoesNotExistMessage('doesnt-exist', 'web');
230-
$this->assertLogMessage($message, Logger::ALERT);
231+
$this->assertLogMessage($message, Level::Alert);
231232
}
232233
}
233234
}
@@ -256,7 +257,7 @@ public function it_throws_an_exception_when_a_permission_of_the_wrong_guard_is_p
256257
$this->testUserRole->hasPermissionTo($permission);
257258
} finally {
258259
$message = $this->helpers->getGuardDoesNotMatchMessage(collect(['web']), 'admin');
259-
$this->assertLogMessage($message, Logger::ALERT);
260+
$this->assertLogMessage($message, Level::Alert);
260261
}
261262
}
262263
}

0 commit comments

Comments
 (0)