/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/TestModuleOverrideConfig/MagentoConfigFixture/ReplaceFixtureTest.php
133 строки
4 KB
Raj Mohan R
AC-16236::Upgrade Core Test Framework to PHPUnit 12 and Migrate from PHPUnit 10
11 фев 2026, 13:51
11 фев 2026, 13:51
152ed41
Код
Авторство
О чём код?
<?php /** * Copyright 2020 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\TestModuleOverrideConfig\MagentoConfigFixture; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; use Magento\TestModuleOverrideConfig\AbstractOverridesTest; use PHPUnit\Framework\Attributes\DataProvider; /** * 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 * * @param string $expectedConfigValue * @return void */ #[DataProvider('configDataProvider')] 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 static function configDataProvider(): array { return [ 'first_data_set' => [ 'Overridden fixture for method', ], 'second_data_set' => [ '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 * * @param string $expectedConfigValue * @return void */ #[DataProvider('configValuesProvider')] 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 static function configValuesProvider(): array { return [ 'first_data_set' => [ 'Overridden fixture for method from third module', ], 'second_data_set' => [ 'Overridden fixture for data set from third module', ], ]; } }