-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,4 +78,62 @@ public function testPolicyEntity(): void | |
self::assertNull($foundPolicy); | ||
} | ||
|
||
public function testFetchEntities(): void | ||
{ | ||
$this->generateDbSchema(); | ||
Check failure on line 83 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 83 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 83 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
$manager = $this->container->getByType(Models\Policies\Manager::class); | ||
Check failure on line 85 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 85 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 85 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
$repository = $this->container->getByType(Models\Policies\Repository::class); | ||
Check failure on line 87 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 87 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 87 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
$parentId = Uuid\Uuid::fromString('ff11f4fd-c06b-40a2-9a79-6dd3e3a10373'); | ||
|
||
$manager->create(Utils\ArrayHash::from([ | ||
'entity' => Fixtures\Entities\TestPolicyEntity::class, | ||
'parent' => $parentId, | ||
'type' => Types\PolicyType::POLICY, | ||
'v0' => '2784d750-f085-4580-8525-4d622face83d', | ||
'v1' => 'data1', | ||
'v2' => 'read', | ||
])); | ||
|
||
$manager->create(Utils\ArrayHash::from([ | ||
'entity' => Fixtures\Entities\TestPolicyEntity::class, | ||
'parent' => $parentId, | ||
'type' => Types\PolicyType::POLICY, | ||
'v0' => '2784d750-f085-4580-8525-4d622face83d', | ||
'v1' => 'data1', | ||
'v2' => 'write', | ||
])); | ||
|
||
$manager->create(Utils\ArrayHash::from([ | ||
'entity' => Fixtures\Entities\TestPolicyEntity::class, | ||
'parent' => $parentId, | ||
'type' => Types\PolicyType::POLICY, | ||
'v0' => '2784d750-f085-4580-8525-4d622face83d', | ||
'v1' => 'data1', | ||
'v2' => 'remove', | ||
])); | ||
|
||
$findQuery = new Queries\FindPolicies(); | ||
|
||
$policies = $repository->findAllBy($findQuery); | ||
Check failure on line 120 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 120 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 120 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
self::assertCount(3, $policies); | ||
|
||
$findQuery = new Queries\FindPolicies(); | ||
$findQuery->byType(Types\PolicyType::POLICY); | ||
|
||
$policies = $repository->findAllBy($findQuery); | ||
Check failure on line 127 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 127 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 127 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
self::assertCount(3, $policies); | ||
|
||
$findQuery = new Queries\FindPolicies(); | ||
$findQuery->byType(Types\PolicyType::ROLE); | ||
|
||
$policies = $repository->findAllBy($findQuery); | ||
Check failure on line 134 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.1, ubuntu-latest)
Check failure on line 134 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.2, ubuntu-latest)
Check failure on line 134 in tests/cases/unit/Models/PoliciesRepositoryTest.php GitHub Actions / Code static analysis (8.3, ubuntu-latest)
|
||
|
||
self::assertCount(0, $policies); | ||
} | ||
|
||
} |