Skip to content

Commit 5929940

Browse files
committed
MC-24010: Broken integration test RelationTest.php on mainline 2.3
1 parent 3c3c8ed commit 5929940

File tree

1 file changed

+61
-41
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action

1 file changed

+61
-41
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RelationTest.php

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\DB\Adapter\AdapterInterface;
1313
use Magento\Store\Model\StoreManagerInterface;
14-
use Magento\TestFramework\Catalog\Model\Indexer\Product\Flat\Action\Full as FlatIndexerFull;
14+
use Magento\Catalog\Model\Indexer\Product\Flat\Action\Full as FlatIndexerFull;
15+
use Magento\Catalog\Helper\Product\Flat\Indexer;
16+
use Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder;
17+
use Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder;
18+
use Magento\Framework\Exception\LocalizedException;
19+
use Magento\TestFramework\Helper\Bootstrap;
1520

1621
/**
1722
* Test relation customization
@@ -42,33 +47,79 @@ class RelationTest extends \Magento\TestFramework\Indexer\TestCase
4247
*/
4348
private $flatUpdated = [];
4449

50+
/**
51+
* @var Indexer
52+
*/
53+
private $productIndexerHelper;
54+
4555
/**
4656
* @inheritdoc
4757
*/
4858
protected function setUp(): void
4959
{
50-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
60+
$objectManager = Bootstrap::getObjectManager();
5161

52-
$tableBuilderMock = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder::class);
53-
$flatTableBuilderMock = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class);
62+
$tableBuilderMock = $objectManager->get(TableBuilder::class);
63+
$flatTableBuilderMock =
64+
$objectManager->get(FlatTableBuilder::class);
5465

55-
$productIndexerHelper = $objectManager->create(
56-
\Magento\Catalog\Helper\Product\Flat\Indexer::class,
57-
['addChildData' => 1]
66+
$this->productIndexerHelper = $objectManager->create(
67+
Indexer::class,
68+
['addChildData' => true]
5869
);
5970
$this->indexer = $objectManager->create(
6071
FlatIndexerFull::class,
6172
[
62-
'productHelper' => $productIndexerHelper,
73+
'productHelper' => $this->productIndexerHelper,
6374
'tableBuilder' => $tableBuilderMock,
6475
'flatTableBuilder' => $flatTableBuilderMock
6576
]
6677
);
67-
$this->storeManager = $objectManager->create(StoreManagerInterface::class);
78+
$this->storeManager = $objectManager->get(StoreManagerInterface::class);
6879
$this->connection = $objectManager->get(ResourceConnection::class)->getConnection();
80+
}
81+
82+
/**
83+
* @inheritdoc
84+
*/
85+
protected function tearDown(): void
86+
{
87+
foreach ($this->flatUpdated as $flatTable) {
88+
$this->connection->dropColumn($flatTable, 'child_id');
89+
$this->connection->dropColumn($flatTable, 'is_child');
90+
}
91+
}
92+
93+
/**
94+
* Test that SQL generated for relation customization is valid
95+
*
96+
* @return void
97+
* @throws LocalizedException
98+
* @throws \Exception
99+
*/
100+
public function testExecute() : void
101+
{
102+
$this->addChildColumns();
103+
try {
104+
$result = $this->indexer->execute();
105+
} catch (LocalizedException $e) {
106+
if ($e->getPrevious() instanceof \Zend_Db_Statement_Exception) {
107+
$this->fail($e->getMessage());
108+
}
109+
throw $e;
110+
}
111+
$this->assertInstanceOf(FlatIndexerFull::class, $result);
112+
}
69113

114+
/**
115+
* Add child columns to tables if needed
116+
*
117+
* @return void
118+
*/
119+
private function addChildColumns(): void
120+
{
70121
foreach ($this->storeManager->getStores() as $store) {
71-
$flatTable = $productIndexerHelper->getFlatTableName($store->getId());
122+
$flatTable = $this->productIndexerHelper->getFlatTableName($store->getId());
72123
if ($this->connection->isTableExists($flatTable) &&
73124
!$this->connection->tableColumnExists($flatTable, 'child_id') &&
74125
!$this->connection->tableColumnExists($flatTable, 'is_child')
@@ -103,35 +154,4 @@ protected function setUp(): void
103154
}
104155
}
105156
}
106-
107-
/**
108-
* @inheritdoc
109-
*/
110-
protected function tearDown(): void
111-
{
112-
foreach ($this->flatUpdated as $flatTable) {
113-
$this->connection->dropColumn($flatTable, 'child_id');
114-
$this->connection->dropColumn($flatTable, 'is_child');
115-
}
116-
}
117-
118-
/**
119-
* Test that SQL generated for relation customization is valid
120-
*
121-
* @return void
122-
* @throws \Magento\Framework\Exception\LocalizedException
123-
* @throws \Exception
124-
*/
125-
public function testExecute() : void
126-
{
127-
$this->markTestSkipped('MC-19675');
128-
try {
129-
$this->indexer->execute();
130-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
131-
if ($e->getPrevious() instanceof \Zend_Db_Statement_Exception) {
132-
$this->fail($e->getMessage());
133-
}
134-
throw $e;
135-
}
136-
}
137157
}

0 commit comments

Comments
 (0)