/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Test/Unit/Fixtures/AttributeSetsFixtureTest.php
122 строки
3 KB
Manish Ranjan
AC-16248: PHPUnit 12 Upgrade | Unit test fix
13 янв 2026, 17:31
13 янв 2026, 17:31
58f9738
Код
Авторство
О чём код?
<?php /** * Copyright 2016 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Fixtures; use Magento\Setup\Fixtures\AttributeSet\AttributeSetFixture; use Magento\Setup\Fixtures\AttributeSet\Pattern; use Magento\Setup\Fixtures\AttributeSetsFixture; use Magento\Setup\Fixtures\FixtureModel; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * @SuppressWarnings(PHPMD) */ class AttributeSetsFixtureTest extends TestCase { /** * @var MockObject|FixtureModel */ private $fixtureModelMock; /** * @var AttributeSetsFixture */ private $model; /** * @var MockObject */ private $attributeSetsFixtureMock; /** * @var MockObject */ private $patternMock; protected function setUp(): void { $this->fixtureModelMock = $this->getMockBuilder(FixtureModel::class) ->disableOriginalConstructor() ->getMock(); $this->attributeSetsFixtureMock = $this->getMockBuilder(AttributeSetFixture::class) ->disableOriginalConstructor() ->getMock(); $this->patternMock = $this->getMockBuilder(Pattern::class) ->disableOriginalConstructor() ->getMock(); $this->model = new AttributeSetsFixture( $this->fixtureModelMock, $this->attributeSetsFixtureMock, $this->patternMock ); } public function testCreateAttributeSet() { $valueMap = [ ['attribute_sets', null, ['attribute_set' => [['some-data']]]], ['product_attribute_sets', null, null], ]; $this->attributeSetsFixtureMock->expects($this->once()) ->method('createAttributeSet') ->with(['some-data']); $this->fixtureModelMock ->expects($this->exactly(2)) ->method('getValue') ->willReturnMap($valueMap); $this->model->execute(); } public function testCreateProductAttributeSet() { $valueMap = [ ['attribute_sets', null, null], ['product_attribute_sets', null, 1], ['product_attribute_sets_attributes', 3, 2], ['product_attribute_sets_attributes_values', 3, 3], ]; $this->patternMock->expects($this->once()) ->method('generateAttributeSet') ->with( AttributeSetsFixture::PRODUCT_SET_NAME . 1, 2, 3, $this->callback(function ($arg) { return is_callable($arg); }) ) ->willReturn(['some-data']); $this->attributeSetsFixtureMock->expects($this->once()) ->method('createAttributeSet') ->with(['some-data']); $this->fixtureModelMock ->expects($this->exactly(4)) ->method('getValue') ->willReturnMap($valueMap); $this->model->execute(); } public function testGetActionTitle() { $this->assertSame('Generating attribute sets', $this->model->getActionTitle()); } public function testIntroduceParamLabels() { $this->assertSame([ 'attribute_sets' => 'Attribute Sets (Default)', 'product_attribute_sets' => 'Attribute Sets (Extra)' ], $this->model->introduceParamLabels()); } }