|
5 | 5 | */
|
6 | 6 | namespace Magento\Sales\Block\Order\PrintOrder;
|
7 | 7 |
|
8 |
| -use Magento\Framework\View\LayoutInterface; |
9 |
| -use Magento\TestFramework\Helper\Bootstrap; |
| 8 | +use Magento\Framework\App\Filesystem\DirectoryList; |
10 | 9 | use Magento\Framework\App\State;
|
11 |
| -use Magento\Theme\Block\Html\Header\Logo; |
12 | 10 | use Magento\Framework\Filesystem;
|
13 | 11 | use Magento\Framework\Filesystem\Directory\WriteInterface;
|
14 |
| -use Magento\Framework\App\Filesystem\DirectoryList; |
15 | 12 | use Magento\Framework\ObjectManagerInterface;
|
16 |
| -use Magento\Theme\ViewModel\Block\Html\Header\LogoPathResolver as LogoPathResolverDefault; |
| 13 | +use Magento\Framework\View\LayoutInterface; |
17 | 14 | 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; |
19 | 19 |
|
20 | 20 | class LogoTest extends TestCase
|
21 | 21 | {
|
@@ -71,4 +71,33 @@ public function testGetLogoSrc(): void
|
71 | 71 | $this->mediaDirectory->delete($defaultPath);
|
72 | 72 | $this->mediaDirectory->delete($salesPath);
|
73 | 73 | }
|
| 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 | + } |
74 | 103 | }
|
0 commit comments