/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/api-functional/testsuite/Magento/TestModuleOverrideConfig/MagentoApiConfigFixture/AddFixtureTest.php
109 строк
3 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\MagentoApiConfigFixture; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; use Magento\TestFramework\Config\Model\ConfigStorage; use Magento\TestModuleOverrideConfig\AbstractOverridesTest; use PHPUnit\Framework\Attributes\DataProvider; /** * Class checks that magentoConfigFixtures can be added via override config * * @magentoAppIsolation enabled */ class AddFixtureTest extends AbstractOverridesTest { /** @var ScopeConfigInterface */ private $config; /** @var ConfigStorage */ private $configStorage; /** * @inheritdoc */ protected function setUp(): void { parent::setUp(); $this->config = $this->objectManager->get(ScopeConfigInterface::class); $this->configStorage = $this->objectManager->get(ConfigStorage::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', ScopeInterface::SCOPE_STORES, 'default'); $this->assertEquals('overridden value for full class', $value); $this->assertEquals( 'overridden value for full class', $this->configStorage->getValueFromDb( 'test_section/test_group/field_1', ScopeInterface::SCOPE_STORES, 'default' ) ); } /** * Checks that fixtures added in method and data set nodes successfully applied * * @param string $expectedConfigValue * @return void */ #[DataProvider('configValueDataProvider')] public function testAddFixtureToMethod(string $expectedConfigValue): void { $value = $this->config->getValue('test_section/test_group/field_1', ScopeInterface::SCOPE_STORES, 'default'); $this->assertEquals($expectedConfigValue, $value); $this->assertEquals( $expectedConfigValue, $this->configStorage->getValueFromDb( 'test_section/test_group/field_1', ScopeInterface::SCOPE_STORES, 'default' ) ); } /** * @return array */ public static function configValueDataProvider(): array { return [ 'first_data_set' => ['overridden value for method'], 'second_data_set' => ['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, 'base'); $this->assertEquals('overridden value for method on website scope', $value); $this->assertEquals( 'overridden value for method on website scope', $this->configStorage->getValueFromDb( 'test_section/test_group/field_1', ScopeInterface::SCOPE_WEBSITES, 'base' ) ); } }