-
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 Cleanup codeception tests
Signed-off-by: Anton Fedurtsya <[email protected]>
- Loading branch information
Showing
14 changed files
with
790 additions
and
1,336 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,8 @@ | |
|
||
abstract class BaseCest | ||
{ | ||
private const TEST_THEME_ID = 'awesomeTheme'; | ||
public const TEST_MODULE_ID = 'awesomeModule'; | ||
public const TEST_THEME_ID = 'awesomeTheme'; | ||
|
||
private const AGENT_USERNAME = '[email protected]'; | ||
|
||
|
@@ -52,16 +53,4 @@ protected function getAdminPassword(): string | |
{ | ||
return self::ADMIN_PASSWORD; | ||
} | ||
|
||
protected function assertQueryNotFoundErrorInResult(AcceptanceTester $I, array $result, string $query): void | ||
{ | ||
$errorMessage = $result['errors'][0]['message']; | ||
$I->assertSame('Cannot query field "' . $query . '" on type "Query".', $errorMessage); | ||
} | ||
|
||
protected function assertMutationNotFoundErrorInResult(AcceptanceTester $I, array $result, string $mutation): void | ||
{ | ||
$errorMessage = $result['errors'][0]['message']; | ||
$I->assertSame('Cannot query field "' . $mutation . '" on type "Mutation".', $errorMessage); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?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 Codeception\Attribute\DataProvider; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\AcceptanceTester; | ||
|
||
/** | ||
* @group module_setting | ||
* @group setting_access | ||
* @group oe_graphql_configuration_access | ||
*/ | ||
final class ModuleSettingGettersCest extends ModuleSettingBaseCest | ||
{ | ||
#[DataProvider('queryMethodsDataProvider')] | ||
public function testGetSettingAuthorized(AcceptanceTester $I, \Codeception\Example $example): void | ||
{ | ||
$I->login($this->getAdminUsername(), $this->getAdminPassword()); | ||
|
||
$result = $this->runSettingGetterQuery($I, $example['queryName'], $example['settingName']); | ||
|
||
$I->assertArrayNotHasKey('errors', $result); | ||
|
||
$setting = $result['data'][$example['queryName']]; | ||
$I->assertSame($example['settingName'], $setting['name']); | ||
$I->assertSame($example['expectedValue'], $setting['value']); | ||
} | ||
|
||
protected function queryMethodsDataProvider(): \Generator | ||
{ | ||
yield [ | ||
'queryName' => 'moduleSettingInteger', | ||
'settingName' => 'intSetting', | ||
'expectedValue' => 123 | ||
]; | ||
|
||
yield [ | ||
'queryName' => 'moduleSettingFloat', | ||
'settingName' => 'floatSetting', | ||
'expectedValue' => 1.23 | ||
]; | ||
|
||
yield [ | ||
'queryName' => 'moduleSettingBoolean', | ||
'settingName' => 'boolSetting', | ||
'expectedValue' => false | ||
]; | ||
|
||
yield [ | ||
'queryName' => 'moduleSettingString', | ||
'settingName' => 'stringSetting', | ||
'expectedValue' => 'default' | ||
]; | ||
|
||
yield [ | ||
'queryName' => 'moduleSettingCollection', | ||
'settingName' => 'arraySetting', | ||
'expectedValue' => '["nice","values"]' | ||
]; | ||
} | ||
|
||
private function runSettingGetterQuery(AcceptanceTester $I, string $queryName, string $settingName): array | ||
{ | ||
$I->sendGQLQuery( | ||
'query q($name: ID!, $moduleId: String!){ | ||
' . $queryName . '(name: $name, moduleId: $moduleId) { | ||
name | ||
value | ||
} | ||
}', | ||
[ | ||
'name' => $settingName, | ||
'moduleId' => self::TEST_MODULE_ID | ||
] | ||
); | ||
|
||
$I->seeResponseIsJson(); | ||
|
||
return $I->grabJsonResponseAsArray(); | ||
} | ||
} |
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,65 @@ | ||
<?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\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; | ||
use OxidEsales\GraphQL\ConfigurationAccess\Tests\Codeception\AcceptanceTester; | ||
|
||
/** | ||
* @group module_setting | ||
* @group setting_access | ||
* @group oe_graphql_configuration_access | ||
*/ | ||
final class ModuleSettingListCest extends ModuleSettingBaseCest | ||
{ | ||
public function testGetModuleSettingsListAuthorized(AcceptanceTester $I): void | ||
{ | ||
$I->login($this->getAdminUsername(), $this->getAdminPassword()); | ||
|
||
$I->sendGQLQuery( | ||
'query getSettings($moduleId: String!){ | ||
moduleSettingsList(moduleId: $moduleId) { | ||
name | ||
type | ||
supported | ||
} | ||
}', | ||
['moduleId' => self::TEST_MODULE_ID] | ||
); | ||
|
||
$I->seeResponseIsJson(); | ||
|
||
$result = $I->grabJsonResponseAsArray(); | ||
$I->assertArrayNotHasKey('errors', $result); | ||
|
||
$settingsList = $result['data']['moduleSettingsList']; | ||
$I->assertCount(5, $settingsList); | ||
$I->assertContains( | ||
['name' => 'intSetting', 'type' => FieldType::NUMBER, 'supported' => true], | ||
$settingsList | ||
); | ||
$I->assertContains( | ||
['name' => 'floatSetting', 'type' => FieldType::NUMBER, 'supported' => true], | ||
$settingsList | ||
); | ||
$I->assertContains( | ||
['name' => 'boolSetting', 'type' => FieldType::BOOLEAN, 'supported' => true], | ||
$settingsList | ||
); | ||
$I->assertContains( | ||
['name' => 'stringSetting', 'type' => FieldType::STRING, 'supported' => true], | ||
$settingsList | ||
); | ||
$I->assertContains( | ||
['name' => 'arraySetting', 'type' => FieldType::ARRAY, 'supported' => true], | ||
$settingsList | ||
); | ||
} | ||
} |
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
Oops, something went wrong.