-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OXDEV-8215 Improved unit test coverage
- Loading branch information
1 parent
7cb9dcc
commit 89c91f6
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shared\Service; | ||
|
||
use OxidEsales\GraphQL\ConfigurationAccess\Shared\Service\NamespaceMapper; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NamespaceMapperTest extends TestCase | ||
{ | ||
public const PATH_TO_MAPPER = '/var/www/vendor/oxid-esales/graphql-configuration-access/src/Shared/Service'; | ||
public const NAMESPACE_PREFIX = '\\OxidEsales\\GraphQL\\ConfigurationAccess'; | ||
|
||
public function testGetControllerNamespaceMapping(): void | ||
{ | ||
|
||
$expectedMapping = [ | ||
self::NAMESPACE_PREFIX . '\\Module\\Controller' => self::PATH_TO_MAPPER . '/../../Module/Controller/', | ||
self::NAMESPACE_PREFIX . '\\Shop\\Controller' => self::PATH_TO_MAPPER . '/../../Shop/Controller/', | ||
self::NAMESPACE_PREFIX . '\\Theme\\Controller' => self::PATH_TO_MAPPER . '/../../Theme/Controller/', | ||
]; | ||
|
||
$sut = $this->getSut(); | ||
$actualMapping = $sut->getControllerNamespaceMapping(); | ||
|
||
$this->assertSame($expectedMapping, $actualMapping); | ||
} | ||
|
||
public function testGetTypeNamespaceMapping(): void | ||
{ | ||
$expectedMapping = [ | ||
self::NAMESPACE_PREFIX . '\\Shared\\DataType' => self::PATH_TO_MAPPER . '/../../Shared/DataType/', | ||
self::NAMESPACE_PREFIX . '\\Module\\DataType' => self::PATH_TO_MAPPER . '/../../Module/DataType/', | ||
]; | ||
|
||
$sut = $this->getSut(); | ||
$actualMapping = $sut->getTypeNamespaceMapping(); | ||
|
||
$this->assertSame($expectedMapping, $actualMapping); | ||
} | ||
|
||
private function getSut(): NamespaceMapper | ||
{ | ||
return new NamespaceMapper(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shared\Service; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Shared\Service\PermissionProvider; | ||
|
||
class PermissionProviderTest extends TestCase | ||
{ | ||
public function testGetPermissions(): void | ||
{ | ||
$expectedPermissions = [ | ||
'oxidadmin' => [ | ||
'CHANGE_CONFIGURATION' | ||
], | ||
]; | ||
|
||
$permissionProvider = new PermissionProvider(); | ||
$actualPermissions = $permissionProvider->getPermissions(); | ||
|
||
$this->assertSame($expectedPermissions, $actualPermissions); | ||
} | ||
} |