Skip to content

Commit b21f09f

Browse files
committed
MAGETWO-90562: [Forwardport] Fix transaction level in integration tests framework
1 parent dc7f483 commit b21f09f

File tree

5 files changed

+143
-5
lines changed

5 files changed

+143
-5
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer;
77

8+
use Magento\TestFramework\Helper\Bootstrap;
9+
810
/**
911
* @magentoDbIsolation enabled
1012
*/
11-
class FlatTest extends \PHPUnit\Framework\TestCase
13+
class FlatTest extends \Magento\TestFramework\Indexer\TestCase
1214
{
1315
/**
1416
* @var int
@@ -56,6 +58,16 @@ class FlatTest extends \PHPUnit\Framework\TestCase
5658
public static function setUpBeforeClass()
5759
{
5860
self::loadAttributeCodes();
61+
62+
$db = Bootstrap::getInstance()->getBootstrap()
63+
->getApplication()
64+
->getDbInstance();
65+
if (!$db->isDbDumpExists()) {
66+
throw new \LogicException('DB dump does not exist.');
67+
}
68+
$db->restoreFromDbDump();
69+
70+
parent::setUpBeforeClass();
5971
}
6072

6173
public function testEntityItemsBefore()
@@ -71,6 +83,8 @@ public function testEntityItemsBefore()
7183
*
7284
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
7385
* @magentoAppArea frontend
86+
*
87+
* @magentoDbIsolation disabled
7488
*/
7589
public function testReindexAll()
7690
{
@@ -105,6 +119,8 @@ public function testFlatItemsBefore()
105119
* Populate EAV category data`
106120
*
107121
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
122+
*
123+
* @magentoDbIsolation disabled
108124
*/
109125
public function testCreateCategory()
110126
{
@@ -115,6 +131,8 @@ public function testCreateCategory()
115131

116132
$this->assertEquals(self::$defaultCategoryId, $result[self::$categoryOne]->getParentId());
117133
$this->assertEquals(self::$categoryOne, $result[self::$categoryTwo]->getParentId());
134+
135+
$this->removeSubCategoriesInDefaultCategory();
118136
}
119137

120138
/**
@@ -123,6 +141,8 @@ public function testCreateCategory()
123141
*
124142
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
125143
* @magentoAppArea frontend
144+
*
145+
* @magentoDbIsolation disabled
126146
*/
127147
public function testFlatAfterCreate()
128148
{
@@ -150,18 +170,24 @@ public function testFlatAfterCreate()
150170

151171
$this->assertEquals(self::$categoryOne, $categoryTwo->getParentId());
152172
$this->checkCategoryData($categoryTwo);
173+
174+
$this->removeSubCategoriesInDefaultCategory();
153175
}
154176

155177
/**
156178
* Move category and populate EAV category data
157179
*
158180
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
181+
*
182+
* @magentoDbIsolation disabled
159183
*/
160184
public function testMoveCategory()
161185
{
162186
$this->moveSubCategoriesInDefaultCategory();
163187
$categoryTwo = $this->getLoadedCategory(self::$categoryTwo);
164188
$this->assertEquals($categoryTwo->getData('parent_id'), self::$defaultCategoryId);
189+
190+
$this->removeSubCategoriesInDefaultCategory();
165191
}
166192

167193
/**
@@ -170,6 +196,8 @@ public function testMoveCategory()
170196
*
171197
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
172198
* @magentoAppArea frontend
199+
*
200+
* @magentoDbIsolation disabled
173201
*/
174202
public function testFlatAfterMove()
175203
{
@@ -188,6 +216,8 @@ public function testFlatAfterMove()
188216

189217
$categoryTwo = $this->getLoadedCategory(self::$categoryTwo);
190218
$this->checkCategoryData($categoryTwo);
219+
220+
$this->removeSubCategoriesInDefaultCategory();
191221
}
192222

193223
/**
@@ -357,7 +387,17 @@ private function deleteSubCategoriesInDefaultCategory()
357387
{
358388
$this->executeWithFlatEnabledInAdminArea(function () {
359389
$this->createSubCategoriesInDefaultCategory();
390+
$this->removeSubCategoriesInDefaultCategory();
391+
});
392+
}
360393

394+
/**
395+
* Invoke business logic:
396+
* - delete created categories
397+
*/
398+
private function removeSubCategoriesInDefaultCategory()
399+
{
400+
$this->executeWithFlatEnabledInAdminArea(function () {
361401
$category = $this->instantiateCategoryModel();
362402
$category->load(self::$categoryTwo);
363403
$category->delete();
@@ -427,4 +467,12 @@ private function getActiveConfigInstance()
427467
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
428468
);
429469
}
470+
471+
/**
472+
* teardown
473+
*/
474+
public function tearDown()
475+
{
476+
parent::tearDown();
477+
}
430478
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Eav/Action/FullTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product\Eav\Action;
77

8+
use Magento\TestFramework\Helper\Bootstrap;
9+
810
/**
911
* Full reindex Test
1012
*/
11-
class FullTest extends \PHPUnit\Framework\TestCase
13+
class FullTest extends \Magento\TestFramework\Indexer\TestCase
1214
{
1315
/**
1416
* @var \Magento\Catalog\Model\Indexer\Product\Eav\Processor
1517
*/
1618
protected $_processor;
1719

20+
public static function setUpBeforeClass()
21+
{
22+
$db = Bootstrap::getInstance()->getBootstrap()
23+
->getApplication()
24+
->getDbInstance();
25+
if (!$db->isDbDumpExists()) {
26+
throw new \LogicException('DB dump does not exist.');
27+
}
28+
$db->restoreFromDbDump();
29+
30+
parent::setUpBeforeClass();
31+
}
32+
1833
protected function setUp()
1934
{
2035
$this->_processor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
@@ -61,4 +76,12 @@ public function testReindexAll()
6176
$this->assertEquals(1, $product->getWeight());
6277
}
6378
}
79+
80+
/**
81+
* teardown
82+
*/
83+
public function tearDown()
84+
{
85+
parent::tearDown();
86+
}
6487
}

dev/tests/integration/testsuite/Magento/Framework/Backup/DbTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,26 @@
1616
/**
1717
* Provide tests for \Magento\Framework\Backup\Db.
1818
*/
19-
class DbTest extends TestCase
19+
class DbTest extends \Magento\TestFramework\Indexer\TestCase
2020
{
21+
public static function setUpBeforeClass()
22+
{
23+
$db = Bootstrap::getInstance()->getBootstrap()
24+
->getApplication()
25+
->getDbInstance();
26+
if (!$db->isDbDumpExists()) {
27+
throw new \LogicException('DB dump does not exist.');
28+
}
29+
$db->restoreFromDbDump();
30+
31+
parent::setUpBeforeClass();
32+
}
33+
2134
/**
2235
* Test db backup includes triggers.
2336
*
2437
* @magentoDataFixture Magento/Framework/Backup/_files/trigger.php
38+
* @magentoDbIsolation disabled
2539
*/
2640
public function testBackupIncludesCustomTriggers()
2741
{
@@ -48,4 +62,12 @@ public function testBackupIncludesCustomTriggers()
4862
//Clean up.
4963
$write->delete('/backups/' . $time . '_db_testbackup.sql');
5064
}
65+
66+
/**
67+
* teardown
68+
*/
69+
public function tearDown()
70+
{
71+
parent::tearDown();
72+
}
5173
}

dev/tests/integration/testsuite/Magento/GraphQl/Controller/GraphQlControllerTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212
use Magento\Framework\App\Request\Http;
1313
use Magento\Framework\EntityManager\MetadataPool;
1414
use Magento\Framework\Serialize\SerializerInterface;
15+
use Magento\TestFramework\Helper\Bootstrap;
1516

1617
/**
1718
* Tests the dispatch method in the GraphQl Controller class using a simple product query
1819
*
1920
* @magentoAppArea graphql
2021
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
22+
* @magentoDbIsolation disabled
2123
*/
22-
class GraphQlControllerTest extends \PHPUnit\Framework\TestCase
24+
class GraphQlControllerTest extends \Magento\TestFramework\Indexer\TestCase
2325
{
2426
const CONTENT_TYPE = 'application/json';
2527

@@ -35,6 +37,19 @@ class GraphQlControllerTest extends \PHPUnit\Framework\TestCase
3537
/** @var MetadataPool */
3638
private $metadataPool;
3739

40+
public static function setUpBeforeClass()
41+
{
42+
$db = Bootstrap::getInstance()->getBootstrap()
43+
->getApplication()
44+
->getDbInstance();
45+
if (!$db->isDbDumpExists()) {
46+
throw new \LogicException('DB dump does not exist.');
47+
}
48+
$db->restoreFromDbDump();
49+
50+
parent::setUpBeforeClass();
51+
}
52+
3853
protected function setUp() : void
3954
{
4055
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -153,4 +168,12 @@ public function testError() : void
153168
}
154169
}
155170
}
171+
172+
/**
173+
* teardown
174+
*/
175+
public function tearDown()
176+
{
177+
parent::tearDown();
178+
}
156179
}

dev/tests/integration/testsuite/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreementTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,26 @@
66
namespace Magento\Paypal\Model\Payment\Method\Billing;
77

88
use Magento\Quote\Api\Data\PaymentInterface;
9+
use Magento\TestFramework\Helper\Bootstrap;
910

10-
class AbstractAgreementTest extends \PHPUnit\Framework\TestCase
11+
class AbstractAgreementTest extends \Magento\TestFramework\Indexer\TestCase
1112
{
1213
/** @var \Magento\Paypal\Model\Method\Agreement */
1314
protected $_model;
1415

16+
public static function setUpBeforeClass()
17+
{
18+
$db = Bootstrap::getInstance()->getBootstrap()
19+
->getApplication()
20+
->getDbInstance();
21+
if (!$db->isDbDumpExists()) {
22+
throw new \LogicException('DB dump does not exist.');
23+
}
24+
$db->restoreFromDbDump();
25+
26+
parent::setUpBeforeClass();
27+
}
28+
1529
protected function setUp()
1630
{
1731
$config = $this->getMockBuilder(\Magento\Paypal\Model\Config::class)->disableOriginalConstructor()->getMock();
@@ -72,4 +86,12 @@ public function testAssignData()
7286
$info->getAdditionalInformation(AbstractAgreement::PAYMENT_INFO_REFERENCE_ID)
7387
);
7488
}
89+
90+
/**
91+
* teardown
92+
*/
93+
public function tearDown()
94+
{
95+
parent::tearDown();
96+
}
7597
}

0 commit comments

Comments
 (0)