LogoTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Test\Unit\Block\Html\Header;
  7. class LogoTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * cover \Magento\Theme\Block\Html\Header\Logo::getLogoSrc
  11. */
  12. public function testGetLogoSrc()
  13. {
  14. $filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
  15. $mediaDirectory = $this->createMock(\Magento\Framework\Filesystem\Directory\Read::class);
  16. $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  17. $urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
  18. $scopeConfig->expects($this->once())->method('getValue')->will($this->returnValue('default/image.gif'));
  19. $urlBuilder->expects(
  20. $this->once()
  21. )->method(
  22. 'getBaseUrl'
  23. )->will(
  24. $this->returnValue('http://localhost/pub/media/')
  25. );
  26. $mediaDirectory->expects($this->any())->method('isFile')->will($this->returnValue(true));
  27. $filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($mediaDirectory));
  28. $helper = $this->createPartialMock(\Magento\MediaStorage\Helper\File\Storage\Database::class, ['checkDbUsage']);
  29. $helper->expects($this->once())->method('checkDbUsage')->will($this->returnValue(false));
  30. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  31. $arguments = [
  32. 'scopeConfig' => $scopeConfig,
  33. 'urlBuilder' => $urlBuilder,
  34. 'fileStorageHelper' => $helper,
  35. 'filesystem' => $filesystem,
  36. ];
  37. $block = $objectManager->getObject(\Magento\Theme\Block\Html\Header\Logo::class, $arguments);
  38. $this->assertEquals('http://localhost/pub/media/logo/default/image.gif', $block->getLogoSrc());
  39. }
  40. }