Skip to content

Commit

Permalink
MAGETWO-69805: Return array of blocks as items instead of array of ar…
Browse files Browse the repository at this point in the history
…rays #9157
  • Loading branch information
Oleksii Korshenko authored Jun 12, 2017
2 parents d1b86ae + e091cfd commit 7592b8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
17 changes: 1 addition & 16 deletions app/code/Magento/Cms/Model/BlockRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $criteria

$this->collectionProcessor->process($criteria, $collection);

$blocks = [];
/** @var Block $blockModel */
foreach ($collection as $blockModel) {
$blockData = $this->dataBlockFactory->create();
$this->dataObjectHelper->populateWithArray(
$blockData,
$blockModel->getData(),
\Magento\Cms\Api\Data\BlockInterface::class
);
$blocks[] = $this->dataObjectProcessor->buildOutputDataArray(
$blockData,
\Magento\Cms\Api\Data\BlockInterface::class
);
}

/** @var Data\BlockSearchResultsInterface $searchResults */
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($criteria);
$searchResults->setItems($blocks);
$searchResults->setItems($collection->getItems());
$searchResults->setTotalCount($collection->getSize());
return $searchResults;
}
Expand Down
16 changes: 1 addition & 15 deletions app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,8 @@ public function testGetList()
->willReturnSelf();
$this->blockSearchResult->expects($this->once())
->method('setItems')
->with(['someData'])
->with([$this->block])
->willReturnSelf();

$this->block->expects($this->once())
->method('getData')
->willReturn(['data']);

$this->dataHelper->expects($this->once())
->method('populateWithArray')
->with($this->blockData, ['data'], \Magento\Cms\Api\Data\BlockInterface::class);

$this->dataObjectProcessor->expects($this->once())
->method('buildOutputDataArray')
->with($this->blockData, \Magento\Cms\Api\Data\BlockInterface::class)
->willReturn('someData');

$this->assertEquals($this->blockSearchResult, $this->repository->getList($criteria));
}
}

0 comments on commit 7592b8c

Please sign in to comment.