First upload

This commit is contained in:
Nikolai Fesenko
2025-02-02 13:37:56 +01:00
commit 8d227c9191
3281 changed files with 362319 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Acceptance;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\AcceptanceTester;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\Module\Config;
abstract class BaseCest
{
private $configBackup;
public function _before(AcceptanceTester $I, Config $configModule): void
{
$this->configBackup = $configModule->getConfiguration();
$this->prepareConfiguration($configModule);
$I->saveShopConfVar('string', 'usercentricsId', '3j0TmWxNS', 1, 'module:oxps_usercentrics');
$I->saveShopConfVar('string', 'usercentricsMode', 'CmpV2', 1, 'module:oxps_usercentrics');
$I->saveShopConfVar('bool', 'developmentAutomaticConsent', false, 1, 'module:oxps_usercentrics');
$I->clearShopCache();
}
public function _after(AcceptanceTester $I, Config $configModule): void
{
$configModule->putConfiguration($this->configBackup);
$I->saveShopConfVar('string', 'usercentricsId', '', 1, 'module:oxps_usercentrics');
}
/**
* Prepare some test configuration before tests
*/
protected function prepareConfiguration(Config $configModule)
{
}
protected function waitForUserCentrics($I, $accept = false)
{
$I->waitForElement("#usercentrics-root", 10);
$I->waitForJS("return typeof UC_UI !== 'undefined' && UC_UI !== null && UC_UI.isInitialized()");
if ($accept) {
$I->executeJS("UC_UI.acceptAllConsents() && UC_UI.restartCMP()");
}
}
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Acceptance;
use OxidEsales\Codeception\Page\Home;
use OxidProfessionalServices\Usercentrics\DataObject\Configuration;
use OxidProfessionalServices\Usercentrics\DataObject\Script;
use OxidProfessionalServices\Usercentrics\DataObject\Service;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\AcceptanceTester;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\Module\Config;
final class ScriptIncludeAdjustementCest extends BaseCest
{
/**
* @param AcceptanceTester $I
* @group usercentrics
*/
public function scriptIncludeDecoratedNotAccepted(AcceptanceTester $I)
{
$homePage = new Home($I);
$I->amOnPage($homePage->URL);
$I->seeElementInDOM("//script[@type='text/plain'][@data-usercentrics='testcustomservice']");
$this->waitForUserCentrics($I, false);
$I->seeElementInDOM("//script[@type='text/plain'][@data-usercentrics='testcustomservice']");
}
/**
* @param AcceptanceTester $I
* @group usercentrics
*/
public function scriptIncludeDecoratedAccepted(AcceptanceTester $I)
{
$homePage = new Home($I);
$I->amOnPage($homePage->URL);
$I->seeElementInDOM("//script[@type='text/plain'][@data-usercentrics='testcustomservice']");
$this->waitForUserCentrics($I, true);
$I->dontSeeElementInDOM("//script[@type='text/plain'][@data-usercentrics='testcustomservice']");
}
/**
* Prepare some test configuration before tests
*/
protected function prepareConfiguration(Config $configModule)
{
$config = new Configuration(
[ //services
new Service('testcustomservice', 'testcustomservice')
],
[ //scripts
new Script('.min.js', 'testcustomservice')
],
[]
);
$configModule->putConfiguration($config);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Acceptance;
use OxidEsales\Codeception\Page\Home;
use OxidEsales\Codeception\Step\Basket as BasketSteps;
use OxidProfessionalServices\Usercentrics\DataObject\Configuration;
use OxidProfessionalServices\Usercentrics\DataObject\ScriptSnippet;
use OxidProfessionalServices\Usercentrics\DataObject\Service;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\AcceptanceTester;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\Module\Config;
final class ScriptSnippetAdjustementCest extends BaseCest
{
/**
* @param AcceptanceTester $I
* @group usercentrics
*/
public function scriptIncludeDecorated(AcceptanceTester $I, Config $configModule)
{
$homePage = new Home($I);
$I->amOnPage($homePage->URL);
$basketSteps = new BasketSteps($I);
$basketSteps->addProductToBasketAndOpenBasket('dc5ffdf380e15674b56dd562a7cb6aec', 1);
$value = $I->grabAttributeFrom("//script[@data-oxid][1]", "data-oxid");
$this->prepareSpecialConfiguration($configModule, $value);
$I->reloadPage();
$I->waitForElement("//script[@data-oxid='{$value}'][@data-usercentrics='testcustomservice'][@type='text/plain']");
// Accept cookie policy
$this->waitForUserCentrics($I, true);
$I->waitForElement("//script[@data-oxid='{$value}'][@type='text/javascript']");
}
/**
* Prepare some test configuration before tests
*/
protected function prepareSpecialConfiguration(Config $configModule, string $value): void
{
$config = new Configuration(
[ //services
new Service('testcustomservice', 'testcustomservice')
],
[],
[ //snippets
new ScriptSnippet($value, 'testcustomservice')
]
);
$configModule->putConfiguration($config);
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Acceptance;
use OxidEsales\Codeception\Page\Home;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\AcceptanceTester;
final class UsercentricsButtonCest extends BaseCest
{
/**
* @param AcceptanceTester $I
* @throws \Exception
* @group usercentrics
*/
public function frontPageWorksAndShowsUserCentricsWallOrBanner(AcceptanceTester $I)
{
$homePage = new Home($I);
$I->amOnPage($homePage->URL);
$this->waitForUserCentrics($I);
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Acceptance;
use OxidEsales\Codeception\Page\Home;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\AcceptanceTester;
use OxidProfessionalServices\Usercentrics\Tests\Codeception\Module\Config;
final class UsercentricsDeactivateBlockingCest extends BaseCest
{
public function _before(AcceptanceTester $I, Config $configModule): void
{
parent::_before($I, $configModule);
$I->saveShopConfVar(
'string',
'smartDataProtectorDeactivateBlocking',
'xxx , yyy',
1,
'module:oxps_usercentrics'
);
}
public function _after(AcceptanceTester $I, Config $configModule): void
{
parent::_after($I, $configModule);
$I->saveShopConfVar(
'string',
'smartDataProtectorDeactivateBlocking',
'',
1,
'module:oxps_usercentrics'
);
}
/**
* @param AcceptanceTester $I
* @throws \Exception
* @group usercentrics
*/
public function protectorBlockingDeactivationConfigurationPresent(AcceptanceTester $I)
{
$homePage = new Home($I);
$I->amOnPage($homePage->URL);
$I->seeInSource('<script>uc.deactivateBlocking(["xxx", "yyy"]);</script>');
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
// This is acceptance bootstrap
$helper = new \OxidEsales\Codeception\Module\FixturesHelper();
$helper->loadRuntimeFixtures(dirname(__FILE__) . '/../_data/fixtures.php');

View File

@@ -0,0 +1,86 @@
<?php
// phpcs:disable
declare(strict_types=1);
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
use OxidEsales\Facts\Facts;
use OxidEsales\Eshop\Core\ConfigFile;
use OxidEsales\TestingLibrary\Services\Library\DatabaseDefaultsFileGenerator;
$facts = new Facts();
$phpBinEnv = (getenv('PHPBIN')) ? : 'php';
$screenShotPathEnv = getenv('CC_SCREEN_SHOTS_PATH');
$screenShotPathEnv = ($screenShotPathEnv) ? : '';
return [
'SHOP_URL' => $facts->getShopUrl(),
'SHOP_SOURCE_PATH' => $facts->getSourcePath(),
'VENDOR_PATH' => $facts->getVendorPath(),
'DB_NAME' => $facts->getDatabaseName(),
'DB_USERNAME' => $facts->getDatabaseUserName(),
'DB_PASSWORD' => $facts->getDatabasePassword(),
'DB_HOST' => $facts->getDatabaseHost(),
'DB_PORT' => $facts->getDatabasePort(),
'DUMP_PATH' => getTestDataDumpFilePath(),
'MYSQL_CONFIG_PATH' => getMysqlConfigPath(),
'SELENIUM_SERVER_PORT' => getenv('SELENIUM_SERVER_PORT') ?: '4444',
'SELENIUM_SERVER_IP' => getenv('SELENIUM_SERVER_IP') ?: 'selenium',
'BROWSER_NAME' => getenv('BROWSER_NAME') ?: 'chrome',
'PHP_BIN' => $phpBinEnv,
'SCREEN_SHOT_URL' => $screenShotPathEnv
];
function getTestDataDumpFilePath()
{
return getShopTestPath() . '/Codeception/_data/dump.sql';
}
function getShopSuitePath($facts)
{
$testSuitePath = getenv('TEST_SUITE');
if (!$testSuitePath) {
$testSuitePath = $facts->getShopRootPath() . '/tests';
}
return $testSuitePath;
}
function getShopTestPath()
{
$facts = new Facts();
$shopTestPath = getShopSuitePath($facts);
return $shopTestPath;
}
function getMysqlConfigPath()
{
$facts = new Facts();
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
$generator = new DatabaseDefaultsFileGenerator($configFile);
return $generator->generate();
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Module;
use Codeception\Lib\Interfaces\DependsOnModule;
use OxidProfessionalServices\Usercentrics\DataObject\Configuration;
use OxidProfessionalServices\Usercentrics\Service\Configuration\ConfigurationDao;
use OxidProfessionalServices\Usercentrics\Service\Configuration\YamlStorage;
/**
* Class Config
*/
class Config extends \Codeception\Module implements DependsOnModule
{
protected $requiredFields = ['shop_path', 'config_file'];
protected $config = [
'shop_path' => '',
'config_file' => ''
];
public function _depends()
{
return [];
}
private function getConfigManager(): ConfigurationDao
{
$storage = new YamlStorage(
$this->config['shop_path'],
$this->config['config_file']
);
return new ConfigurationDao($storage);
}
public function getConfiguration(): Configuration
{
$configManager = $this->getConfigManager();
return $configManager->getConfiguration();
}
public function putConfiguration(Configuration $configuration): void
{
$configManager = $this->getConfigManager();
$configManager->putConfiguration($configuration);
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
return [
];

View File

@@ -0,0 +1,53 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception;
/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
public function saveShopConfVar($sVarType, $sVarName, $sVarVal, $sShopId = null, $sModule = '')
{
$config = \OxidEsales\Eshop\Core\Registry::getConfig();
$config->saveShopConfVar($sVarType, $sVarName, $sVarVal, $sShopId, $sModule);
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* This file is part of O3-Shop Usercentrics Cookie Compliance module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidProfessionalServices\Usercentrics\Tests\Codeception\Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
}

View File

@@ -0,0 +1,41 @@
# suite config
actor: AcceptanceTester
path: Acceptance
bootstrap: _bootstrap.php
modules:
enabled:
- Asserts
- WebDriver:
url: '%SHOP_URL%'
host: '%SELENIUM_SERVER_IP%'
browser: '%BROWSER_NAME%'
port: '%SELENIUM_SERVER_PORT%'
window_size: 1920x1080
clear_cookies: true
- Db:
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%;charset=utf8'
user: '%DB_USERNAME%'
password: '%DB_PASSWORD%'
port: '%DB_PORT%'
dump: '%DUMP_PATH%'
populate: false # run populator before all tests
cleanup: false # run populator before each test
populator: '%PHP_BIN% %VENDOR_PATH%/bin/reset-shop'
- \OxidEsales\Codeception\Module\Oxideshop:
screen_shot_url: '%SCREEN_SHOT_URL%'
depends:
- WebDriver
- Db
- \OxidEsales\Codeception\Module\OxideshopAdmin:
depends:
- WebDriver
- \OxidEsales\Codeception\Module\Oxideshop
- \OxidEsales\Codeception\Module\Database:
config_key: 'fq45QS09_fqyx09239QQ'
depends: Db
- \OxidEsales\Codeception\Module\Translation\TranslationsModule:
shop_path: '%SHOP_SOURCE_PATH%'
paths: 'Application/views/flow'
- \OxidProfessionalServices\Usercentrics\Tests\Codeception\Module\Config:
shop_path: '%SHOP_SOURCE_PATH%'
config_file: '../var/configuration/usercentrics.yaml'