CurrencysymbolTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System;
  7. class CurrencysymbolTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * Object manager helper
  11. *
  12. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  13. */
  14. protected $objectManagerHelper;
  15. protected function setUp()
  16. {
  17. $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  18. }
  19. protected function tearDown()
  20. {
  21. unset($this->objectManagerHelper);
  22. }
  23. public function testPrepareLayout()
  24. {
  25. $symbolSystemFactoryMock = $this->createPartialMock(
  26. \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory::class,
  27. ['create']
  28. );
  29. $blockMock = $this->createPartialMock(
  30. \Magento\Framework\View\Element\BlockInterface::class,
  31. ['addChild', 'toHtml']
  32. );
  33. /** @var $layoutMock \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject */
  34. $layoutMock = $this->getMockForAbstractClass(
  35. \Magento\Framework\View\LayoutInterface::class,
  36. [],
  37. '',
  38. false,
  39. false,
  40. true,
  41. ['getBlock']
  42. );
  43. $layoutMock->expects($this->once())->method('getBlock')->willReturn($blockMock);
  44. $blockMock->expects($this->once())
  45. ->method('addChild')
  46. ->with(
  47. 'save_button',
  48. \Magento\Backend\Block\Widget\Button::class,
  49. [
  50. 'label' => __('Save Currency Symbols'),
  51. 'class' => 'save primary save-currency-symbols',
  52. 'data_attribute' => [
  53. 'mage-init' => ['button' => ['event' => 'save', 'target' => '#currency-symbols-form']],
  54. ]
  55. ]
  56. );
  57. /** @var $block \Magento\CurrencySymbol\Block\Adminhtml\System\Currencysymbol */
  58. $block = $this->objectManagerHelper->getObject(
  59. \Magento\CurrencySymbol\Block\Adminhtml\System\Currencysymbol::class,
  60. [
  61. 'symbolSystemFactory' => $symbolSystemFactoryMock,
  62. 'layout' => $layoutMock
  63. ]
  64. );
  65. $block->setLayout($layoutMock);
  66. }
  67. }