TaxTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Test\Unit\Block\Element\Weee;
  7. class TaxTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight
  11. */
  12. protected $model;
  13. public function testGetEscapedValue()
  14. {
  15. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  16. $inputValue = [
  17. ['value' => '30000.4'],
  18. ];
  19. $collectionFactory = $this->createPartialMock(
  20. \Magento\Framework\Data\Form\Element\CollectionFactory::class,
  21. ['create']
  22. );
  23. $storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
  24. $localeCurrency = $this->createMock(\Magento\Framework\Locale\Currency::class);
  25. $currency = $this->createMock(\Magento\Framework\Currency::class);
  26. $currency->expects(
  27. $this->any()
  28. )->method(
  29. 'toCurrency'
  30. )->willReturn('30.000,40');
  31. $localeCurrency->expects(
  32. $this->any()
  33. )->method(
  34. 'getCurrency'
  35. )->willReturn($currency);
  36. $store = $this->createMock(\Magento\Store\Model\Store::class);
  37. $storeManager->expects(
  38. $this->any()
  39. )->method(
  40. 'getStore'
  41. )->willReturn($store);
  42. $factory = $this->createMock(\Magento\Framework\Data\Form\Element\Factory::class);
  43. $this->model = $objectManager->getObject(
  44. \Magento\Weee\Block\Element\Weee\Tax::class,
  45. [
  46. 'factoryElement' => $factory,
  47. 'factoryCollection' => $collectionFactory,
  48. 'storeManager' => $storeManager,
  49. 'localeCurrency' => $localeCurrency
  50. ]
  51. );
  52. $this->model->setValue($inputValue);
  53. $this->model->setEntityAttribute(new \Magento\Framework\DataObject(['store_id' => 1]));
  54. $return = $this->model->getEscapedValue();
  55. $this->assertEquals(
  56. [
  57. ['value' => '30.000,40'],
  58. ],
  59. $return
  60. );
  61. }
  62. }