-
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-7456: Restructure tests for getting and setting integer-setting
- Loading branch information
1 parent
33c67e5
commit 99f5a62
Showing
7 changed files
with
124 additions
and
20 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
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
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
69 changes: 69 additions & 0 deletions
69
tests/Unit/Infrastructure/ChangeThemeSettingRepositoryTest.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,69 @@ | ||
<?php | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Infrastructure; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Framework\Config\Utility\ShopSettingEncoderInterface; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; | ||
use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; | ||
use OxidEsales\GraphQL\Base\Exception\NotFound; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ThemeSettingRepository; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use TheCodingMachine\GraphQLite\Types\ID; | ||
|
||
class ChangeThemeSettingRepositoryTest extends UnitTestCase | ||
{ | ||
public function testChangeThemeSettingInteger(): void | ||
{ | ||
$nameID = new ID('integerSetting'); | ||
$settingEncoder = $this->createMock(ShopSettingEncoderInterface::class); | ||
$settingEncoder->expects($this->once()) | ||
->method('encode') | ||
->with(FieldType::NUMBER, 123) | ||
->willReturn(123); | ||
|
||
$repository = $this->getMockBuilder(ThemeSettingRepository::class) | ||
->setConstructorArgs([ | ||
$this->createMock(BasicContextInterface::class), | ||
$this->createMock(EventDispatcherInterface::class), | ||
$this->createMock(QueryBuilderFactoryInterface::class), | ||
$settingEncoder | ||
]) | ||
->onlyMethods(['saveSettingValue']) | ||
->getMock(); | ||
$repository->expects($this->once()) | ||
->method('saveSettingValue') | ||
->with($nameID, 'awesomeTheme', '123'); | ||
|
||
$repository->saveIntegerSetting($nameID, 123, 'awesomeTheme'); | ||
} | ||
|
||
public function testChangeNoThemeSettingInteger(): void | ||
{ | ||
$nameID = new ID('NotExistingSetting'); | ||
$settingEncoder = $this->createMock(ShopSettingEncoderInterface::class); | ||
$settingEncoder->expects($this->once()) | ||
->method('encode') | ||
->with(FieldType::NUMBER, 123) | ||
->willReturn(123); | ||
$repository = $this->getMockBuilder(ThemeSettingRepository::class) | ||
->setConstructorArgs([ | ||
$this->createMock(BasicContextInterface::class), | ||
$this->createMock(EventDispatcherInterface::class), | ||
$this->createMock(QueryBuilderFactoryInterface::class), | ||
$settingEncoder | ||
]) | ||
->onlyMethods(['saveSettingValue']) | ||
->getMock(); | ||
$repository->expects($this->once()) | ||
->method('saveSettingValue') | ||
->with($nameID, 'awesomeTheme', '123') | ||
->willThrowException(new NotFound()); | ||
|
||
$this->expectException(NotFound::class); | ||
$this->expectExceptionMessage('The integer setting "' . $nameID->val() . '" doesn\'t exist'); | ||
|
||
$repository->saveIntegerSetting($nameID, 123, 'awesomeTheme'); | ||
} | ||
} |
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
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
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