Skip to content

Commit 8a8286c

Browse files
author
Cristian Partica
committed
MAGETWO-18815: code review #7
1 parent cf37a72 commit 8a8286c

File tree

4 files changed

+31
-66
lines changed

4 files changed

+31
-66
lines changed

app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -294,39 +294,4 @@ protected function _prepareForm()
294294

295295
return parent::_prepareForm();
296296
}
297-
298-
/**
299-
* Extract tax rate data in a format which is
300-
*
301-
* @param \Magento\Tax\Api\Data\TaxRateInterface $taxRate
302-
* @return array
303-
*/
304-
protected function extractTaxRateData($taxRate)
305-
{
306-
$formData = [
307-
'tax_calculation_rate_id' => $taxRate->getId(),
308-
'tax_country_id' => $taxRate->getTaxCountryId(),
309-
'tax_region_id' => $taxRate->getTaxRegionId(),
310-
'tax_postcode' => $taxRate->getTaxPostcode(),
311-
'code' => $taxRate->getCode(),
312-
'rate' => $taxRate->getRate(),
313-
'zip_is_range' => false,
314-
];
315-
316-
if ($taxRate->getZipFrom() && $taxRate->getZipTo()) {
317-
$formData['zip_is_range'] = true;
318-
$formData['zip_from'] = $taxRate->getZipFrom();
319-
$formData['zip_to'] = $taxRate->getZipTo();
320-
}
321-
322-
if ($taxRate->getTitles()) {
323-
$titleData = [];
324-
foreach ($taxRate->getTitles() as $title) {
325-
$titleData[] = [$title->getStoreId() => $title->getValue()];
326-
}
327-
$formData['title'] = $titleData;
328-
}
329-
330-
return $formData;
331-
}
332297
}

app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class AjaxLoad extends \Magento\Tax\Controller\Adminhtml\Rate
1313
{
1414
/**
15-
* Show Edit Form
15+
* Json needed for the Ajax Edit Form
1616
*
1717
* @return void
1818
*/

app/code/Magento/Tax/Model/Calculation/Rate/Converter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class Converter
1515
/**
1616
* @var \Magento\Tax\Api\Data\TaxRateInterfaceFactory
1717
*/
18-
protected $_taxRateDataObjectFactory;
18+
protected $taxRateDataObjectFactory;
1919

2020
/**
2121
* @var \Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory
2222
*/
23-
protected $_taxRateTitleDataObjectFactory;
23+
protected $taxRateTitleDataObjectFactory;
2424

2525
/**
2626
* @param \Magento\Tax\Api\Data\TaxRateInterfaceFactory $taxRateDataObjectFactory
@@ -30,8 +30,8 @@ public function __construct(
3030
\Magento\Tax\Api\Data\TaxRateInterfaceFactory $taxRateDataObjectFactory,
3131
\Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory $taxRateTitleDataObjectFactory
3232
) {
33-
$this->_taxRateDataObjectFactory = $taxRateDataObjectFactory;
34-
$this->_taxRateTitleDataObjectFactory = $taxRateTitleDataObjectFactory;
33+
$this->taxRateDataObjectFactory = $taxRateDataObjectFactory;
34+
$this->taxRateTitleDataObjectFactory = $taxRateTitleDataObjectFactory;
3535
}
3636
/**
3737
* Convert a tax rate data object to an array of associated titles
@@ -112,7 +112,7 @@ public function createArrayFromServiceObject(\Magento\Tax\Api\Data\TaxRateInterf
112112
*/
113113
public function populateTaxRateData($formData)
114114
{
115-
$taxRate = $this->_taxRateDataObjectFactory->create();
115+
$taxRate = $this->taxRateDataObjectFactory->create();
116116
$taxRate->setId($this->extractFormData($formData, 'tax_calculation_rate_id'))
117117
->setTaxCountryId($this->extractFormData($formData, 'tax_country_id'))
118118
->setTaxRegionId($this->extractFormData($formData, 'tax_region_id'))
@@ -127,7 +127,7 @@ public function populateTaxRateData($formData)
127127
if (isset($formData['title'])) {
128128
$titles = [];
129129
foreach ($formData['title'] as $storeId => $value) {
130-
$titles[] = $this->_taxRateTitleDataObjectFactory->create()->setStoreId($storeId)->setValue($value);
130+
$titles[] = $this->taxRateTitleDataObjectFactory->create()->setStoreId($storeId)->setValue($value);
131131
}
132132
$taxRate->setTitles($titles);
133133
}

app/code/Magento/Tax/Test/Unit/Controller/Adminhtml/Rate/AjaxLoadTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@ class AjaxLoadTest extends \PHPUnit_Framework_TestCase
1616
/**
1717
* @var \Magento\Framework\App\Request\Http
1818
*/
19-
private $_request;
19+
private $request;
2020

2121
/**
2222
* @var \Magento\Framework\App\Response\Http
2323
*/
24-
private $_resultFactory;
24+
private $resultFactory;
2525

2626
/**
2727
* @var \Magento\Tax\Model\Calculation\RateRepository
2828
*/
29-
private $_taxRateRepository;
29+
private $taxRateRepository;
3030

3131
/*
3232
* test setup
3333
*/
3434
public function setUp()
3535
{
36-
$this->_request = $this->getMockBuilder('\Magento\Framework\App\Request\Http')
36+
$this->request = $this->getMockBuilder('\Magento\Framework\App\Request\Http')
3737
->disableOriginalConstructor()
3838
->setMethods(['getParam'])
3939
->getMock();
4040

41-
$this->_resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
41+
$this->resultFactory = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
4242
->disableOriginalConstructor()
4343
->setMethods(['create'])
4444
->getMock();
4545

46-
$this->_taxRateRepository = $this->getMockBuilder('\Magento\Tax\Model\Calculation\RateRepository')
46+
$this->taxRateRepository = $this->getMockBuilder('\Magento\Tax\Model\Calculation\RateRepository')
4747
->disableOriginalConstructor()
4848
->setMethods(['get'])
4949
->getMock();
@@ -86,11 +86,11 @@ public function testExecute()
8686
]
8787
);
8888

89-
$this->_request->expects($this->any())
89+
$this->request->expects($this->any())
9090
->method('getParam')
9191
->will($this->returnValue($taxRateId));
9292

93-
$this->_taxRateRepository->expects($this->any())
93+
$this->taxRateRepository->expects($this->any())
9494
->method('get')
9595
->with($taxRateId)
9696
->will($this->returnValue($rateMock));
@@ -115,18 +115,18 @@ public function testExecute()
115115
$returnArray,
116116
]);
117117

118-
$this->_resultFactory->expects($this->any())
118+
$this->resultFactory->expects($this->any())
119119
->method('create')
120120
->with(\Magento\Framework\Controller\ResultFactory::TYPE_JSON)
121121
->willReturn($jsonObject);
122122

123123
$notification = $objectManager->getObject(
124124
'Magento\Tax\Controller\Adminhtml\Rate\AjaxLoad',
125125
[
126-
'taxRateRepository' => $this->_taxRateRepository,
126+
'taxRateRepository' => $this->taxRateRepository,
127127
'taxRateConverter' => $taxRateConverter,
128-
'request' => $this->_request,
129-
'resultFactory' => $this->_resultFactory,
128+
'request' => $this->request,
129+
'resultFactory' => $this->resultFactory,
130130
]
131131
);
132132

@@ -147,11 +147,11 @@ public function testExecuteLocalizedException()
147147

148148
$objectManager = new ObjectManager($this);
149149

150-
$this->_request->expects($this->any())
150+
$this->request->expects($this->any())
151151
->method('getParam')
152152
->will($this->returnValue($taxRateId));
153153

154-
$this->_taxRateRepository->expects($this->any())
154+
$this->taxRateRepository->expects($this->any())
155155
->method('get')
156156
->with($taxRateId)
157157
->willThrowException($noSuchEntityEx);
@@ -168,17 +168,17 @@ public function testExecuteLocalizedException()
168168
'error_message' => $exceptionMessage,
169169
]);
170170

171-
$this->_resultFactory->expects($this->any())
171+
$this->resultFactory->expects($this->any())
172172
->method('create')
173173
->with(\Magento\Framework\Controller\ResultFactory::TYPE_JSON)
174174
->willReturn($jsonObject);
175175

176176
$notification = $objectManager->getObject(
177177
'Magento\Tax\Controller\Adminhtml\Rate\AjaxLoad',
178178
[
179-
'taxRateRepository' => $this->_taxRateRepository,
180-
'request' => $this->_request,
181-
'resultFactory' => $this->_resultFactory,
179+
'taxRateRepository' => $this->taxRateRepository,
180+
'request' => $this->request,
181+
'resultFactory' => $this->resultFactory,
182182
]
183183
);
184184

@@ -197,11 +197,11 @@ public function testExecuteException()
197197

198198
$objectManager = new ObjectManager($this);
199199

200-
$this->_request->expects($this->any())
200+
$this->request->expects($this->any())
201201
->method('getParam')
202202
->will($this->returnValue($taxRateId));
203203

204-
$this->_taxRateRepository->expects($this->any())
204+
$this->taxRateRepository->expects($this->any())
205205
->method('get')
206206
->with($taxRateId)
207207
->willThrowException($noSuchEntityEx);
@@ -218,17 +218,17 @@ public function testExecuteException()
218218
'error_message' => $exceptionMessage,
219219
]);
220220

221-
$this->_resultFactory->expects($this->any())
221+
$this->resultFactory->expects($this->any())
222222
->method('create')
223223
->with(\Magento\Framework\Controller\ResultFactory::TYPE_JSON)
224224
->willReturn($jsonObject);
225225

226226
$notification = $objectManager->getObject(
227227
'Magento\Tax\Controller\Adminhtml\Rate\AjaxLoad',
228228
[
229-
'taxRateRepository' => $this->_taxRateRepository,
230-
'request' => $this->_request,
231-
'resultFactory' => $this->_resultFactory,
229+
'taxRateRepository' => $this->taxRateRepository,
230+
'request' => $this->request,
231+
'resultFactory' => $this->resultFactory,
232232
]
233233
);
234234

0 commit comments

Comments
 (0)