-
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-7557 Split ModuleSettingCest to Queries and Mutations
Signed-off-by: Anton Fedurtsya <[email protected]>
- Loading branch information
Showing
5 changed files
with
601 additions
and
605 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
|
||
abstract class BaseCest | ||
{ | ||
private const TEST_MODULE_ID = 'awesomeModule'; | ||
private const TEST_THEME_ID = 'awesomeTheme'; | ||
|
||
private const AGENT_USERNAME = '[email protected]'; | ||
|
@@ -29,11 +28,6 @@ public function _after(AcceptanceTester $I): void | |
$I->logout(); | ||
} | ||
|
||
protected function getTestModuleName(): string | ||
{ | ||
return self::TEST_MODULE_ID; | ||
} | ||
|
||
protected function getTestThemeName(): string | ||
{ | ||
return self::TEST_THEME_ID; | ||
|
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,106 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\Acceptance; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopConfigurationDao; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ShopConfigurationDaoInterface; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ShopConfiguration; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\AcceptanceTester; | ||
|
||
abstract class ModuleSettingBaseCest extends BaseCest | ||
{ | ||
protected const TEST_MODULE_ID = 'awesomeModule'; | ||
|
||
public function _before(AcceptanceTester $I): void | ||
{ | ||
$this->prepareConfiguration(); | ||
} | ||
|
||
protected function prepareConfiguration(): void | ||
{ | ||
$shopConfiguration = $this->getShopConfiguration(); | ||
|
||
$integerSetting = new Setting(); | ||
$integerSetting | ||
->setName('intSetting') | ||
->setValue(123) | ||
->setType(FieldType::NUMBER); | ||
|
||
$floatSetting = new Setting(); | ||
$floatSetting | ||
->setName('floatSetting') | ||
->setValue(1.23) | ||
->setType(FieldType::NUMBER); | ||
|
||
$booleanSetting = new Setting(); | ||
$booleanSetting | ||
->setName('boolSetting') | ||
->setValue(false) | ||
->setType(FieldType::BOOLEAN); | ||
|
||
$stringSetting = new Setting(); | ||
$stringSetting | ||
->setName('stringSetting') | ||
->setValue('default') | ||
->setType(FieldType::STRING); | ||
|
||
$collectionSetting = new Setting(); | ||
$collectionSetting | ||
->setName('arraySetting') | ||
->setValue(['nice', 'values']) | ||
->setType(FieldType::ARRAY); | ||
|
||
|
||
$moduleConfiguration = new ModuleConfiguration(); | ||
$moduleConfiguration | ||
->setId(self::TEST_MODULE_ID) | ||
->setModuleSource('testPath') | ||
->addModuleSetting($integerSetting) | ||
->addModuleSetting($floatSetting) | ||
->addModuleSetting($booleanSetting) | ||
->addModuleSetting($stringSetting) | ||
->addModuleSetting($collectionSetting); | ||
|
||
$shopConfiguration->addModuleConfiguration($moduleConfiguration); | ||
$this->getShopConfigurationDao()->save($shopConfiguration, 1); | ||
} | ||
|
||
protected function getShopConfiguration(): ShopConfiguration | ||
{ | ||
$shopConfigurationDao = $this->getShopConfigurationDao(); | ||
$shopConfiguration = $shopConfigurationDao->get(1); | ||
|
||
return $shopConfiguration; | ||
} | ||
|
||
public function _after(AcceptanceTester $I): void | ||
{ | ||
$this->removeConfiguration(self::TEST_MODULE_ID); | ||
BaseCest::_after($I); | ||
} | ||
|
||
protected function removeConfiguration(string $moduleId): void | ||
{ | ||
$shopConfiguration = $this->getShopConfiguration(); | ||
$shopConfiguration->deleteModuleConfiguration($moduleId); | ||
} | ||
|
||
protected function getShopConfigurationDao(): ShopConfigurationDao | ||
{ | ||
$container = ContainerFactory::getInstance()->getContainer(); | ||
/** @var ShopConfigurationDao $shopConfigurationDao */ | ||
$shopConfigurationDao = $container->get(ShopConfigurationDaoInterface::class); | ||
return $shopConfigurationDao; | ||
} | ||
} |
Oops, something went wrong.