Skip to content

Commit

Permalink
Run with shop 8.0.x, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hkreuter committed Dec 13, 2024
1 parent 1032297 commit a6df45e
Show file tree
Hide file tree
Showing 35 changed files with 247 additions and 92 deletions.
2 changes: 1 addition & 1 deletion tests/Codeception/Acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ modules:
- \OxidEsales\Codeception\Module\ShopSetup:
dump: '%DUMP_PATH%'
fixtures: '%FIXTURES_PATH%'
license: '%license_key%'
license: '%LICENSE_KEY%'
- Db:
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%;charset=utf8'
user: '%DB_USERNAME%'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @group action
* @group other
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class ActionMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/**
* @group address
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class DeliveryAddressMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* @group address
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class InvoiceAddressMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group attribute
* @group other
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class AttributeMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @group banner
* @group other
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BannerMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* @group basket
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BasketAddItemMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @group address
* @group basket
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BasketDeliveryAddressMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @group basket
* @group basket_access
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BasketMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* @group basket
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BasketRemoveMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* @group basket
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class BasketsMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group content
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class ContentMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @group country
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class CountryEnterpriseCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group currency
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class CurrencyMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/**
* @group customer
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerDeleteMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/**
* @group customer
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @group manufacturer
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class ManufacturerMultishopCest extends MultishopBaseCest
{
Expand Down
72 changes: 54 additions & 18 deletions tests/Codeception/Acceptance/MultishopBaseCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
namespace OxidEsales\GraphQL\Storefront\Tests\Codeception\Acceptance;

use Codeception\Scenario;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Model\ListModel;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Edition\Edition;
use OxidEsales\EshopCommunity\Internal\Framework\Edition\EditionDirectoriesLocator;
use OxidEsales\EshopCommunity\Internal\Framework\FileSystem\ProjectDirectoriesLocator;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface;
use OxidEsales\EshopEnterprise\Application\Controller\Admin\ShopMain;
use OxidEsales\EshopEnterprise\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationGeneratorBridgeInterface;
use OxidEsales\Facts\Facts;
use OxidEsales\GraphQL\Storefront\Tests\Codeception\AcceptanceTester;
use Psr\Container\ContainerInterface;

Expand All @@ -27,9 +33,7 @@ abstract class MultishopBaseCest extends BaseCest

public function _before(AcceptanceTester $I, Scenario $scenario): void
{
$facts = new Facts();

if (!$facts->isEnterprise()) {
if (!(new EditionDirectoriesLocator())->getEditionRootPath(Edition::Enterprise)){
$scenario->skip('Skip EE related tests for CE/PE edition');

return;
Expand All @@ -44,9 +48,8 @@ public function _after(AcceptanceTester $I): void
{
parent::_after($I);

$facts = new Facts();
if ($facts->isEnterprise()) {
$I->updateConfigInDatabaseForShops('blMallUsers', false, 'bool', [1, 2]);
if ((new EditionDirectoriesLocator())->getEditionRootPath(Edition::Enterprise)){
$I->updateInDatabase('oxconfig', ['oxvarvalue' => false], ['oxvarname' => 'blMallUsers']);
}
}

Expand All @@ -58,6 +61,16 @@ private function ensureSubshop(): void
$container->get(ShopConfigurationDaoBridgeInterface::class)->save($shopConfiguration);
$container->get(ShopConfigurationGeneratorBridgeInterface::class)->generateForShop(self::SUBSHOP_ID);

$shop = oxNew(Shop::class);
$shop->load(1);
$shop->assign(
[
'oxid' => self::SUBSHOP_ID
]
);
$shop->save();

#$this->copyConfig();
$this->copyContent();
$this->regenerateDatabaseViews();
$this->activateModule($container);
Expand All @@ -67,8 +80,7 @@ private function ensureSubshop(): void

private function regenerateDatabaseViews(): void
{
$vendorPath = (new Facts())->getVendorPath();
exec($vendorPath . '/bin/oe-eshop-db_views_generate');
exec((new ProjectDirectoriesLocator())->getVendorPath() . '/bin/oe-eshop-db_views_generate');
}

private function activateModule(ContainerInterface $container)
Expand All @@ -84,20 +96,44 @@ private function activateModule(ContainerInterface $container)
private function copyContent()
{
//copy contents
$shopContentList = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
$shopContentList = oxNew(ListModel::class);
$shopContentList->init("oxi18n", 'oxcontents');
$shopContentList->getBaseObject()->setEnableMultilang(false);

$shopContentList->selectString("select * from oxcontents where oxshopid = '1'");
foreach ($shopContentList as $shopContent) {
try {
$shopContent->oxcontents__oxshopid->setValue(self::SUBSHOP_ID);
$shopContent->delete();
$shopContent->setId();
$shopContent->save();
} catch (DatabaseErrorException $e) {
// This happen on executing multiple tests
$shopContent->oxcontents__oxshopid->setValue(self::SUBSHOP_ID);
$shopContent->setId();
$shopContent->save();
}
}

private function copyConfig(): void
{
$utilsObject = Registry::getUtilsObject();
$db = DatabaseProvider::getDb();

$selectShopConfigurationQuery =
"select oxvarname, oxvartype, oxvarvalue, oxmodule
from oxconfig where oxshopid = '1'";

$shopConfiguration = $db->select($selectShopConfigurationQuery);
if ($shopConfiguration != false && $shopConfiguration->count() > 0) {
while (!$shopConfiguration->EOF) {
$newId = $utilsObject->generateUID();
$insertNewConfigQuery =
"insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule)
values (:oxid, :oxshopid, :oxvarname, :oxvartype, :value, :oxmodule)";
$db->execute($insertNewConfigQuery, [
':oxid' => $newId,
':oxshopid' => self::SUBSHOP_ID,
':oxvarname' => $shopConfiguration->fields[0],
':oxvartype' => $shopConfiguration->fields[1],
':value' => $shopConfiguration->fields[2],
':oxmodule' => $shopConfiguration->fields[3],
]);
}
$shopConfiguration->fetchRow();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @group newsletterstatus
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class NewsletterStatusMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group newsletterstatus
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class NewsletterStatusSubscribeMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/**
* @group order
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerOrderFilesMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
use Codeception\Example;
use Codeception\Scenario;
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
use OxidEsales\Facts\Facts;
use OxidEsales\EshopCommunity\Internal\Framework\Edition\Edition;
use OxidEsales\EshopCommunity\Internal\Framework\Edition\EditionDirectoriesLocator;
use OxidEsales\GraphQL\Storefront\Tests\Codeception\Acceptance\BaseCest;
use OxidEsales\GraphQL\Storefront\Tests\Codeception\AcceptanceTester;

Expand Down Expand Up @@ -500,9 +501,7 @@ private function assertInvoiceAddress(AcceptanceTester $I, array $address): void
'state' => null,
];

$facts = new Facts();

if ($facts->getEdition() !== 'EE') {
if (!(new EditionDirectoriesLocator())->getEditionRootPath(Edition::Enterprise)){
$expected['vatID'] = '';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/**
* @group order
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerOrderHistoryMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/**
* @group order
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerOrderItemsMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/**
* @group order
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class CustomerOrderPaymentMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @group product
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class ProductMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @group promotion
* @group other
* @group oe_graphql_storefront
* @group oe_graphql_storefront_multishop
*/
final class PromotionMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group review
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class ReviewMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @group vendor
* @group oe_graphql_storefront
* @group other
* @group oe_graphql_storefront_multishop
*/
final class VendorMultishopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @group voucher
* @group oe_graphql_storefront
* @group pricing
* @group oe_graphql_storefront_multishop
*/
final class VoucherMultiShopCest extends MultishopBaseCest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @group wishedprice
* @group oe_graphql_storefront
* @group pricing
* @group oe_graphql_storefront_multishop
*/
final class WishedPriceMultiShopCest extends MultishopBaseCest
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Codeception/Acceptance/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
declare(strict_types=1);

// This is acceptance bootstrap
use OxidEsales\EshopCommunity\Internal\Framework\FileSystem\ProjectRootLocator;
use Symfony\Component\Filesystem\Path;

require_once Path::join((new \OxidEsales\Facts\Facts())->getShopRootPath(), 'source', 'bootstrap.php');
require_once Path::join((new ProjectRootLocator())->getProjectRoot(), 'source', 'bootstrap.php');
Loading

0 comments on commit a6df45e

Please sign in to comment.