![]() 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/dev/tests/integration/testsuite/Magento/Sales/Block/Order/PrintOrder/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Sales\Block\Order\PrintOrder; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\State; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Directory\WriteInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\View\LayoutInterface; use Magento\Sales\ViewModel\Header\LogoPathResolver as LogoPathResolverSales; use Magento\TestFramework\Helper\Bootstrap; use Magento\Theme\Block\Html\Header\Logo; use Magento\Theme\ViewModel\Block\Html\Header\LogoPathResolver as LogoPathResolverDefault; use PHPUnit\Framework\TestCase; class LogoTest extends TestCase { /** * @var ObjectManagerInterface */ private $objectManager; /** * @var WriteInterface */ private $mediaDirectory; protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); $filesystem = $this->objectManager->get(Filesystem::class); $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->objectManager->get(State::class) ->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND); Bootstrap::getInstance() ->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); } /** * @magentoConfigFixture default_store design/header/logo_src default/logo.jpg * @magentoConfigFixture default_store sales/identity/logo_html default/logo_sales.jpg * @throws \Magento\Framework\Exception\FileSystemException */ public function testGetLogoSrc(): void { $host = 'http://localhost/media/'; $defaultLogoFile= 'logo.jpg'; $defaultPath = 'logo/default/' . $defaultLogoFile; $salesLogoFile = 'logo_sales.jpg'; $salesPath = 'sales/store/logo_html/default/' . $salesLogoFile; $this->mediaDirectory->writeFile($defaultPath, ''); $this->mediaDirectory->writeFile($salesPath, ''); $blockArguments = ['data' => ['logoPathResolver' => $this->objectManager->get(LogoPathResolverDefault::class)] ]; /** @var Logo $block */ $block = $this->objectManager->create(LayoutInterface::class) ->createBlock(Logo::class, 'logo', $blockArguments); $this->assertSame($host . $defaultPath, $block->getLogoSrc()); $blockArguments = ['data' => ['logoPathResolver' => $this->objectManager->get(LogoPathResolverSales::class)] ]; /** @var Logo $block */ $block = $this->objectManager->create(LayoutInterface::class) ->createBlock(Logo::class, 'logo', $blockArguments); $this->assertSame($host . $salesPath, $block->getLogoSrc()); $this->mediaDirectory->delete($defaultPath); $this->mediaDirectory->delete($salesPath); } /** * Checks that fallback to header logo works fine * * @magentoConfigFixture default_store design/header/logo_src default/logo.jpg * @throws \Magento\Framework\Exception\FileSystemException */ public function testGetLogoSrcWithFallback(): void { $host = 'http://localhost/media/'; $defaultLogoFile = 'logo.jpg'; $defaultPath = 'logo/default/' . $defaultLogoFile; $this->mediaDirectory->writeFile($defaultPath, ''); $blockArguments = ['data' => ['logoPathResolver' => $this->objectManager->get(LogoPathResolverDefault::class)] ]; /** @var Logo $block */ $block = $this->objectManager->create(LayoutInterface::class) ->createBlock(Logo::class, 'logo', $blockArguments); $this->assertSame($host . $defaultPath, $block->getLogoSrc()); $blockArguments = ['data' => ['logoPathResolver' => $this->objectManager->get(LogoPathResolverSales::class)] ]; /** @var Logo $block */ $block = $this->objectManager->create(LayoutInterface::class) ->createBlock(Logo::class, 'logo', $blockArguments); $this->assertSame($host . $defaultPath, $block->getLogoSrc()); $this->mediaDirectory->delete($defaultPath); } }