![]() 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/cartforge.co/vendor/magento/module-require-js/Test/Unit/Block/Html/Head/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\RequireJs\Test\Unit\Block\Html\Head; use Magento\Framework\View\Asset\ConfigInterface; use Magento\Framework\View\Asset\GroupedCollection; use Magento\Framework\View\Asset\LocalInterface; use Magento\Framework\View\Asset\Minification; use Magento\Framework\View\Element\Context; use Magento\Framework\View\LayoutInterface; use Magento\RequireJs\Block\Html\Head\Config; use Magento\RequireJs\Model\FileManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class ConfigTest extends TestCase { /** * @var Context|MockObject */ private $context; /** * @var \Magento\Framework\RequireJs\Config|MockObject */ private $config; /** * @var FileManager|MockObject */ private $fileManager; /** * @var \Magento\Framework\View\Page\Config|MockObject */ protected $pageConfig; /** * @var Config */ protected $blockConfig; /** * @var ConfigInterface|MockObject */ protected $bundleConfig; /** * @var Minification|MockObject */ private $minificationMock; protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->config = $this->createMock(\Magento\Framework\RequireJs\Config::class); $this->fileManager = $this->createMock(FileManager::class); $this->pageConfig = $this->createMock(\Magento\Framework\View\Page\Config::class); $this->bundleConfig = $this->getMockForAbstractClass(ConfigInterface::class); } public function testSetLayout() { $this->bundleConfig ->expects($this->once()) ->method('isBundlingJsFiles') ->willReturn(true); $filePath = 'require_js_fie_path'; $asset = $this->getMockForAbstractClass(LocalInterface::class); $asset->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn($filePath); $requireJsAsset = $this->getMockForAbstractClass(LocalInterface::class); $requireJsAsset ->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn('/path/to/require/require.js'); $minResolverAsset = $this->getMockForAbstractClass(LocalInterface::class); $minResolverAsset ->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn('/path/to/require/require-min-resolver.js'); $this->fileManager ->expects($this->once()) ->method('createRequireJsConfigAsset') ->willReturn($requireJsAsset); $this->fileManager ->expects($this->once()) ->method('createRequireJsMixinsAsset') ->willReturn($requireJsAsset); $this->fileManager ->expects($this->once()) ->method('createStaticJsAsset') ->willReturn($requireJsAsset); $this->fileManager ->expects($this->once()) ->method('createBundleJsPool') ->willReturn([$asset]); $this->fileManager ->expects($this->once()) ->method('createMinResolverAsset') ->willReturn($minResolverAsset); $layout = $this->getMockForAbstractClass(LayoutInterface::class); $assetCollection = $this->getMockBuilder(GroupedCollection::class) ->disableOriginalConstructor() ->getMock(); $this->pageConfig->expects($this->atLeastOnce()) ->method('getAssetCollection') ->willReturn($assetCollection); $assetCollection ->expects($this->atLeastOnce()) ->method('insert') ->willReturn(true); $this->minificationMock = $this->getMockBuilder(Minification::class) ->disableOriginalConstructor() ->getMock(); $this->minificationMock ->expects($this->any()) ->method('isEnabled') ->with('js') ->willReturn(true); $object = new Config( $this->context, $this->config, $this->fileManager, $this->pageConfig, $this->bundleConfig, $this->minificationMock ); $object->setLayout($layout); } }