From d5192147fe2c75c9325b436f3fc035834dd6100c Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Tue, 13 Aug 2024 14:25:52 -0400 Subject: [PATCH] Refactor test namespace to LmcTest\Rbac Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- composer.json | 2 +- .../AssertionPluginManagerFactoryTest.php | 2 +- test/Assertion/AssertionPluginManagerTest.php | 4 ++-- test/Assertion/AssertionSetTest.php | 4 ++-- test/Asset/DummyAuthorizationServiceClass.php | 2 +- test/Asset/Identity.php | 2 +- test/Asset/Permission.php | 2 +- test/Asset/Role.php | 2 +- test/Asset/SimpleAssertion.php | 2 +- test/Options/ModuleOptionsFactoryTest.php | 2 +- test/Options/ModuleOptionsTest.php | 2 +- test/Rbac/RbacTest.php | 2 +- test/Role/InMemoryRoleProviderFactoryTest.php | 2 +- test/Role/InMemoryRoleProviderTest.php | 2 +- ...bjectRepositoryRoleProviderFactoryTest.php | 2 +- .../Role/ObjectRepositoryRoleProviderTest.php | 20 +++++++++---------- test/Role/RoleTest.php | 2 +- .../AuthorizationServiceAwareTraitTest.php | 4 ++-- ...thorizationServiceDelegatorFactoryTest.php | 4 ++-- .../AuthorizationServiceFactoryTest.php | 2 +- test/Service/AuthorizationServiceTest.php | 14 +++---------- test/Service/RoleServiceFactoryTest.php | 2 +- test/Service/RoleServiceTest.php | 4 ++-- 23 files changed, 39 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index 6547f7d..d1857e6 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ }, "autoload-dev": { "psr-4": { - "LmcRbacTest\\": "test/" + "LmcTest\\Rbac\\": "test/" } }, "extra": { diff --git a/test/Assertion/AssertionPluginManagerFactoryTest.php b/test/Assertion/AssertionPluginManagerFactoryTest.php index dc04eef..45fc05a 100644 --- a/test/Assertion/AssertionPluginManagerFactoryTest.php +++ b/test/Assertion/AssertionPluginManagerFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Assertion; +namespace LmcTest\Rbac\Assertion; use Laminas\ServiceManager\ServiceManager; use Lmc\Rbac\Assertion\AssertionContainer; diff --git a/test/Assertion/AssertionPluginManagerTest.php b/test/Assertion/AssertionPluginManagerTest.php index 2fe90f4..ac5feea 100644 --- a/test/Assertion/AssertionPluginManagerTest.php +++ b/test/Assertion/AssertionPluginManagerTest.php @@ -19,14 +19,14 @@ declare(strict_types=1); -namespace LmcRbacTest\Assertion; +namespace LmcTest\Rbac\Assertion; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; use Lmc\Rbac\Assertion\AssertionInterface; use Lmc\Rbac\Assertion\AssertionPluginManager; -use LmcRbacTest\Asset\SimpleAssertion; +use LmcTest\Rbac\Asset\SimpleAssertion; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; diff --git a/test/Assertion/AssertionSetTest.php b/test/Assertion/AssertionSetTest.php index 7658599..e021ee3 100644 --- a/test/Assertion/AssertionSetTest.php +++ b/test/Assertion/AssertionSetTest.php @@ -18,7 +18,7 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Assertion; +namespace LmcTest\Rbac\Assertion; use Lmc\Rbac\Assertion\AssertionContainerInterface; use Lmc\Rbac\Assertion\AssertionInterface; @@ -27,7 +27,7 @@ use Lmc\Rbac\Assertion\AssertionSet; use Lmc\Rbac\Exception\InvalidArgumentException; use Lmc\Rbac\Identity\IdentityInterface; -use LmcRbacTest\Asset\SimpleAssertion; +use LmcTest\Rbac\Asset\SimpleAssertion; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; diff --git a/test/Asset/DummyAuthorizationServiceClass.php b/test/Asset/DummyAuthorizationServiceClass.php index 3f00084..776ab6c 100644 --- a/test/Asset/DummyAuthorizationServiceClass.php +++ b/test/Asset/DummyAuthorizationServiceClass.php @@ -16,7 +16,7 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Asset; +namespace LmcTest\Rbac\Asset; /** * @author Eric Richer diff --git a/test/Asset/Identity.php b/test/Asset/Identity.php index 5ae7931..94025c6 100644 --- a/test/Asset/Identity.php +++ b/test/Asset/Identity.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Asset; +namespace LmcTest\Rbac\Asset; use Lmc\Rbac\Identity\IdentityInterface; diff --git a/test/Asset/Permission.php b/test/Asset/Permission.php index 25b7655..4710270 100644 --- a/test/Asset/Permission.php +++ b/test/Asset/Permission.php @@ -18,7 +18,7 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Asset; +namespace LmcTest\Rbac\Asset; use Doctrine\ORM\Mapping as ORM; use Lmc\Rbac\Permission\PermissionInterface; diff --git a/test/Asset/Role.php b/test/Asset/Role.php index 3f9446b..002f6f5 100644 --- a/test/Asset/Role.php +++ b/test/Asset/Role.php @@ -18,7 +18,7 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Asset; +namespace LmcTest\Rbac\Asset; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; diff --git a/test/Asset/SimpleAssertion.php b/test/Asset/SimpleAssertion.php index 3e77162..e4f98b3 100644 --- a/test/Asset/SimpleAssertion.php +++ b/test/Asset/SimpleAssertion.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Asset; +namespace LmcTest\Rbac\Asset; use Lmc\Rbac\Assertion\AssertionInterface; use Lmc\Rbac\Identity\IdentityInterface; diff --git a/test/Options/ModuleOptionsFactoryTest.php b/test/Options/ModuleOptionsFactoryTest.php index 7886075..96fd050 100644 --- a/test/Options/ModuleOptionsFactoryTest.php +++ b/test/Options/ModuleOptionsFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Options; +namespace LmcTest\Rbac\Options; use Laminas\ServiceManager\ServiceManager; use Lmc\Rbac\Options\ModuleOptionsFactory; diff --git a/test/Options/ModuleOptionsTest.php b/test/Options/ModuleOptionsTest.php index bc07fc8..ea4fe50 100644 --- a/test/Options/ModuleOptionsTest.php +++ b/test/Options/ModuleOptionsTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Options; +namespace LmcTest\Rbac\Options; use Lmc\Rbac\Options\ModuleOptions; use PHPUnit\Framework\Attributes\CoversClass; diff --git a/test/Rbac/RbacTest.php b/test/Rbac/RbacTest.php index f6fadf1..19a6326 100644 --- a/test/Rbac/RbacTest.php +++ b/test/Rbac/RbacTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Rbac; +namespace LmcTest\Rbac\Rbac; use Lmc\Rbac\Rbac; use Lmc\Rbac\Role\Role; diff --git a/test/Role/InMemoryRoleProviderFactoryTest.php b/test/Role/InMemoryRoleProviderFactoryTest.php index 888c4bc..aec269f 100644 --- a/test/Role/InMemoryRoleProviderFactoryTest.php +++ b/test/Role/InMemoryRoleProviderFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Role; +namespace LmcTest\Rbac\Role; use Laminas\ServiceManager\ServiceManager; use Lmc\Rbac\Role\InMemoryRoleProviderFactory; diff --git a/test/Role/InMemoryRoleProviderTest.php b/test/Role/InMemoryRoleProviderTest.php index c58a925..f34166e 100644 --- a/test/Role/InMemoryRoleProviderTest.php +++ b/test/Role/InMemoryRoleProviderTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Role; +namespace LmcTest\Rbac\Role; use Lmc\Rbac\Role\InMemoryRoleProvider; use Lmc\Rbac\Role\RoleInterface; diff --git a/test/Role/ObjectRepositoryRoleProviderFactoryTest.php b/test/Role/ObjectRepositoryRoleProviderFactoryTest.php index 88048cb..bb6ede0 100644 --- a/test/Role/ObjectRepositoryRoleProviderFactoryTest.php +++ b/test/Role/ObjectRepositoryRoleProviderFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Role; +namespace LmcTest\Rbac\Role; use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectRepository; diff --git a/test/Role/ObjectRepositoryRoleProviderTest.php b/test/Role/ObjectRepositoryRoleProviderTest.php index f7eaff3..827377d 100644 --- a/test/Role/ObjectRepositoryRoleProviderTest.php +++ b/test/Role/ObjectRepositoryRoleProviderTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Role; +namespace LmcTest\Rbac\Role; use Doctrine\DBAL\DriverManager; use Doctrine\ORM\EntityManager; @@ -119,20 +119,20 @@ public function testObjectRepositoryProviderForFlatRole(array $rolesConfig, arra $objectManager = $this->getObjectManager(); foreach ($rolesConfig as $name => $roleConfig) { if (is_array($roleConfig)) { - $role = new \LmcRbacTest\Asset\Role($name); + $role = new \LmcTest\Rbac\Asset\Role($name); if (isset($roleConfig['permissions'])) { foreach ($roleConfig['permissions'] as $permission) { $role->addPermission($permission); } } } else { - $role = new \LmcRbacTest\Asset\Role($roleConfig); + $role = new \LmcTest\Rbac\Asset\Role($roleConfig); } $objectManager->persist($role); } $objectManager->flush(); - $objectRepository = $objectManager->getRepository('LmcRbacTest\Asset\Role'); + $objectRepository = $objectManager->getRepository('LmcTest\Rbac\Asset\Role'); $objectRepositoryRoleProvider = new ObjectRepositoryRoleProvider($objectRepository, 'name'); $roles = $objectRepositoryRoleProvider->getRoles($rolesToCheck); @@ -153,14 +153,14 @@ public function testObjectRepositoryProviderForFlatRoleWithPermissions() $objectManager = $this->getObjectManager(); // Let's create a role - $adminRole = new \LmcRbacTest\Asset\Role('admin'); + $adminRole = new \LmcTest\Rbac\Asset\Role('admin'); $adminRole->addPermission('manage'); $adminRole->addPermission('write'); $adminRole->addPermission('read'); $objectManager->persist($adminRole); $objectManager->flush(); - $objectRepository = $objectManager->getRepository('LmcRbacTest\Asset\Role'); + $objectRepository = $objectManager->getRepository('LmcTest\Rbac\Asset\Role'); $objectRepositoryRoleProvider = new ObjectRepositoryRoleProvider($objectRepository, 'name'); @@ -183,20 +183,20 @@ public function testObjectRepositoryProviderForHierarchicalRole() $objectManager = $this->getObjectManager(); // Let's add some roles - $guestRole = new \LmcRbacTest\Asset\Role('guest'); + $guestRole = new \LmcTest\Rbac\Asset\Role('guest'); $objectManager->persist($guestRole); - $memberRole = new \LmcRbacTest\Asset\Role('member'); + $memberRole = new \LmcTest\Rbac\Asset\Role('member'); $memberRole->addChild($guestRole); $objectManager->persist($memberRole); - $adminRole = new \LmcRbacTest\Asset\Role('admin'); + $adminRole = new \LmcTest\Rbac\Asset\Role('admin'); $adminRole->addChild($memberRole); $objectManager->persist($adminRole); $objectManager->flush(); - $objectRepository = $objectManager->getRepository('LmcRbacTest\Asset\Role'); + $objectRepository = $objectManager->getRepository('LmcTest\Rbac\Asset\Role'); $objectRepositoryRoleProvider = new ObjectRepositoryRoleProvider($objectRepository, 'name'); diff --git a/test/Role/RoleTest.php b/test/Role/RoleTest.php index 4cc1daa..37be4bc 100644 --- a/test/Role/RoleTest.php +++ b/test/Role/RoleTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Role; +namespace LmcTest\Rbac\Role; use Lmc\Rbac\Role\Role; use Lmc\Rbac\Role\RoleInterface; diff --git a/test/Service/AuthorizationServiceAwareTraitTest.php b/test/Service/AuthorizationServiceAwareTraitTest.php index ad675e0..0c1bc94 100644 --- a/test/Service/AuthorizationServiceAwareTraitTest.php +++ b/test/Service/AuthorizationServiceAwareTraitTest.php @@ -16,14 +16,14 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; /** * @author Eric Richer */ use Lmc\Rbac\Service\AuthorizationServiceInterface; -use LmcRbacTest\Asset\DummyAuthorizationServiceClass; +use LmcTest\Rbac\Asset\DummyAuthorizationServiceClass; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; diff --git a/test/Service/AuthorizationServiceDelegatorFactoryTest.php b/test/Service/AuthorizationServiceDelegatorFactoryTest.php index bb6829f..9c3305f 100644 --- a/test/Service/AuthorizationServiceDelegatorFactoryTest.php +++ b/test/Service/AuthorizationServiceDelegatorFactoryTest.php @@ -16,7 +16,7 @@ * and is licensed under the MIT license. */ -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; /** * @author Eric Richer @@ -25,7 +25,7 @@ use Laminas\ServiceManager\Exception\ServiceNotCreatedException; use Lmc\Rbac\Service\AuthorizationServiceDelegatorFactory; use Lmc\Rbac\Service\AuthorizationServiceInterface; -use LmcRbacTest\Asset\DummyAuthorizationServiceClass; +use LmcTest\Rbac\Asset\DummyAuthorizationServiceClass; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; diff --git a/test/Service/AuthorizationServiceFactoryTest.php b/test/Service/AuthorizationServiceFactoryTest.php index 7009448..d337f86 100644 --- a/test/Service/AuthorizationServiceFactoryTest.php +++ b/test/Service/AuthorizationServiceFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; use Lmc\Rbac\Assertion\AssertionContainerInterface; use Lmc\Rbac\Assertion\AssertionPluginManager; diff --git a/test/Service/AuthorizationServiceTest.php b/test/Service/AuthorizationServiceTest.php index e9258c7..29b2e52 100644 --- a/test/Service/AuthorizationServiceTest.php +++ b/test/Service/AuthorizationServiceTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; use Laminas\ServiceManager\ServiceManager; use Lmc\Rbac\Assertion\AssertionPluginManager; @@ -27,7 +27,6 @@ use Lmc\Rbac\Assertion\AssertionSet; use Lmc\Rbac\Exception\InvalidArgumentException; use Lmc\Rbac\Identity\IdentityInterface; -use Lmc\Rbac\Identity\IdentityProviderInterface; use Lmc\Rbac\Rbac; use Lmc\Rbac\RbacInterface; use Lmc\Rbac\Role\InMemoryRoleProvider; @@ -36,8 +35,8 @@ use Lmc\Rbac\Service\AuthorizationService; use Lmc\Rbac\Service\RoleService; use Lmc\Rbac\Service\RoleServiceInterface; -use LmcRbacTest\Asset\Identity; -use LmcRbacTest\Asset\SimpleAssertion; +use LmcTest\Rbac\Asset\Identity; +use LmcTest\Rbac\Asset\SimpleAssertion; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; @@ -182,13 +181,6 @@ public function testGranted($role, $permission, $context, bool $isGranted, array ]; $identity = new Identity((array) $role); - /* - $identityProvider = $this->createMock(IdentityProviderInterface::class); - - $identityProvider->expects($this->any()) - ->method('getIdentity') - ->willReturn($identity); - */ $roleService = new RoleService(new InMemoryRoleProvider($roleConfig), 'guest'); $assertionPluginManager = new AssertionPluginManager(new ServiceManager(), $assertionPluginConfig); $authorizationService = new AuthorizationService(new Rbac(), $roleService, $assertionPluginManager, $assertions); diff --git a/test/Service/RoleServiceFactoryTest.php b/test/Service/RoleServiceFactoryTest.php index 765c7f0..309576f 100644 --- a/test/Service/RoleServiceFactoryTest.php +++ b/test/Service/RoleServiceFactoryTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; use Laminas\ServiceManager\ServiceManager; use Lmc\Rbac\Options\ModuleOptions; diff --git a/test/Service/RoleServiceTest.php b/test/Service/RoleServiceTest.php index a2561fd..e67253d 100644 --- a/test/Service/RoleServiceTest.php +++ b/test/Service/RoleServiceTest.php @@ -19,7 +19,7 @@ declare(strict_types=1); -namespace LmcRbacTest\Service; +namespace LmcTest\Rbac\Service; use Lmc\Rbac\Identity\IdentityInterface; use Lmc\Rbac\Role\InMemoryRoleProvider; @@ -27,7 +27,7 @@ use Lmc\Rbac\Role\RoleInterface; use Lmc\Rbac\Role\RoleProviderInterface; use Lmc\Rbac\Service\RoleService; -use LmcRbacTest\Asset\Identity; +use LmcTest\Rbac\Asset\Identity; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Prophecy\Argument;