Skip to content

Commit

Permalink
[17] Merge api-proto with develop #71
Browse files Browse the repository at this point in the history
  • Loading branch information
le0n4ik committed Jun 12, 2020
1 parent 2916519 commit dff716b
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\TestFramework\Db\DymanicTables;

use Magento\Framework\App\ResourceConnection;
use Magento\Store\Model\Store;

/**
* Class to pre-create category product index tables
*/
class CategoryProductIndexTables
{

/**
* @var string
*/
private $prototype = 'catalog_category_product_index';

/**
* @var ResourceConnection
*/
private $resourceConnection;

/**
* @param ResourceConnection $resourceConnection
*/
public function __construct(
ResourceConnection $resourceConnection
) {
$this->resourceConnection = $resourceConnection;
}

/**
* Creates category product index tables
*/
public function createTables(): void
{
$connection = $this->resourceConnection->getConnection();
for ($storeId = 0; $storeId <= 256; $storeId++) {
$connection->createTable(
$connection->createTableByDdl(
$this->resourceConnection->getTableName($this->prototype),
$this->resourceConnection->getTableName($this->prototype) . '_' . Store::ENTITY . $storeId
)
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\TestFramework\Db;

use Magento\TestFramework\Db\DymanicTables\CategoryProductIndexTables;

/**
* Class to pre-create dynamic tables
*/
class DynamicTables
{
/**
* @var CategoryProductIndexTables
*/
private $categoryProductIndexTables;

/**
* @param CategoryProductIndexTables $categoryProductIndexTables
*/
public function __construct(
CategoryProductIndexTables $categoryProductIndexTables
) {
$this->categoryProductIndexTables = $categoryProductIndexTables;
}

/**
* Create dynamic tables before the test to preserve integration tests isolation
*/
public function createTables()
{
$this->categoryProductIndexTables->createTables();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

$appDir = dirname(\Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppTempDir());
// phpcs:ignore Magento2.Security.InsecureFunction
exec("php -f {$appDir}/bin/magento indexer:reindex");

0 comments on commit dff716b

Please sign in to comment.