Skip to content

Commit f6a6289

Browse files
committed
Fix incorrect logo on order print page
Add test coverage
1 parent 302f6c5 commit f6a6289

File tree

1 file changed

+35
-6
lines changed
  • dev/tests/integration/testsuite/Magento/Sales/Block/Order/PrintOrder

1 file changed

+35
-6
lines changed

dev/tests/integration/testsuite/Magento/Sales/Block/Order/PrintOrder/LogoTest.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
*/
66
namespace Magento\Sales\Block\Order\PrintOrder;
77

8-
use Magento\Framework\View\LayoutInterface;
9-
use Magento\TestFramework\Helper\Bootstrap;
8+
use Magento\Framework\App\Filesystem\DirectoryList;
109
use Magento\Framework\App\State;
11-
use Magento\Theme\Block\Html\Header\Logo;
1210
use Magento\Framework\Filesystem;
1311
use Magento\Framework\Filesystem\Directory\WriteInterface;
14-
use Magento\Framework\App\Filesystem\DirectoryList;
1512
use Magento\Framework\ObjectManagerInterface;
16-
use Magento\Theme\ViewModel\Block\Html\Header\LogoPathResolver as LogoPathResolverDefault;
13+
use Magento\Framework\View\LayoutInterface;
1714
use Magento\Sales\ViewModel\Header\LogoPathResolver as LogoPathResolverSales;
18-
use \PHPUnit\Framework\TestCase;
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\Theme\Block\Html\Header\Logo;
17+
use Magento\Theme\ViewModel\Block\Html\Header\LogoPathResolver as LogoPathResolverDefault;
18+
use PHPUnit\Framework\TestCase;
1919

2020
class LogoTest extends TestCase
2121
{
@@ -71,4 +71,33 @@ public function testGetLogoSrc(): void
7171
$this->mediaDirectory->delete($defaultPath);
7272
$this->mediaDirectory->delete($salesPath);
7373
}
74+
75+
/**
76+
* Checks that fallback to header logo works fine
77+
*
78+
* @magentoConfigFixture default_store design/header/logo_src default/logo.jpg
79+
* @throws \Magento\Framework\Exception\FileSystemException
80+
*/
81+
public function testGetLogoSrcWithFallback(): void
82+
{
83+
$host = 'http://localhost/media/';
84+
$defaultLogoFile = 'logo.jpg';
85+
$defaultPath = 'logo/default/' . $defaultLogoFile;
86+
$this->mediaDirectory->writeFile($defaultPath, '');
87+
$blockArguments = ['data' =>
88+
['logoPathResolver' => $this->objectManager->get(LogoPathResolverDefault::class)]
89+
];
90+
/** @var Logo $block */
91+
$block = $this->objectManager->create(LayoutInterface::class)
92+
->createBlock(Logo::class, 'logo', $blockArguments);
93+
$this->assertSame($host . $defaultPath, $block->getLogoSrc());
94+
$blockArguments = ['data' =>
95+
['logoPathResolver' => $this->objectManager->get(LogoPathResolverSales::class)]
96+
];
97+
/** @var Logo $block */
98+
$block = $this->objectManager->create(LayoutInterface::class)
99+
->createBlock(Logo::class, 'logo', $blockArguments);
100+
$this->assertSame($host . $defaultPath, $block->getLogoSrc());
101+
$this->mediaDirectory->delete($defaultPath);
102+
}
74103
}

0 commit comments

Comments
 (0)