-
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-8952: Add tests for not covered classes
- Loading branch information
1 parent
bf2f233
commit 9e8603b
Showing
7 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
tests/Unit/Shared/Exception/CollectionEncodingExceptionTest.php
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,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
26
tests/Unit/Shared/Exception/InvalidCollectionExceptionTest.php
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,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
25
tests/Unit/Shared/Exception/WrongSettingValueExceptionTest.php
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,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
56
tests/Unit/Shared/Subscriber/BeforeModuleDeactivationTest.php
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,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); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
tests/Unit/Shop/Exception/WrongSettingTypeExceptionTest.php
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,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()); | ||
} | ||
} |
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