Skip to content

Commit

Permalink
OXDEV-7557 Split ModuleSettingCest to Queries and Mutations
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Nov 13, 2023
1 parent 09607c4 commit 41bc986
Show file tree
Hide file tree
Showing 5 changed files with 601 additions and 605 deletions.
6 changes: 0 additions & 6 deletions tests/Codeception/Acceptance/BaseCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]';
Expand All @@ -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;
Expand Down
106 changes: 106 additions & 0 deletions tests/Codeception/Acceptance/ModuleSettingBaseCest.php
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;
}
}
Loading

0 comments on commit 41bc986

Please sign in to comment.