public function testGetEscapedValue()
 {
     $this->localeFormat->expects($this->any())->method('getPriceFormat')->willReturn(['precision' => 2, 'decimalSymbol' => ',', 'groupSymbol' => '.']);
     $this->_model->setValue('30000.4');
     $this->_model->setEntityAttribute(true);
     $return = $this->_model->getEscapedValue('30000.4');
     $this->assertEquals('30.000,40', $return);
 }
Exemple #2
0
 public function testGetEscapedValue()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $collectionFactory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\CollectionFactory', ['create'], [], '', false);
     $localeFormat = $this->getMock('\\Magento\\Framework\\Locale\\Format', [], [], '', false);
     $localeFormat->expects($this->any())->method('getPriceFormat')->willReturn(['precision' => 2, 'decimalSymbol' => ',', 'groupSymbol' => '.']);
     $factory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $this->model = $objectManager->getObject('Magento\\Weee\\Block\\Element\\Weee\\Tax', ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory, 'localeFormat' => $localeFormat]);
     $inputValue = [['value' => '30000.4']];
     $this->model->setValue($inputValue);
     $this->model->setEntityAttribute(true);
     $return = $this->model->getEscapedValue();
     $this->assertEquals([['value' => '30.000,40']], $return);
 }
 public function testSetForm()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $factory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $collectionFactory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\CollectionFactory', ['create'], [], '', false);
     $formKey = $this->getMock('Magento\\Framework\\Data\\Form\\FormKey', [], [], '', false);
     $form = new \Magento\Framework\Data\Form($factory, $collectionFactory, $formKey);
     $helper = $this->getMock('Magento\\Catalog\\Helper\\Product', ['getTypeSwitcherControlLabel'], [], '', false, false);
     $helper->expects($this->any())->method('getTypeSwitcherControlLabel')->will($this->returnValue('Virtual / Downloadable'));
     $this->_virtual = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Checkbox', ['setId', 'setName', 'setLabel', 'setForm'], [], '', false, false);
     $this->_virtual->expects($this->any())->method('setId')->will($this->returnSelf());
     $this->_virtual->expects($this->any())->method('setName')->will($this->returnSelf());
     $this->_virtual->expects($this->any())->method('setLabel')->will($this->returnSelf());
     $this->_virtual->expects($this->any())->method('setForm')->with($this->equalTo($form))->will($this->returnSelf());
     $factory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $factory->expects($this->once())->method('create')->with($this->equalTo('checkbox'))->will($this->returnValue($this->_virtual));
     $this->_model = $objectManager->getObject('Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Weight', ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory, 'helper' => $helper]);
     $this->_model->setForm($form);
 }
 public function testGetEscapedValue()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $inputValue = [['value' => '30000.4']];
     $collectionFactory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\CollectionFactory', ['create'], [], '', false);
     $storeManager = $this->getMock('\\Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $localeCurrency = $this->getMock('\\Magento\\Framework\\Locale\\Currency', [], [], '', false);
     $currency = $this->getMock('\\Magento\\Framework\\Currency', [], [], '', false);
     $currency->expects($this->any())->method('toCurrency')->willReturn('30.000,40');
     $localeCurrency->expects($this->any())->method('getCurrency')->willReturn($currency);
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $storeManager->expects($this->any())->method('getStore')->willReturn($store);
     $factory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $this->model = $objectManager->getObject('Magento\\Weee\\Block\\Element\\Weee\\Tax', ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory, 'storeManager' => $storeManager, 'localeCurrency' => $localeCurrency]);
     $this->model->setValue($inputValue);
     $this->model->setEntityAttribute(new \Magento\Framework\DataObject(['store_id' => 1]));
     $return = $this->model->getEscapedValue();
     $this->assertEquals([['value' => '30.000,40']], $return);
 }
Exemple #5
0
 public function testGetEscapedValue()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $collectionFactory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\CollectionFactory', ['create'], [], '', false);
     $localeFormat = $this->getMock('\\Magento\\Framework\\Locale\\Format', [], [], '', false);
     $localeFormat->expects($this->any())->method('getPriceFormat')->willReturn(['precision' => 2, 'decimalSymbol' => ',', 'groupSymbol' => '.']);
     $helper = $this->getMock('Magento\\Catalog\\Helper\\Product', ['getTypeSwitcherControlLabel'], [], '', false, false);
     $helper->expects($this->any())->method('getTypeSwitcherControlLabel')->will($this->returnValue('Virtual / Downloadable'));
     $this->_virtual = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Checkbox', ['setId', 'setName', 'setLabel'], [], '', false, false);
     $this->_virtual->expects($this->any())->method('setId')->will($this->returnSelf());
     $this->_virtual->expects($this->any())->method('setName')->will($this->returnSelf());
     $this->_virtual->expects($this->any())->method('setLabel')->will($this->returnSelf());
     $factory = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Factory', [], [], '', false);
     $factory->expects($this->once())->method('create')->with($this->equalTo('checkbox'))->will($this->returnValue($this->_virtual));
     $this->_model = $objectManager->getObject('Magento\\Catalog\\Block\\Adminhtml\\Product\\Helper\\Form\\Weight', ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory, 'helper' => $helper, 'localeFormat' => $localeFormat]);
     $this->_model->setValue('30000.4');
     $this->_model->setEntityAttribute(true);
     $return = $this->_model->getEscapedValue('30000.4');
     $this->assertEquals('30.000,40', $return);
 }