本文整理汇总了PHP中Magento\Quote\Api\CartRepositoryInterface::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP CartRepositoryInterface::getList方法的具体用法?PHP CartRepositoryInterface::getList怎么用?PHP CartRepositoryInterface::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Api\CartRepositoryInterface
的用法示例。
在下文中一共展示了CartRepositoryInterface::getList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->searchResultsDataFactory->expects($this->once())->method('create')->will($this->returnValue($searchResult));
$searchResult->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);
$searchResult->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->extensionAttributesJoinProcessorMock->expects($this->once())->method('process')->with($this->isInstanceOf('\\Magento\\Quote\\Model\\ResourceModel\\Quote\\Collection'));
$this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]);
$searchResult->expects($this->once())->method('setItems')->with([$cartMock]);
$this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock));
}