Skip to content

Commit

Permalink
[task] #91
Browse files Browse the repository at this point in the history
- phpcs fixes
- phpunit fixes
  • Loading branch information
larsroettig committed Sep 30, 2017
1 parent 6c8cf81 commit f2a4ac7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ public function execute(array $sourceItemIds): array
->from(
['source_item' => $sourceItemTable],
[
SourceItemInterface::SKU => sprintf("GROUP_CONCAT(DISTINCT %s SEPARATOR ',')",
'source_item.' . SourceItemInterface::SKU
)
SourceItemInterface::SKU =>
sprintf("GROUP_CONCAT(DISTINCT %s SEPARATOR ',')", 'source_item.' . SourceItemInterface::SKU)
]
)->joinInner(['stock_source_link' => $sourceStockLinkTable],
)->joinInner(
['stock_source_link' => $sourceStockLinkTable],
'source_item.' . SourceItemInterface::SOURCE_ID . ' = stock_source_link.' . StockSourceLink::SOURCE_ID,
[StockSourceLink::STOCK_ID]
)
->where('source_item.source_item_id IN (?)', $sourceItemIds)
)->where('source_item.source_item_id IN (?)', $sourceItemIds)
->group(['stock_source_link.' . StockSourceLink::STOCK_ID]);

$items = $connection->fetchAll($select);
Expand All @@ -67,7 +66,7 @@ public function execute(array $sourceItemIds): array
* @param array $items
* @return array
*/
private function getStockIdToSkus(array $items) :array
private function getStockIdToSkus(array $items): array
{
$stockIds = [];
foreach ($items as $item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getData(int $stockId, array $skuList = []): \ArrayIterator
->where('stock_source_link.' . StockSourceLink::STOCK_ID . ' = ?', $stockId)
->where('stock_source_link.' . StockSourceLink::SOURCE_ID . ' IN (?)', $sourceIds);

if (count($skuList) === 0) {
if (count($skuList) !== 0) {
$select->where('source_item.' . SourceItemInterface::SKU . ' IN (?)', $skuList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public function cleanUp(
$this->createTable($connection, $tableName);
return;
}
$where = ['sku in (?)' => $skuList];
$connection->delete($tableName, $where);
$connection->delete($tableName, ['sku in (?)' => $skuList]);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Inventory/Indexer/StockItem/StockItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Inventory\Indexer\StockItem;

use Magento\Inventory\Indexer\Alias;
Expand Down Expand Up @@ -53,8 +54,8 @@ class StockItem implements StockItemIndexerInterface
private $indexNameBuilder;

/**
* @param GetDeltaReindexData $getDeltaReindexData,
* @param GetFullReindexData $getFullReindexData,
* @param GetDeltaReindexData $getDeltaReindexData ,
* @param GetFullReindexData $getFullReindexData ,
* @param IndexStructureInterface $indexStructureHandler
* @param IndexHandlerInterface $indexHandler
* @param IndexDataProvider $indexDataProvider
Expand Down Expand Up @@ -125,8 +126,7 @@ public function executeList(array $sourceItemIds)
{
$stockIds = $this->getDeltaReindexData->execute($sourceItemIds);

foreach($stockIds as $stockId => $skuList)
{
foreach ($stockIds as $stockId => $skuList) {
$mainIndexName = $this->indexNameBuilder
->setIndexId(StockItemIndexerInterface::INDEXER_ID)
->addDimension('stock_', $stockId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function tearDown()
->setIndexId(StockItemIndexerInterface::INDEXER_ID)
->addDimension('stock_', $stockId)
->setAlias(Alias::ALIAS_MAIN)
->create();
->build();
$indexStructure->delete($indexName);
}
}
Expand All @@ -91,10 +91,6 @@ public function testReindexRow()
self::assertEquals(8.5, $this->indexerChecker->execute(1, 'SKU-1'));
self::assertEquals(0, $this->indexerChecker->execute(2, 'SKU-1'));
self::assertEquals(8.5, $this->indexerChecker->execute(3, 'SKU-1'));

self::assertEquals(0, $this->indexerChecker->execute(1, 'SKU-2'));
self::assertEquals(0, $this->indexerChecker->execute(2, 'SKU-2'));
self::assertEquals(0, $this->indexerChecker->execute(3, 'SKU-2'));
}

/**
Expand Down

0 comments on commit f2a4ac7

Please sign in to comment.