Skip to content

Commit dff716b

Browse files
committed
[17] Merge api-proto with develop #71
1 parent 2916519 commit dff716b

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Db\DymanicTables;
9+
10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Store\Model\Store;
12+
13+
/**
14+
* Class to pre-create category product index tables
15+
*/
16+
class CategoryProductIndexTables
17+
{
18+
19+
/**
20+
* @var string
21+
*/
22+
private $prototype = 'catalog_category_product_index';
23+
24+
/**
25+
* @var ResourceConnection
26+
*/
27+
private $resourceConnection;
28+
29+
/**
30+
* @param ResourceConnection $resourceConnection
31+
*/
32+
public function __construct(
33+
ResourceConnection $resourceConnection
34+
) {
35+
$this->resourceConnection = $resourceConnection;
36+
}
37+
38+
/**
39+
* Creates category product index tables
40+
*/
41+
public function createTables(): void
42+
{
43+
$connection = $this->resourceConnection->getConnection();
44+
for ($storeId = 0; $storeId <= 256; $storeId++) {
45+
$connection->createTable(
46+
$connection->createTableByDdl(
47+
$this->resourceConnection->getTableName($this->prototype),
48+
$this->resourceConnection->getTableName($this->prototype) . '_' . Store::ENTITY . $storeId
49+
)
50+
);
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Db;
9+
10+
use Magento\TestFramework\Db\DymanicTables\CategoryProductIndexTables;
11+
12+
/**
13+
* Class to pre-create dynamic tables
14+
*/
15+
class DynamicTables
16+
{
17+
/**
18+
* @var CategoryProductIndexTables
19+
*/
20+
private $categoryProductIndexTables;
21+
22+
/**
23+
* @param CategoryProductIndexTables $categoryProductIndexTables
24+
*/
25+
public function __construct(
26+
CategoryProductIndexTables $categoryProductIndexTables
27+
) {
28+
$this->categoryProductIndexTables = $categoryProductIndexTables;
29+
}
30+
31+
/**
32+
* Create dynamic tables before the test to preserve integration tests isolation
33+
*/
34+
public function createTables()
35+
{
36+
$this->categoryProductIndexTables->createTables();
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$appDir = dirname(\Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppTempDir());
8+
// phpcs:ignore Magento2.Security.InsecureFunction
9+
exec("php -f {$appDir}/bin/magento indexer:reindex");

0 commit comments

Comments
 (0)