Skip to content

Commit

Permalink
OXDEV-8952: Add tests for not covered classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Dec 12, 2024
1 parent bf2f233 commit 9e8603b
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 2 deletions.
25 changes: 25 additions & 0 deletions tests/Unit/Shared/Exception/CollectionEncodingExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\CollectionEncodingException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\CollectionEncodingException
*/
class CollectionEncodingExceptionTest extends TestCase
{
public function testExceptionMessage()
{
$sut = new CollectionEncodingException();
$this->assertSame('Error encountered while encoding collection data', $sut->getMessage());
}
}
26 changes: 26 additions & 0 deletions tests/Unit/Shared/Exception/InvalidCollectionExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\InvalidCollectionException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\InvalidCollectionException
*/
class InvalidCollectionExceptionTest extends TestCase
{
public function testExceptionMessage(): void
{
$value = uniqid();
$sut = new InvalidCollectionException($value);
$this->assertSame(sprintf('%s is not a valid collection string.', $value), $sut->getMessage());
}
}
25 changes: 25 additions & 0 deletions tests/Unit/Shared/Exception/WrongSettingValueExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\WrongSettingValueException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\WrongSettingValueException
*/
class WrongSettingValueExceptionTest extends TestCase
{
public function testExceptionMessage()
{
$sut = new WrongSettingValueException();
$this->assertSame('Wrong setting value', $sut->getMessage());
}
}
56 changes: 56 additions & 0 deletions tests/Unit/Shared/Subscriber/BeforeModuleDeactivationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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\Exception;

use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Event\BeforeModuleDeactivationEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Exception\ModuleSetupValidationException;
use OxidEsales\GraphQL\ConfigurationAccess\Shared\Subscriber\BeforeModuleDeactivation;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Subscriber\BeforeModuleDeactivation
*/
class BeforeModuleDeactivationTest extends TestCase
{
public function testHandle()
{
$dependencies = [];
$dependencies[] = uniqid();
$dependencies[] = uniqid();

$beforeModuleDeactivationEvent = $this->createConfiguredStub(BeforeModuleDeactivationEvent::class, [
'getModuleId' => uniqid('module')
]);

$sut = new BeforeModuleDeactivation($dependencies);
$returnEvent = $sut->handle($beforeModuleDeactivationEvent);
$this->assertSame($beforeModuleDeactivationEvent, $returnEvent);
}

public function testHandleThrowsModuleSetupValidationException()
{
$dependencies = [];
$dependencies[] = uniqid();
$dependencies[] = uniqid();

$dependenciesKey = array_rand($dependencies);
$dependency = $dependencies[$dependenciesKey];

$beforeModuleDeactivationEvent = $this->createConfiguredStub(BeforeModuleDeactivationEvent::class, [
'getModuleId' => $dependency
]);

$this->expectException(ModuleSetupValidationException::class);
$this->expectExceptionMessage((new ModuleSetupValidationException($dependency))->getMessage());

$sut = new BeforeModuleDeactivation($dependencies);
$sut->handle($beforeModuleDeactivationEvent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shared\Exception;
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shop\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\NoSettingsFoundForShopException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\NoSettingsFoundForShopException
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\NoSettingsFoundException
*/
class NoSettingsFoundForShopExceptionTest extends TestCase
{
Expand Down
26 changes: 26 additions & 0 deletions tests/Unit/Shop/Exception/WrongSettingTypeExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shop\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\NoSettingsFoundForShopException;
use OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\WrongSettingTypeException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\WrongSettingTypeException
*/
class WrongSettingTypeExceptionTest extends TestCase
{
public function testExceptionMessage(): void
{
$sut = new WrongSettingTypeException();
$this->assertSame('Wrong setting type', $sut->getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Shared\Exception;
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Theme\Exception;

use OxidEsales\GraphQL\ConfigurationAccess\Theme\Exception\NoSettingsFoundForThemeException;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Theme\Exception\NoSettingsFoundForThemeException
* @covers \OxidEsales\GraphQL\ConfigurationAccess\Shared\Exception\NoSettingsFoundException
*/
class NoSettingsFoundForThemeExceptionTest extends TestCase
{
Expand Down

0 comments on commit 9e8603b

Please sign in to comment.