![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-ui/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Ui\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Framework\View\Element\UiComponent\ContextFactory; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\LayoutInterface as LayoutInterfaceView; use Magento\Ui\Model\UiComponentGenerator; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class UiComponentGeneratorTest extends TestCase { /** @var UiComponentGenerator */ protected $model; /** @var ObjectManagerHelper */ protected $objectManagerHelper; /** @var ContextFactory|MockObject */ protected $contextFactoryMock; /** @var UiComponentFactory|MockObject */ protected $uiComponentFactoryMock; protected function setUp(): void { $this->contextFactoryMock = $this ->getMockBuilder(ContextFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->uiComponentFactoryMock = $this->getMockBuilder(UiComponentFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( UiComponentGenerator::class, [ 'contextFactory' => $this->contextFactoryMock, 'uiComponentFactory' => $this->uiComponentFactoryMock ] ); } public function testGenerateUiComponent() { $uiComponentMock = $this->getMockForAbstractClass(UiComponentInterface::class); $uiComponentMockChild1 = $this->getMockForAbstractClass(UiComponentInterface::class); $uiComponentMockChild2 = $this->getMockForAbstractClass(UiComponentInterface::class); $uiComponentMockChild1->expects($this->once()) ->method('prepare'); $uiComponentMockChild2->expects($this->once()) ->method('prepare'); $uiComponentMock->expects($this->once()) ->method('prepare'); $uiComponentMock->expects($this->once()) ->method('getChildComponents') ->willReturn([$uiComponentMockChild1, $uiComponentMockChild2]); $this->uiComponentFactoryMock->expects($this->once()) ->method('create') ->willReturn($uiComponentMock); $layoutMock = $this->createMock(LayoutInterfaceView::class); $this->model->generateUiComponent('widget_recently_viewed', $layoutMock); } }