|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Sales\Model\Order\Invoice; |
| 9 | + |
| 10 | +use Magento\Store\Model\ScopeInterface; |
| 11 | +use Magento\TestFramework\Helper\Bootstrap; |
| 12 | +use Magento\TestFramework\ObjectManager; |
| 13 | +use Magento\Framework\App\Config\MutableScopeConfigInterface; |
| 14 | + |
| 15 | +/** |
| 16 | + * Test class for \Magento\Sales\Model\Order\Invoice\GetLogoFile |
| 17 | + */ |
| 18 | +class GetLogoFileTest extends \PHPUnit\Framework\TestCase |
| 19 | +{ |
| 20 | + private const XML_PATH_SALES_IDENTITY_LOGO_HTML = 'sales/identity/logo_html'; |
| 21 | + private const DUMP_IMAGE = 'my_dump_logo.png'; |
| 22 | + |
| 23 | + /** |
| 24 | + * @var ObjectManager |
| 25 | + */ |
| 26 | + private $objectManager; |
| 27 | + |
| 28 | + /** |
| 29 | + * @var MutableScopeConfigInterface |
| 30 | + */ |
| 31 | + private $scopeConfig; |
| 32 | + |
| 33 | + /** |
| 34 | + * @var GetLogoFile |
| 35 | + */ |
| 36 | + private $getLogoFile; |
| 37 | + |
| 38 | + /** |
| 39 | + * @inheritdoc |
| 40 | + */ |
| 41 | + protected function setUp(): void |
| 42 | + { |
| 43 | + $this->objectManager = Bootstrap::getObjectManager(); |
| 44 | + $this->scopeConfig = $this->objectManager->get(MutableScopeConfigInterface::class); |
| 45 | + $this->getLogoFile = $this->objectManager->get(GetLogoFile::class); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Check that GetLogoFile return image after Admin configuration is changed |
| 50 | + * |
| 51 | + * @return void |
| 52 | + */ |
| 53 | + public function testExecute(): void |
| 54 | + { |
| 55 | + $this->assertNull($this->getLogoFile->execute()); |
| 56 | + |
| 57 | + $this->applyImage(); |
| 58 | + |
| 59 | + $this->assertIsString($this->getLogoFile->execute()); |
| 60 | + $this->assertStringContainsString(self::DUMP_IMAGE, $this->getLogoFile->execute()); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Set Invoice Custom Logo HTML Image configuration |
| 65 | + * |
| 66 | + * @return void |
| 67 | + */ |
| 68 | + private function applyImage(): void |
| 69 | + { |
| 70 | + $this->scopeConfig->setValue( |
| 71 | + self::XML_PATH_SALES_IDENTITY_LOGO_HTML, |
| 72 | + self::DUMP_IMAGE, |
| 73 | + ScopeInterface::SCOPE_STORE |
| 74 | + ); |
| 75 | + } |
| 76 | +} |
0 commit comments