Skip to content

Commit 82be113

Browse files
committed
WIP: working on tests.
1 parent 6aa6828 commit 82be113

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

database/seeders/OwnedBySeeder.php

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

55
namespace GeneaLabs\LaravelGovernor\Database\Seeders;
66

7+
use GeneaLabs\LaravelGovernor\Policies\BasePolicy;
78
use GeneaLabs\LaravelGovernor\Traits\EntityManagement;
89
use GeneaLabs\LaravelGovernor\Traits\GovernorOwnedByField;
910
use Illuminate\Database\Seeder;
@@ -17,7 +18,7 @@ public function run()
1718
{
1819
$this->getPolicies()
1920
->each(function ($policy) {
20-
if (! is_subclass_of($policy, BasePolicy::class)) {
21+
if (! collect(class_parents($policy))->contains(BasePolicy::class)) {
2122
return collect();
2223
}
2324

phpunit.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="true"
12+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
13+
>
314
<coverage processUncoveredFiles="true">
415
<include>
516
<directory suffix=".php">./src</directory>

src/Http/Middleware/ParseCustomPolicyActions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function registerCustomPolicyActions(): void
2828
$this
2929
->getPolicies()
3030
->map(function (string $policyClass, string $modelClass): Collection {
31-
if (! is_subclass_of($policyClass, BasePolicy::class)) {
31+
if (! collect(class_parents($policyClass))->contains(BasePolicy::class)) {
3232
return collect();
3333
}
3434

src/Policies/BasePolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function validatePermissions(
122122
$user = $this->createGuestUser();
123123
}
124124

125-
$user->loadMissing("roles", "teams.permision");
125+
$user->loadMissing("roles", "teams.permissions");
126126

127127
if ($user->hasRole("SuperAdmin")) {
128128
return true;

tests/Integration/Policies/BasePolicyTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<?php namespace GeneaLabs\LaravelGovernor\Tests\Integration\Policies;
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace GeneaLabs\LaravelGovernor\Tests\Integration\Policies;
26

37
use GeneaLabs\LaravelGovernor\Permission;
48
use GeneaLabs\LaravelGovernor\Team;

tests/database/database.sqlite

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)