Skip to content

Commit 6a0ab5a

Browse files
committed
MAGETWO-87467: Fix modularity of \Magento\Catalog\Block\Adminhtml\Product\Edit\JsTest
- Fix a typo in PhpDoc of \Magento\Tax\Model\ResourceModel\Calculation\Rule - Add rollback for the fixture: dev/tests/integration/testsuite/Magento/Tax/_files/tax_classes.php - Force api-functional tests to fail when exception is happened during a fixture
1 parent 26f42fe commit 6a0ab5a

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Tax\Model\ResourceModel\Calculation;
77

88
/**
9-
* Tax rate resource model
9+
* Tax rule resource model
1010
*
1111
* @author Magento Core Team <core@magentocommerce.com>
1212
*/

dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiDataFixture.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ protected function _getFixtures($scope, \PHPUnit\Framework\TestCase $test)
102102
* Execute single fixture script
103103
*
104104
* @param string|array $fixture
105+
* @throws \Exception
105106
*/
106107
protected function _applyOneFixture($fixture)
107108
{
@@ -112,9 +113,13 @@ protected function _applyOneFixture($fixture)
112113
require $fixture;
113114
}
114115
} catch (\Exception $e) {
115-
echo 'Exception occurred when running the '
116-
. (is_array($fixture) || is_scalar($fixture) ? json_encode($fixture) : 'callback')
117-
. ' fixture: ', PHP_EOL, $e;
116+
throw new \Exception(
117+
sprintf(
118+
"Exception occurred when running the %s fixture: \n%s",
119+
(\is_array($fixture) || is_scalar($fixture) ? json_encode($fixture) : 'callback'),
120+
$e->getMessage()
121+
)
122+
);
118123
}
119124
$this->_appliedFixtures[] = $fixture;
120125
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var $objectManager \Magento\TestFramework\ObjectManager */
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
10+
$taxRules = [
11+
'Test Rule',
12+
'Test Rule Duplicate',
13+
];
14+
$taxClasses = [
15+
'ProductTaxClass1',
16+
'ProductTaxClass2',
17+
'ProductTaxClass3',
18+
'CustomerTaxClass1',
19+
'CustomerTaxClass2',
20+
];
21+
22+
23+
$taxRuleResource = $objectManager->get(\Magento\Tax\Model\ResourceModel\Calculation\Rule::class);
24+
foreach ($taxRules as $taxRuleCode) {
25+
$taxRule = $objectManager->create(\Magento\Tax\Model\Calculation\Rule::class);
26+
$taxRuleResource->load($taxRule, $taxRuleCode, 'code');
27+
$taxRuleResource->delete($taxRule);
28+
}
29+
30+
/** @var \Magento\Tax\Model\ResourceModel\TaxClass $resourceModel */
31+
$resourceModel = $objectManager->get(\Magento\Tax\Model\ResourceModel\TaxClass::class);
32+
33+
foreach ($taxClasses as $taxClass) {
34+
try {
35+
/** @var \Magento\Tax\Model\ClassModel $taxClassEntity */
36+
$taxClassEntity = $objectManager->create(\Magento\Tax\Model\ClassModel::class);
37+
$resourceModel->load($taxClassEntity, $taxClass, 'class_name');
38+
$resourceModel->delete($taxClassEntity);
39+
} catch (\Magento\Framework\Exception\CouldNotDeleteException $couldNotDeleteException) {
40+
// It's okay if the entity already wiped from the database
41+
}
42+
}

0 commit comments

Comments
 (0)