Skip to content

Commit

Permalink
OXDEV-8215 Improved unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RahatHameed committed Jul 4, 2024
1 parent 7cb9dcc commit 89c91f6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/Unit/Shared/Service/NamespaceMapperTest.php
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();
}
}
30 changes: 30 additions & 0 deletions tests/Unit/Shared/Service/PermissionProviderTest.php
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);
}
}

0 comments on commit 89c91f6

Please sign in to comment.