Skip to content

Commit

Permalink
MAGETWO-69666: Return array of pages as items instead of array of arr…
Browse files Browse the repository at this point in the history
…ays #9823
  • Loading branch information
Oleksii Korshenko authored Jun 12, 2017
2 parents bb98ac1 + 02172bd commit 5112cfb
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/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $criteria

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

$pages = [];
/** @var Page $pageModel */
foreach ($collection as $pageModel) {
$pageData = $this->dataPageFactory->create();
$this->dataObjectHelper->populateWithArray(
$pageData,
$pageModel->getData(),
\Magento\Cms\Api\Data\PageInterface::class
);
$pages[] = $this->dataObjectProcessor->buildOutputDataArray(
$pageData,
\Magento\Cms\Api\Data\PageInterface::class
);
}

/** @var Data\PageSearchResultsInterface $searchResults */
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($criteria);
$searchResults->setItems($pages);
$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/PageRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,8 @@ public function testGetList()
->willReturnSelf();
$this->pageSearchResult->expects($this->once())
->method('setItems')
->with(['someData'])
->with([$this->page])
->willReturnSelf();

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

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

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

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

0 comments on commit 5112cfb

Please sign in to comment.