ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Base class for override config tests.
*/
abstract class AbstractOverridesTest extends TestCase
{
/**
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$useConfig = (defined('USE_OVERRIDE_CONFIG') && USE_OVERRIDE_CONFIG === 'enabled');
if (!$useConfig) {
$this->markTestSkipped('Override config disabled.');
}
$this->objectManager = Bootstrap::getObjectManager();
}
}
@@ -0,0 +1,20 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Test abstract class for testing fixtures override config inheritance.
*
* phpcs:disable Generic.Classes.DuplicateClassName
*/
abstract class FixturesAbstractClass extends AbstractOverridesTest
{
}
@@ -0,0 +1,18 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
/**
* Test interface for testing fixtures override config inheritance.
*
* phpcs:disable Generic.Classes.DuplicateClassName
*/
interface FixturesInterface
{
}
@@ -0,0 +1,208 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class checks that fixtures override config inherited from abstract class and interface.
*
* phpcs:disable Generic.Classes.DuplicateClassName
*
* @magentoAppIsolation enabled
*/
class FixturesTest extends FixturesAbstractClass implements FixturesInterface
{
/**
* @var ScopeConfigInterface
*/
private $config;
/**
* @var FixtureCallStorage
*/
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* @magentoAdminConfigFixture test_section/test_group/field_2 new_value
* @magentoAdminConfigFixture test_section/test_group/field_3 new_value
* @magentoConfigFixture current_store test_section/test_group/field_2 new_value
* @magentoConfigFixture current_store test_section/test_group/field_3 new_value
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
* @magentoDataFixtureBeforeTransaction Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixtureBeforeTransaction Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
* @dataProvider interfaceDataProvider
* @param array $configs
* @param array $storeConfigs
* @param array $fixtures
* @return void
*/
public function testInterfaceInheritance(
array $configs,
array $storeConfigs,
array $fixtures
): void {
$this->assertConfigFieldValues($configs);
$this->assertConfigFieldValues($storeConfigs, ScopeInterface::SCOPE_STORES);
$this->assertUsedFixturesCount($fixtures);
}
/**
* @magentoAdminConfigFixture test_section/test_group/field_2 new_value
* @magentoConfigFixture current_store test_section/test_group/field_2 new_value
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixtureBeforeTransaction Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @dataProvider abstractDataProvider
* @param array $configs
* @param array $storeConfigs
* @param array $fixtures
* @return void
*/
public function testAbstractInheritance(
array $configs,
array $storeConfigs,
array $fixtures
): void {
$this->assertConfigFieldValues($configs);
$this->assertConfigFieldValues($storeConfigs, ScopeInterface::SCOPE_STORES);
$this->assertUsedFixturesCount($fixtures);
}
/**
* @return array
*/
public function interfaceDataProvider(): array
{
return [
'first_data_set' => [
'admin_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => 'overridden config fixture value for method',
'test_section/test_group/field_3' => 'new_value',
],
'store_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => 'overridden config fixture value for method',
'test_section/test_group/field_3' => 'new_value',
],
'fixtures' => [
'fixture1_first_module.php' => 2,
'fixture2_first_module.php' => 0,
'fixture2_second_module.php' => 2,
'fixture3_first_module.php' => 2,
],
],
'second_data_set' => [
'admin_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => 'overridden config fixture value for method',
'test_section/test_group/field_3' => '3rd field default value',
],
'store_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => 'overridden config fixture value for method',
'test_section/test_group/field_3' => '3rd field website scope default value',
],
'fixtures' => [
'fixture1_first_module.php' => 2,
'fixture2_first_module.php' => 0,
'fixture2_second_module.php' => 2,
'fixture3_first_module.php' => 0,
],
],
];
}
/**
* @return array
*/
public function abstractDataProvider(): array
{
return [
'first_data_set' => [
'admin_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => '2nd field default value',
'test_section/test_group/field_3' => 'overridden config fixture value for data set from abstract',
],
'store_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for class',
'test_section/test_group/field_2' => '2nd field default value',
'test_section/test_group/field_3' => 'overridden config fixture value for data set from abstract',
],
'fixtures' => [
'fixture1_first_module.php' => 2,
'fixture2_first_module.php' => 0,
'fixture2_second_module.php' => 0,
'fixture3_first_module.php' => 2,
],
],
'second_data_set' => [
'admin_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for data set from abstract',
'test_section/test_group/field_2' => '2nd field default value',
'test_section/test_group/field_3' => '3rd field default value',
],
'store_configs' => [
'test_section/test_group/field_1' => 'overridden config fixture value for data set from abstract',
'test_section/test_group/field_2' => '2nd field default value',
'test_section/test_group/field_3' => '3rd field website scope default value',
],
'fixtures' => [
'fixture1_first_module.php' => 0,
'fixture2_first_module.php' => 0,
'fixture1_second_module.php' => 2,
'fixture3_first_module.php' => 0,
],
],
];
}
/**
* Asserts config field values.
*
* @param array $configs
* @param string $scope
* @return void
*/
private function assertConfigFieldValues(
array $configs,
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
): void {
foreach ($configs as $path => $expectedValue) {
$this->assertEquals($expectedValue, $this->config->getValue($path, $scope));
}
}
/**
* Asserts count of used fixtures.
*
* @param array $fixtures
* @return void
*/
private function assertUsedFixturesCount(array $fixtures): void
{
foreach ($fixtures as $fixture => $count) {
$this->assertEquals($count, $this->fixtureCallStorage->getFixturesCount($fixture));
}
}
}
@@ -0,0 +1,20 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Skip;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Test abstract class for testing skip override config inheritance.
*
* phpcs:disable Generic.Classes.DuplicateClassName
*/
abstract class SkipAbstractClass extends AbstractOverridesTest
{
}
@@ -0,0 +1,18 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Skip;
/**
* Test interface for testing skip override config inheritance.
*
* phpcs:disable Generic.Classes.DuplicateClassName
*/
interface SkipInterface
{
}
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Inheritance\Skip;
/**
* Class checks that test method can be skipped using inherited from abstract class/interface override config
*
* phpcs:disable Generic.Classes.DuplicateClassName
*
* @magentoAppIsolation enabled
*/
class SkipTest extends SkipAbstractClass implements SkipInterface
{
/**
* @return void
*/
public function testAbstractSkip(): void
{
$this->fail('This test should be skipped via override config in method node inherited from abstract class');
}
/**
* @return void
*/
public function testInterfaceSkip(): void
{
$this->fail('This test should be skipped via override config in method node inherited from interface');
}
/**
* @dataProvider skipDataProvider
*
* @param string $message
* @return void
*/
public function testSkipDataSet(string $message): void
{
$this->fail($message);
}
/**
* @return array
*/
public function skipDataProvider(): array
{
return [
'first_data_set' => ['This test should be skipped in data set node inherited from abstract class'],
'second_data_set' => ['This test should be skipped in data set node inherited from interface'],
];
}
}
@@ -0,0 +1,68 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoAdminConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that magentoAdminConfigFixtures can be added via override config
*
* @magentoAppIsolation enabled
*/
class AddFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture added in test class node successfully applied
*
* @return void
*/
public function testAddFixtureToClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals('overridden config fixture value for full class', $value);
}
/**
* Checks that fixtures added in method and data set nodes successfully applied
*
* @dataProvider testDataProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testAddFixtureToMethod(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => ['expected_config_value' => 'overridden config fixture value for method'],
'second_data_set' => ['expected_config_value' => 'overridden config fixture value for data set']
];
}
}
@@ -0,0 +1,88 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoAdminConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that magentoAdminConfigFixtures can be removed using override config
*
* @magentoAppIsolation enabled
*/
class RemoveFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture can be removed in test class node
*
* @magentoAdminConfigFixture test_section/test_group/field_1 new_value
*
* @return void
*/
public function testRemoveFixtureForClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals('1st field default value', $value);
}
/**
* Checks that fixtures can be removed in method and data set nodes
*
* @magentoAdminConfigFixture test_section/test_group/field_2 new_value
* @magentoAdminConfigFixture test_section/test_group/field_3 new_value
*
* @dataProvider testDataProvider
*
* @param string $expectedFirstValue
* @param string $expectedSecondValue
* @return void
*/
public function testRemoveFixtureForMethod(string $expectedFirstValue, string $expectedSecondValue): void
{
$fistValue = $this->config->getValue(
'test_section/test_group/field_2',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$secondValue = $this->config->getValue(
'test_section/test_group/field_3',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->assertEquals($expectedFirstValue, $fistValue);
$this->assertEquals($expectedSecondValue, $secondValue);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => [
'expected_first_config_value' => '2nd field default value',
'expected_second_config_value' => 'new_value',
],
'second_data_set' => [
'expected_first_config_value' => '2nd field default value',
'expected_second_config_value' => '3rd field default value',
],
];
}
}
@@ -0,0 +1,107 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoAdminConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class check that fixtures can be replaced using override config
*
* @magentoAppIsolation enabled
*/
class ReplaceFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture can be replaced in test class node
*
* @magentoAdminConfigFixture test_section/test_group/field_1 new_value
*
* @return void
*/
public function testReplaceFixtureForClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals('Overridden admin config fixture for class', $value);
}
/**
* Checks that fixture can be replaced in method and data set nodes
*
* @magentoAdminConfigFixture test_section/test_group/field_1 new_value
*
* @dataProvider testDataProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testReplaceFixtureForMethod(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => [
'expected_config_value' => 'Overridden admin config fixture for method',
],
'second_data_set' => [
'expected_config_value' => 'Overridden admin config fixture for data set',
],
];
}
/**
* Checks that replace config from last loaded file will be applied
*
* @magentoAdminConfigFixture test_section/test_group/field_1 new_value
*
* @dataProvider configValuesDataProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testReplaceFixtureViaThirdModule(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function configValuesDataProvider(): array
{
return [
'first_data_set' => [
'expected_config_value' => 'Overridden admin config fixture for method from third module',
],
'second_data_set' => [
'expected_config_value' => 'Overridden admin config fixture for data set from third module',
],
];
}
}
@@ -0,0 +1,102 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that magentoConfigFixtures can be added via override config
*
* @magentoAppIsolation enabled
*/
class AddFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture added in global node successfully applied
*
* @return void
*/
public function testGloballyAddFixture(): void
{
$value = $this->config->getValue('test_section/test_group/field_4', ScopeInterface::SCOPE_STORES);
$this->assertEquals('4th field globally overridden value', $value);
}
/**
* Checks that fixture added in test class node successfully applied
*
* @return void
*/
public function testAddFixtureToClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals('overridden value for full class', $value);
}
/**
* Checks that fixtures added in method and data set nodes successfully applied
*
* @dataProvider testDataProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testAddFixtureToMethod(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => ['expected_config_value' => 'overridden value for method'],
'second_data_set' => ['expected_config_value' => 'overridden value for data set']
];
}
/**
* Checks that fixtures can be added on website scope
*
* @return void
*/
public function testAddFixtureOnWebsiteScope(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_WEBSITES);
$this->assertEquals('overridden value for method on website scope', $value);
}
/**
* Checks that fixtures can be added on website scope with specified scope code
*
* @return void
*/
public function testAddFixtureOnWebsiteScopeWithScopeCode(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_WEBSITES, 'base');
$this->assertEquals('overridden value for base website scope', $value);
}
}
@@ -0,0 +1,109 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that magentoConfigFixtures can be removed using override config
*
* @magentoAppIsolation enabled
*/
class RemoveFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture can be removed in test class node
*
* @magentoConfigFixture current_store test_section/test_group/field_1 new_value
*
* @return void
*/
public function testRemoveFixtureForClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals('1st field default value', $value);
}
/**
* Checks that fixtures can be removed in method and data set nodes
*
* @magentoConfigFixture current_store test_section/test_group/field_2 new_value
* @magentoConfigFixture current_store test_section/test_group/field_3 new_value
*
* @dataProvider testDataProvider
*
* @param string $expectedFirstValue
* @param string $expectedSecondValue
* @return void
*/
public function testRemoveFixtureForMethod(string $expectedFirstValue, string $expectedSecondValue): void
{
$fistValue = $this->config->getValue('test_section/test_group/field_2', ScopeInterface::SCOPE_STORES);
$secondValue = $this->config->getValue('test_section/test_group/field_3', ScopeInterface::SCOPE_STORES);
$this->assertEquals($expectedFirstValue, $fistValue);
$this->assertEquals($expectedSecondValue, $secondValue);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => [
'expected_first_config_value' => '2nd field default value',
'expected_second_config_value' => 'new_value',
],
'second_data_set' => [
'expected_first_config_value' => '2nd field default value',
'expected_second_config_value' => '3rd field website scope default value',
],
];
}
/**
* Checks that website scope fixture can be removed
*
* @magentoConfigFixture current_website test_section/test_group/field_3 new_value
*
* @return void
*/
public function testRemoveWebsiteScopeFixture(): void
{
$value = $this->config->getValue('test_section/test_group/field_3', ScopeInterface::SCOPE_WEBSITES);
$this->assertEquals('3rd field website scope default value', $value);
}
/**
* Checks that website scope fixture with specified scope code can be removed
*
* @magentoConfigFixture base_website test_section/test_group/field_3 new_value
*
* @return void
*/
public function testRemoveWebsiteScopeFixtureWithScopeCode(): void
{
$value = $this->config->getValue('test_section/test_group/field_3', ScopeInterface::SCOPE_WEBSITES, 'base');
$this->assertEquals('3rd field website scope default value', $value);
}
}
@@ -0,0 +1,134 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoConfigFixture;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class check that fixtures can be replaced using override config
*
* @magentoAppIsolation enabled
*/
class ReplaceFixtureTest extends AbstractOverridesTest
{
/** @var ScopeConfigInterface */
private $config;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
}
/**
* Checks that fixture can be replaced in global node
*
* @magentoConfigFixture current_store test_section/test_group/field_5 new_value
*
* @return void
*/
public function testGloballyReplaceFixture(): void
{
$value = $this->config->getValue('test_section/test_group/field_5', ScopeInterface::SCOPE_STORES);
$this->assertEquals('5th field globally replaced value', $value);
}
/**
* Checks that fixture can be replaced in test class node
*
* @magentoConfigFixture current_store test_section/test_group/field_1 new_value
*
* @return void
*/
public function testReplaceFixtureForClass(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals('Overridden fixture for class', $value);
}
/**
* Checks that fixture can be replaced in method and data set nodes
*
* @magentoConfigFixture current_store test_section/test_group/field_1 new_value
*
* @dataProvider testDataProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testReplaceFixtureForMethod(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => [
'expected_config_value' => 'Overridden fixture for method',
],
'second_data_set' => [
'expected_config_value' => 'Overridden fixture for data set',
],
];
}
/**
* Checks that website scope fixture can be replaced
*
* @magentoConfigFixture current_website test_section/test_group/field_1 new_value
*
* @return void
*/
public function testReplaceWebsiteScopedFixture(): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_WEBSITES);
$this->assertEquals('Overridden value for website scope', $value);
}
/**
* Checks that replace config from last loaded file will be applied
*
* @magentoConfigFixture current_store test_section/test_group/field_1 new_value
*
* @dataProvider configValuesProvider
*
* @param string $expectedConfigValue
* @return void
*/
public function testReplaceFixtureViaThirdModule(string $expectedConfigValue): void
{
$value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES);
$this->assertEquals($expectedConfigValue, $value);
}
/**
* @return array
*/
public function configValuesProvider(): array
{
return [
'first_data_set' => [
'expected_config_value' => 'Overridden fixture for method from third module',
],
'second_data_set' => [
'expected_config_value' => 'Overridden fixture for data set from third module',
],
];
}
}
@@ -0,0 +1,97 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class checks that magentoDataFixtures can be added using override config
*
* @magentoAppIsolation enabled
*/
class AddFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixtures added in all nodes successfully applied
*
* @dataProvider addedFixturesProvider
*
* @param array $fixtures
* @return void
*/
public function testAddFixtures(array $fixtures): void
{
foreach ($fixtures as $scope => $fixture) {
$this->assertEquals(
1,
$this->fixtureCallStorage->getFixturesCount($fixture),
sprintf('Fixture added in %s scope was not called', $scope)
);
}
}
/**
* @return array
*/
public function addedFixturesProvider(): array
{
return [
'first_data_set' => [
[
'class' => 'fixture1_second_module.php',
'method' => 'fixture2_second_module.php',
'data_set' => 'fixture3_second_module.php',
],
],
'second_data_set' => [
[
'class' => 'fixture1_second_module.php',
'method' => 'fixture2_second_module.php',
],
],
];
}
/**
* Checks that same fixture can be added via override config from few files
*
* @return void
*/
public function testAddSameFixtures(): void
{
$this->assertEquals(
3,
$this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php')
);
}
/**
* Checks that fixture which require another fixture can be added using override
*
* @return void
*/
public function testAddFixtureWithRequiredFixture(): void
{
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
}
}
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Checks that magentoDataFixture can be removed using override config
*
* @magentoAppIsolation enabled
*/
class RemoveFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixture can be removed in test class node
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
*
* @return void
*/
public function testRemoveFixtureForClass(): void
{
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
}
/**
* Checks that fixture can be removed in method and data set nodes
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
*
* @dataProvider testDataProvider
*
* @param string $fixtureName
* @return void
*/
public function testRemoveFixtureForMethod(string $fixtureName): void
{
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount($fixtureName));
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => ['fixture2_first_module.php'],
'second_data_set' => ['fixture3_first_module.php'],
];
}
/**
* Checks that same fixtures can be removed few times
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
*
* @return void
*/
public function testRemoveSameFixtures(): void
{
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_first_module.php'));
}
}
@@ -0,0 +1,136 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class check that magentoDataFixtures can be replaced using override config
*
* @magentoAppIsolation enabled
*/
class ReplaceFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixture can be replaced in test class node
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
*
* @return void
*/
public function testReplaceFixtureForClass(): void
{
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture1_second_module.php'));
}
/**
* Checks that fixture can be replaced in method and data set nodes
*
* @dataProvider replacedFixturesProvider
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
*
* @param string $fixture
* @return void
*/
public function testReplaceFixturesForMethod(string $fixture): void
{
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount($fixture));
}
/**
* @return array
*/
public function replacedFixturesProvider(): array
{
return [
'first_data_set' => [
'fixture2_second_module.php',
],
'second_data_set' => [
'fixture3_second_module.php',
],
];
}
/**
* Checks that replace config from last loaded file will be applied
*
* @dataProvider dataProvider
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
*
* @param string $fixture
* @return void
*/
public function testReplaceFixtureViaThirdModule(string $fixture): void
{
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount($fixture));
}
/**
* @return array
*/
public function dataProvider(): array
{
return [
'first_data_set' => [
'fixture2_second_module.php',
],
'second_data_set' => [
'fixture3_second_module.php',
],
];
}
/**
* Checks that fixture required in the another fixture can be replaced using override
*
* @magentoDataFixture Magento/TestModuleOverrideConfig2/_files/fixture_with_required_fixture.php
*
* @return void
*/
public function testReplaceRequiredFixture(): void
{
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php'));
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
}
/**
* Checks that fixture required in the another fixture will be replaced according to last loaded override
*
* @magentoDataFixture Magento/TestModuleOverrideConfig2/_files/fixture_with_required_fixture.php
*
* @return void
*/
public function testReplaceRequiredFixtureViaThirdModule(): void
{
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture1_third_module.php'));
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php'));
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
}
}
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class checks that magentoConfigFixtures can be placed into certain place using override config
*
* @magentoAppIsolation enabled
*/
class SortFixturesTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
// phpstan:ignore "Class Magento\TestModuleOverrideConfig\Model\FixtureCallStorage not found."
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixtures can be placed to specific place according to config
*
* @dataProvider sortFixturesProvider
*
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
*
* @param array $sortedFixtures
* @return void
*/
public function testSortFixtures(array $sortedFixtures): void
{
$this->assertEquals($sortedFixtures, $this->fixtureCallStorage->getStorage());
}
/**
* @return array
*/
public function sortFixturesProvider(): array
{
return [
'first_data_set' => [
'sorted_fixtures' => [
'fixture3_second_module.php',
'fixture1_first_module.php',
'fixture1_second_module.php',
'fixture2_first_module.php',
'fixture1_third_module.php',
'fixture3_first_module.php',
'global_fixture_first_module.php',// globally added fixture
'fixture2_second_module.php',
],
],
'second_data_set' => [
'sorted_fixtures' => [
'fixture1_first_module.php',
'fixture1_second_module.php',
'fixture2_first_module.php',
'fixture3_first_module.php',
'global_fixture_first_module.php',// globally added fixture
'fixture2_second_module.php',
],
],
];
}
}
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixtureBeforeTransaction;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class checks that magentoDataFixtures can be added using override config
*
* @magentoAppIsolation enabled
*/
class AddFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixture can be added
*
* @return void
*/
public function testAddFixture(): void
{
$this->assertEquals(
1,
$this->fixtureCallStorage->getFixturesCount('fixture1_second_module.php')
);
}
}
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixtureBeforeTransaction;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Checks that magentoDataFixture can be removed using override config
*
* @magentoAppIsolation enabled
*/
class RemoveFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixture can be removed in global node
*
* @magentoDataFixtureBeforeTransaction Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
*
* @return void
*/
public function testRemoveFixture(): void
{
$this->assertNull($this->fixtureCallStorage->getFixturePosition('fixture1_first_module.php'));
}
}
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\MagentoDataFixtureBeforeTransaction;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/**
* Class check that magentoDataFixturesBeforeTransaction can be replaced using override config
*
* @magentoAppIsolation enabled
*/
class ReplaceFixtureTest extends AbstractOverridesTest
{
/** @var FixtureCallStorage */
private $fixtureCallStorage;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
}
/**
* Checks that fixture can be replaced in global node
*
* @magentoDataFixtureBeforeTransaction Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
*
* @return void
*/
public function testReplaceFixture(): void
{
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture2_first_module.php'));
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture3_first_module.php'));
}
}
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Skip;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that full test class can be skipped
*
* @magentoAppIsolation enabled
*/
class SkipClassTest extends AbstractOverridesTest
{
/**
* This test should not be executed according to override config it should be mark as skipped
*
* @return void
*/
public function testClassSkip(): void
{
$this->fail('This test should be skipped via override config in test class node');
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Skip;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that only specific data set can be skipped using override config
*
* @magentoAppIsolation enabled
*/
class SkipDataSetTest extends AbstractOverridesTest
{
/**
* The first_data_set should not be executed according to override config it should be mark as skipped
*
* @dataProvider testDataProvider
*
* @return void
*/
public function testSkipDataSet(): void
{
if ($this->dataName() === 'first_data_set') {
$this->fail('This test should be skipped via override config in data set node');
}
}
/**
* @return array
*/
public function testDataProvider(): array
{
return [
'first_data_set' => [],
'second_data_set' => [],
];
}
}
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleOverrideConfig\Skip;
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
/**
* Class checks that test method can be skipped using override config
*
* @magentoAppIsolation enabled
*/
class SkipMethodTest extends AbstractOverridesTest
{
/**
* This test should not be executed according to override config it should be mark as skipped
*
* @return void
*/
public function testMethodSkip(): void
{
$this->fail('This test should be skipped via override config in method node');
}
}
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->addFixtureToStorage(basename(__FILE__));
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->clearStorage();
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->addFixtureToStorage(basename(__FILE__));
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->clearStorage();
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->addFixtureToStorage(basename(__FILE__));
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->clearStorage();
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->addFixtureToStorage(basename(__FILE__));
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
/** @var FixtureCallStorage $fixtureStorage */
$fixtureStorage = Bootstrap::getObjectManager()->get(FixtureCallStorage::class);
$fixtureStorage->clearStorage();