TitleTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Block\Adminhtml\Rate;
  7. use Magento\Tax\Controller\RegistryConstants;
  8. use Magento\Tax\Model\Calculation\Rate;
  9. class TitleTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var \Magento\Tax\Block\Adminhtml\Rate\Title
  13. */
  14. protected $_block;
  15. /**
  16. * @var \Magento\TestFramework\ObjectManager
  17. */
  18. protected $_objectManager;
  19. protected function setUp()
  20. {
  21. /** @var $objectManager \Magento\TestFramework\ObjectManager */
  22. $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  23. }
  24. /**
  25. * @magentoDataFixture Magento/Store/_files/store.php
  26. * @magentoDataFixture Magento/Tax/_files/tax_classes.php
  27. */
  28. public function testGetTitles()
  29. {
  30. /** @var \Magento\Tax\Model\Calculation\Rate $rate */
  31. $rate = $this->_objectManager->create(\Magento\Tax\Model\Calculation\Rate::class);
  32. $rate->load(1);
  33. /** @var \Magento\Store\Model\Store $store */
  34. $store = $this->_objectManager->get(\Magento\Store\Model\Store::class);
  35. $store->load('test', 'code');
  36. $title = 'title';
  37. $rate->saveTitles([$store->getId() => $title]);
  38. $coreRegistry = $this->_objectManager->create(\Magento\Framework\Registry::class);
  39. $coreRegistry->register(RegistryConstants::CURRENT_TAX_RATE_ID, 1);
  40. /** @var \Magento\Tax\Block\Adminhtml\Rate\Title $block */
  41. $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  42. \Magento\Tax\Block\Adminhtml\Rate\Title::class,
  43. [
  44. 'coreRegistry' => $coreRegistry,
  45. ]
  46. );
  47. $titles = $block->getTitles();
  48. $this->assertArrayHasKey($store->getId(), $titles, 'Store was not created');
  49. $this->assertEquals($title, $titles[$store->getId()], 'Invalid Tax Title');
  50. }
  51. }