Skip to content

Commit

Permalink
OXDEV-8215: Use constants in NamespaceMapperTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Aug 8, 2024
1 parent 0bd3194 commit d35848b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions tests/Unit/Shared/Service/NamespaceMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@

class NamespaceMapperTest extends TestCase
{
protected string $namespacePrefix;
private const NAMESPACE_PREFIX = '\\OxidEsales\\GraphQL\\ConfigurationAccess';

protected string $srcPath;
private static string $srcPath;

protected function setUp(): void
public static function setUpBeforeClass(): void
{
$this->srcPath = $this->getSrcDirectoryPath();
$this->namespacePrefix = '\\OxidEsales\\GraphQL\\ConfigurationAccess';
self::$srcPath = self::getSrcDirectoryPath();
}

public function testGetControllerNamespaceMapping(): void
{
$expectedMapping = [
$this->namespacePrefix . '\\Module\\Controller' =>
$this->srcPath . '/Shared/Service/../../Module/Controller/',
$this->namespacePrefix . '\\Shop\\Controller' =>
$this->srcPath . '/Shared/Service/../../Shop/Controller/',
$this->namespacePrefix . '\\Theme\\Controller' =>
$this->srcPath . '/Shared/Service/../../Theme/Controller/',
self::NAMESPACE_PREFIX . '\\Module\\Controller' =>
self::$srcPath . '/Shared/Service/../../Module/Controller/',
self::NAMESPACE_PREFIX . '\\Shop\\Controller' =>
self::$srcPath . '/Shared/Service/../../Shop/Controller/',
self::NAMESPACE_PREFIX . '\\Theme\\Controller' =>
self::$srcPath . '/Shared/Service/../../Theme/Controller/',
];

$sut = $this->getSut();
Expand All @@ -44,12 +43,12 @@ public function testGetControllerNamespaceMapping(): void
public function testGetTypeNamespaceMapping(): void
{
$expectedMapping = [
$this->namespacePrefix . '\\Shared\\DataType' =>
$this->srcPath . '/Shared/Service/../../Shared/DataType/',
$this->namespacePrefix . '\\Theme\\DataType' =>
$this->srcPath . '/Shared/Service/../../Theme/DataType/',
$this->namespacePrefix . '\\Module\\DataType' =>
$this->srcPath . '/Shared/Service/../../Module/DataType/',
self::NAMESPACE_PREFIX . '\\Shared\\DataType' =>
self::$srcPath . '/Shared/Service/../../Shared/DataType/',
self::NAMESPACE_PREFIX . '\\Theme\\DataType' =>
self::$srcPath . '/Shared/Service/../../Theme/DataType/',
self::NAMESPACE_PREFIX . '\\Module\\DataType' =>
self::$srcPath . '/Shared/Service/../../Module/DataType/',
];

$sut = $this->getSut();
Expand All @@ -58,7 +57,7 @@ public function testGetTypeNamespaceMapping(): void
$this->assertSame($expectedMapping, $actualMapping);
}

private function getSrcDirectoryPath(): string
private static function getSrcDirectoryPath(): string
{
$testsDir = 'tests';
$currentPath = __DIR__;
Expand Down

0 comments on commit d35848b

Please sign in to comment.