Skip to content

Commit

Permalink
MAGETWO-36706: [GITHUB] Won't accept valid Brazil monetary value as i…
Browse files Browse the repository at this point in the history
…nput #1192

- more unit tests
  • Loading branch information
Cristian Partica committed Jul 6, 2015
1 parent 36413b8 commit 8cb21d6
Showing 1 changed file with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,88 @@ public function testSetForm()

$this->_model->setForm($form);
}

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);
}
}

0 comments on commit 8cb21d6

Please sign in to comment.