/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Test/Unit/Fixtures/CustomerGroupsFixtureTest.php
132 строки
4 KB
Manish Ranjan
AC-16248: PHPUnit 12 Upgrade | Unit test fix
13 янв 2026, 17:31
13 янв 2026, 17:31
58f9738
Код
Авторство
О чём код?
<?php /** * Copyright 2017 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Fixtures; use Magento\Customer\Api\Data\GroupInterface; use Magento\Customer\Api\Data\GroupInterfaceFactory; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Model\ResourceModel\Group\Collection; use Magento\Customer\Model\ResourceModel\Group\CollectionFactory; use Magento\Setup\Fixtures\CustomerGroupsFixture; use Magento\Setup\Fixtures\FixtureModel; use Magento\Setup\Fixtures\IndexersStatesApplyFixture; use PHPUnit\Framework\MockObject\MockObject; use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait; use PHPUnit\Framework\TestCase; /** * Test Customer Groups generation */ class CustomerGroupsFixtureTest extends TestCase { use MockCreationTrait; /** * @var MockObject|FixtureModel */ private $fixtureModelMock; /** * @var CollectionFactory */ private $groupCollectionFactoryMock; /** * @var GroupRepositoryInterface */ private $groupRepositoryMock; /** * @var GroupInterfaceFactory */ private $groupFactoryMock; /** * @var GroupInterface */ private $groupDataObjectMock; /** * @var IndexersStatesApplyFixture */ private $model; public function testExecute() { $this->fixtureModelMock = $this->getMockBuilder(FixtureModel::class) ->disableOriginalConstructor() ->getMock(); //Mock repository for customer groups $this->groupRepositoryMock = $this->getMockBuilder(GroupRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); //Mock for customer groups collection $groupCollection = $this->createPartialMockWithReflection( Collection::class, ['getSize', 'addFieldToFilter', 'getIterator'] ); $groupCollection->expects($this->once()) ->method('getSize') ->willReturn(0); $this->groupCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class) ->onlyMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->groupCollectionFactoryMock ->expects($this->once()) ->method('create') ->willReturn($groupCollection); //Mock customer groups data object $this->groupDataObjectMock = $this->createMock(GroupInterface::class); //Mock customer groups factory $this->groupFactoryMock = $this->getMockBuilder(GroupInterfaceFactory::class) ->onlyMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->groupFactoryMock ->expects($this->once()) ->method('create') ->willReturn($this->groupDataObjectMock); $this->groupDataObjectMock ->expects($this->once()) ->method('setCode') ->willReturn($this->groupDataObjectMock); $this->groupDataObjectMock ->expects($this->once()) ->method('setTaxClassId') ->willReturn($this->groupDataObjectMock); $this->groupRepositoryMock ->expects($this->once()) ->method('save') ->willReturn($this->groupDataObjectMock); $this->fixtureModelMock ->expects($this->once()) ->method('getValue') ->willReturn(1); $this->model = new CustomerGroupsFixture( $this->fixtureModelMock, $this->groupCollectionFactoryMock, $this->groupRepositoryMock, $this->groupFactoryMock ); $this->model->execute(); } }