diff --git a/app/code/Magento/Cms/Model/BlockRepository.php b/app/code/Magento/Cms/Model/BlockRepository.php index a06c5fac1bc4e..5f8ec399e9bd6 100644 --- a/app/code/Magento/Cms/Model/BlockRepository.php +++ b/app/code/Magento/Cms/Model/BlockRepository.php @@ -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; } diff --git a/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php b/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php index dd43f4a0b2287..6e4440ef97b25 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php @@ -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)); } }