/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/TestModuleOverrideConfig/MagentoDataFixture/ReplaceFixtureTest.php
135 строк
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\MagentoDataFixture; use Magento\TestModuleOverrideConfig\AbstractOverridesTest; use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage; use PHPUnit\Framework\Attributes\DataProvider; /** * 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 * * @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php * * @param string $fixture * @return void */ #[DataProvider('replacedFixturesProvider')] 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 static 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 * * @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php * * @param string $fixture * @return void */ #[DataProvider('dataProvider')] 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 static 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')); } }