本文整理汇总了PHP中Magento\Quote\Model\QuoteRepository::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP QuoteRepository::getList方法的具体用法?PHP QuoteRepository::getList怎么用?PHP QuoteRepository::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\QuoteRepository
的用法示例。
在下文中一共展示了QuoteRepository::getList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetListSuccess
/**
* @param int $direction
* @param string $expectedDirection
* @dataProvider getListSuccessDataProvider
*/
public function testGetListSuccess($direction, $expectedDirection)
{
$searchResult = $this->getMock('\\Magento\\Quote\\Api\\Data\\CartSearchResultsInterface', [], [], '', false);
$searchCriteriaMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteria', [], [], '', false);
$cartMock = $this->getMock('Magento\\Payment\\Model\\Cart', [], [], '', false);
$filterMock = $this->getMock('\\Magento\\Framework\\Api\\Filter', [], [], '', false);
$pageSize = 10;
$this->searchResultsBuilderMock->expects($this->once())->method('setSearchCriteria');
$filterGroupMock = $this->getMock('\\Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
$searchCriteriaMock->expects($this->any())->method('getFilterGroups')->will($this->returnValue([$filterGroupMock]));
//addFilterGroupToCollection() checks
$filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock]));
$filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id'));
$filterMock->expects($this->any())->method('getConditionType')->will($this->returnValue('eq'));
$filterMock->expects($this->once())->method('getValue')->will($this->returnValue('filter_value'));
//back in getList()
$this->quoteCollectionMock->expects($this->once())->method('getSize')->willReturn($pageSize);
$this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with($pageSize);
$sortOrderMock = $this->getMockBuilder('Magento\\Framework\\Api\\SortOrder')->setMethods(['getField', 'getDirection'])->disableOriginalConstructor()->getMock();
//foreach cycle
$searchCriteriaMock->expects($this->once())->method('getSortOrders')->will($this->returnValue([$sortOrderMock]));
$sortOrderMock->expects($this->once())->method('getField')->will($this->returnValue('id'));
$sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction));
$this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('id', $expectedDirection);
$searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1));
$searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10));
$this->quoteCollectionMock->expects($this->once())->method('setCurPage')->with(1);
$this->quoteCollectionMock->expects($this->once())->method('setPageSize')->with(10);
$this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]);
$this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$cartMock]);
$this->searchResultsBuilderMock->expects($this->once())->method('create')->will($this->returnValue($searchResult));
$this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock));
}
示例2: getList
/**
* {@inheritdoc}
*/
public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getList');
if (!$pluginInfo) {
return parent::getList($searchCriteria);
} else {
return $this->___callPlugins('getList', func_get_args(), $pluginInfo);
}
}