From 461a8d09177fa7b28029aa0114dce2b89f47e98e Mon Sep 17 00:00:00 2001 From: RahatHameed Date: Wed, 15 May 2024 14:00:24 +0200 Subject: [PATCH] OXDEV-8234 Update directory structure by Codeception 5 recommendation --- composer.json | 13 ++++--- ...eptance.suite.yml => Acceptance.suite.yml} | 1 + .../AcceptanceTester.php | 2 +- .../{_data => Support/Data}/.gitkeep | 0 .../{_data => Support/Data}/dump.sql | 0 .../{_data => Support/Data}/fixtures.php | 0 .../{_data => Support/Data}/fixtures_ee.php | 0 .../Codeception/Support/Helper/Acceptance.php | 15 ++++++++ .../Step/Acceptance/Basket.php | 4 +-- tests/Codeception/_output/.gitkeep | 0 .../_support/Helper/Acceptance.php | 35 ------------------- .../Codeception/_support/_generated/.gitkeep | 0 tests/Codeception/acceptance/FrontendCest.php | 1 + tests/Codeception/acceptance/_bootstrap.php | 4 +-- tests/Codeception/config/params.php | 10 +++--- tests/codeception.yml | 9 ++--- 16 files changed, 41 insertions(+), 53 deletions(-) rename tests/Codeception/{acceptance.suite.yml => Acceptance.suite.yml} (99%) rename tests/Codeception/{_support => Support}/AcceptanceTester.php (95%) rename tests/Codeception/{_data => Support/Data}/.gitkeep (100%) rename tests/Codeception/{_data => Support/Data}/dump.sql (100%) rename tests/Codeception/{_data => Support/Data}/fixtures.php (100%) rename tests/Codeception/{_data => Support/Data}/fixtures_ee.php (100%) create mode 100644 tests/Codeception/Support/Helper/Acceptance.php rename tests/Codeception/{_support => Support}/Step/Acceptance/Basket.php (89%) delete mode 100644 tests/Codeception/_output/.gitkeep delete mode 100644 tests/Codeception/_support/Helper/Acceptance.php delete mode 100644 tests/Codeception/_support/_generated/.gitkeep diff --git a/composer.json b/composer.json index 37f2b66..7132d72 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,14 @@ "phpunit/phpunit": "^10.4", "oxid-esales/oxideshop-ce": "dev-b-7.1.x", "mikey179/vfsstream": "~1.6.8", - "codeception/module-rest": "*", - "codeception/module-phpbrowser": "*", - "codeception/module-db": "*", "codeception/codeception": "^5.0", - "oxid-esales/codeception-modules": "dev-b-7.1.x" + "codeception/module-asserts": "*", + "codeception/module-db": "*", + "codeception/module-filesystem": "*", + "codeception/module-webdriver": "*", + "oxid-esales/codeception-modules": "dev-b-7.1.x", + "oxid-esales/codeception-page-objects": "dev-b-7.1.x", + "webmozart/path-util": "*" }, "autoload": { "psr-4": { @@ -38,7 +41,7 @@ "tests-codeception": [ "Composer\\Config::disableProcessTimeout", - "MODULE_IDS=oe_graphql_base SHOP_ROOT_PATH=/var/www vendor/bin/codecept run Acceptance -c tests/codeception.yml --no-redirect" + "THEME_ID=apex MODULE_IDS=oegeoblocking SHOP_ROOT_PATH=/var/www vendor/bin/codecept run Acceptance -c tests/codeception.yml --no-redirect" ] }, diff --git a/tests/Codeception/acceptance.suite.yml b/tests/Codeception/Acceptance.suite.yml similarity index 99% rename from tests/Codeception/acceptance.suite.yml rename to tests/Codeception/Acceptance.suite.yml index 5a171e2..deab000 100644 --- a/tests/Codeception/acceptance.suite.yml +++ b/tests/Codeception/Acceptance.suite.yml @@ -5,6 +5,7 @@ # If you need both WebDriver and PHPBrowser tests - create a separate suite. actor: AcceptanceTester +path: Acceptance modules: enabled: - Asserts diff --git a/tests/Codeception/_support/AcceptanceTester.php b/tests/Codeception/Support/AcceptanceTester.php similarity index 95% rename from tests/Codeception/_support/AcceptanceTester.php rename to tests/Codeception/Support/AcceptanceTester.php index 71d7e2c..9b1508a 100644 --- a/tests/Codeception/_support/AcceptanceTester.php +++ b/tests/Codeception/Support/AcceptanceTester.php @@ -4,7 +4,7 @@ * See LICENSE file for license details. */ -namespace OxidEsales\GeoBlocking\Tests\Codeception; +namespace OxidEsales\GeoBlocking\Tests\Codeception\Support; use OxidEsales\Codeception\Page\Home; use OxidEsales\Facts\Facts; diff --git a/tests/Codeception/_data/.gitkeep b/tests/Codeception/Support/Data/.gitkeep similarity index 100% rename from tests/Codeception/_data/.gitkeep rename to tests/Codeception/Support/Data/.gitkeep diff --git a/tests/Codeception/_data/dump.sql b/tests/Codeception/Support/Data/dump.sql similarity index 100% rename from tests/Codeception/_data/dump.sql rename to tests/Codeception/Support/Data/dump.sql diff --git a/tests/Codeception/_data/fixtures.php b/tests/Codeception/Support/Data/fixtures.php similarity index 100% rename from tests/Codeception/_data/fixtures.php rename to tests/Codeception/Support/Data/fixtures.php diff --git a/tests/Codeception/_data/fixtures_ee.php b/tests/Codeception/Support/Data/fixtures_ee.php similarity index 100% rename from tests/Codeception/_data/fixtures_ee.php rename to tests/Codeception/Support/Data/fixtures_ee.php diff --git a/tests/Codeception/Support/Helper/Acceptance.php b/tests/Codeception/Support/Helper/Acceptance.php new file mode 100644 index 0000000..6e4614a --- /dev/null +++ b/tests/Codeception/Support/Helper/Acceptance.php @@ -0,0 +1,15 @@ +getModulesToActivate(); - - if ($modulesToActivate) { - $serviceCaller = new \OxidEsales\TestingLibrary\ServiceCaller(); - $serviceCaller->setParameter('modulestoactivate', $modulesToActivate); - $serviceCaller->callService('ModuleInstaller', 1); - } - - } - -} diff --git a/tests/Codeception/_support/_generated/.gitkeep b/tests/Codeception/_support/_generated/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Codeception/acceptance/FrontendCest.php b/tests/Codeception/acceptance/FrontendCest.php index 1f06bed..df165a1 100644 --- a/tests/Codeception/acceptance/FrontendCest.php +++ b/tests/Codeception/acceptance/FrontendCest.php @@ -11,6 +11,7 @@ use OxidEsales\Codeception\Module\Translation\Translator; use OxidEsales\Codeception\Page\Checkout\UserCheckout; use OxidEsales\Codeception\Step\Basket; +use OxidEsales\GeoBlocking\Tests\Codeception\Support\AcceptanceTester; class FrontendCest { diff --git a/tests/Codeception/acceptance/_bootstrap.php b/tests/Codeception/acceptance/_bootstrap.php index 561699d..5f5503f 100644 --- a/tests/Codeception/acceptance/_bootstrap.php +++ b/tests/Codeception/acceptance/_bootstrap.php @@ -10,8 +10,8 @@ require_once Path::join((new \OxidEsales\Facts\Facts())->getShopRootPath(), 'source', 'bootstrap.php'); $helper = new \OxidEsales\Codeception\Module\FixturesHelper(); -$fixturesPath = dirname(__FILE__).'/../_data/fixtures.php'; +$fixturesPath = dirname(__FILE__).'/../Support/Data/fixtures.php'; if ((new Facts())->isEnterprise()) { - $fixturesPath = dirname(__FILE__).'/../_data/fixtures_ee.php'; + $fixturesPath = dirname(__FILE__).'/../Support/Data/fixtures_ee.php'; } $helper->loadRuntimeFixtures($fixturesPath); diff --git a/tests/Codeception/config/params.php b/tests/Codeception/config/params.php index d48cbe8..cc8a911 100755 --- a/tests/Codeception/config/params.php +++ b/tests/Codeception/config/params.php @@ -4,13 +4,15 @@ * See LICENSE file for license details. */ -namespace OxidEsales\DoctrineMigrationWrapper; - use OxidEsales\Facts\Config\ConfigFile; use OxidEsales\Facts\Facts; use OxidEsales\Codeception\Module\Database\DatabaseDefaultsFileGenerator; use Webmozart\PathUtil\Path; +if ($shopRootPath = getenv('SHOP_ROOT_PATH')){ + require_once(Path::join($shopRootPath, 'source', 'bootstrap.php')); +} + $facts = new Facts(); $seleniumServerPort = getenv('SELENIUM_SERVER_PORT'); @@ -38,7 +40,7 @@ function getTestDataDumpFilePath() { - return getShopTestPath() . '/Codeception/_data/dump.sql'; + return Path::join(__DIR__, '/../', 'Support','Data', 'dump.sql'); } function getShopTestPath() @@ -67,7 +69,7 @@ function getShopSuitePath($facts) function getModuleTestDataDumpFilePath() { - return __DIR__ . '/../_data/dump.sql'; + return __DIR__ . '/../Support/Data/dump.sql'; } function getMysqlConfigPath() diff --git a/tests/codeception.yml b/tests/codeception.yml index b5de838..2e76b77 100644 --- a/tests/codeception.yml +++ b/tests/codeception.yml @@ -1,13 +1,14 @@ namespace: OxidEsales\GeoBlocking\Tests\Codeception +support_namespace: Support params: - Codeception/config/params.php paths: tests: Codeception - output: Codeception/_output - data: Codeception/_data - support: Codeception/_support + output: Codeception/Output + data: Codeception/Support/Data + support: Codeception/Support envs: Codeception/_envs -actor_suffix: Tester + actor_suffix: Tester settings: colors: true log: true