本文整理汇总了PHP中Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP JoinProcessorInterface::expects方法的具体用法?PHP JoinProcessorInterface::expects怎么用?PHP JoinProcessorInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
的用法示例。
在下文中一共展示了JoinProcessorInterface::expects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: testGetList
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetList()
{
$sortOrder = $this->getMock('Magento\\Framework\\Api\\SortOrder', [], [], '', false);
$filterGroup = $this->getMock('Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
$filter = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false);
$collection = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection', [], [], '', false);
$searchResults = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressSearchResultsInterface', [], '', false);
$searchCriteria = $this->getMockForAbstractClass('Magento\\Framework\\Api\\SearchCriteriaInterface', [], '', false);
$customerModel = $this->getMock('Magento\\Customer\\Model\\Customer', ['getId', 'setId', 'setStoreId', 'getStoreId', 'getAttributeSetId', 'setAttributeSetId', 'setRpToken', 'setRpTokenCreatedAt', 'getDataModel', 'setPasswordHash', 'getCollection'], [], 'customerModel', false);
$metadata = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], '', false);
$this->searchResultsFactory->expects($this->once())->method('create')->willReturn($searchResults);
$searchResults->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
$this->customerFactory->expects($this->once())->method('create')->willReturn($customerModel);
$customerModel->expects($this->once())->method('getCollection')->willReturn($collection);
$this->extensionAttributesJoinProcessor->expects($this->once())->method('process')->with($collection, 'Magento\\Customer\\Api\\Data\\CustomerInterface');
$this->customerMetadata->expects($this->once())->method('getAllAttributesMetadata')->willReturn([$metadata]);
$metadata->expects($this->once())->method('getAttributeCode')->willReturn('attribute-code');
$collection->expects($this->once())->method('addAttributeToSelect')->with('attribute-code');
$collection->expects($this->once())->method('addNameToSelect');
$collection->expects($this->at(2))->method('joinAttribute')->with('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')->willReturnSelf();
$collection->expects($this->at(3))->method('joinAttribute')->with('billing_city', 'customer_address/city', 'default_billing', null, 'left')->willReturnSelf();
$collection->expects($this->at(4))->method('joinAttribute')->with('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')->willReturnSelf();
$collection->expects($this->at(5))->method('joinAttribute')->with('billing_region', 'customer_address/region', 'default_billing', null, 'left')->willReturnSelf();
$collection->expects($this->at(6))->method('joinAttribute')->with('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')->willReturnSelf();
$collection->expects($this->at(7))->method('joinAttribute')->with('company', 'customer_address/company', 'default_billing', null, 'left')->willReturnSelf();
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$collection->expects($this->once())->method('addFieldToFilter')->with([['attribute' => 'Field', 'eq' => 'Value']], []);
$filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
$filter->expects($this->once())->method('getConditionType')->willReturn(false);
$filter->expects($this->once())->method('getField')->willReturn('Field');
$filter->expects($this->atLeastOnce())->method('getValue')->willReturn('Value');
$collection->expects($this->once())->method('addOrder')->with('Field', 'ASC');
$searchCriteria->expects($this->atLeastOnce())->method('getSortOrders')->willReturn([$sortOrder]);
$sortOrder->expects($this->once())->method('getField')->willReturn('Field');
$sortOrder->expects($this->once())->method('getDirection')->willReturn(\Magento\Framework\Api\SortOrder::SORT_ASC);
$searchCriteria->expects($this->once())->method('getCurrentPage')->willReturn(1);
$collection->expects($this->once())->method('setCurPage')->with(1);
$searchCriteria->expects($this->once())->method('getPageSize')->willReturn(10);
$collection->expects($this->once())->method('setPageSize')->with(10);
$collection->expects($this->once())->method('getSize')->willReturn(23);
$searchResults->expects($this->once())->method('setTotalCount')->with(23);
$collection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([$customerModel]));
$customerModel->expects($this->atLeastOnce())->method('getDataModel')->willReturn($this->customer);
$searchResults->expects($this->once())->method('setItems')->with([$this->customer]);
$this->assertSame($searchResults, $this->model->getList($searchCriteria));
}
示例3: testGetListWithoutSortOrder
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetListWithoutSortOrder()
{
$groupId = 86;
$groupExtension = $this->getMock('Magento\\Customer\\Api\\Data\\GroupExtensionInterface', [], [], '', false);
$filterGroup = $this->getMock('Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
$filter = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false);
$collection = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\Group\\Collection', [], [], '', false);
$searchCriteria = $this->getMockForAbstractClass('Magento\\Framework\\Api\\SearchCriteriaInterface', [], '', false);
$searchResults = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressSearchResultsInterface', [], '', false);
$this->searchResultsFactory->expects($this->once())->method('create')->willReturn($searchResults);
$searchResults->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
$this->groupFactory->expects($this->once())->method('create')->willReturn($this->groupModel);
$this->groupModel->expects($this->once())->method('getCollection')->willReturn($collection);
$this->extensionAttributesJoinProcessor->expects($this->once())->method('process')->with($collection, 'Magento\\Customer\\Api\\Data\\GroupInterface');
$collection->expects($this->once())->method('addTaxClass');
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
$filter->expects($this->once())->method('getConditionType')->willReturn(false);
$filter->expects($this->once())->method('getField')->willReturn('Field');
$filter->expects($this->atLeastOnce())->method('getValue')->willReturn('Value');
$collection->expects($this->once())->method('addFieldToFilter')->with(['Field'], [['eq' => 'Value']]);
$searchCriteria->expects($this->once())->method('getCurrentPage')->willReturn(1);
$collection->expects($this->once())->method('setCurPage')->with(1);
$searchCriteria->expects($this->once())->method('getPageSize')->willReturn(10);
$collection->expects($this->once())->method('setPageSize')->with(10);
$collection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([$this->groupModel]));
$this->groupDataFactory->expects($this->once())->method('create')->willReturn($this->group);
$this->group->expects($this->once())->method('setId')->with($groupId)->willReturnSelf();
$this->group->expects($this->once())->method('setCode')->with('Code')->willReturnSelf();
$this->group->expects($this->once())->method('setTaxClassId')->with(234)->willReturnSelf();
$this->group->expects($this->once())->method('setTaxClassName')->with('Tax class name')->willReturnSelf();
$this->groupModel->expects($this->atLeastOnce())->method('getId')->willReturn($groupId);
$this->groupModel->expects($this->atLeastOnce())->method('getCode')->willReturn('Code');
$this->groupModel->expects($this->atLeastOnce())->method('getTaxClassId')->willReturn(234);
$this->groupModel->expects($this->atLeastOnce())->method('getTaxClassName')->willReturn('Tax class name');
$this->groupModel->expects($this->once())->method('getData')->willReturn([]);
$this->extensionAttributesJoinProcessor->expects($this->once())->method('extractExtensionAttributes')->with('Magento\\Customer\\Api\\Data\\GroupInterface', [])->willReturn(['extension_attributes' => $groupExtension]);
$this->group->expects($this->once())->method('setExtensionAttributes')->with($groupExtension);
$collection->expects($this->once())->method('getSize')->willReturn(9);
$searchResults->expects($this->once())->method('setTotalCount')->with(9);
$searchResults->expects($this->once())->method('setItems')->with([$this->group])->willReturnSelf();
$collection->expects($this->once())->method('addOrder')->with('customer_group_id', 'ASC');
$this->assertSame($searchResults, $this->model->getList($searchCriteria));
}
示例4: testGetList
public function testGetList()
{
$filterGroup = $this->getMock('Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
$filter = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false);
$collection = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\Address\\Collection', [], [], '', false);
$searchResults = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressSearchResultsInterface', [], '', false);
$searchCriteria = $this->getMockForAbstractClass('Magento\\Framework\\Api\\SearchCriteriaInterface', [], '', false);
$this->addressSearchResultsFactory->expects($this->once())->method('create')->willReturn($searchResults);
$this->addressCollectionFactory->expects($this->once())->method('create')->willReturn($collection);
$this->extensionAttributesJoinProcessor->expects($this->once())->method('process')->with($collection, 'Magento\\Customer\\Api\\Data\\AddressInterface');
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
$filter->expects($this->once())->method('getConditionType')->willReturn(false);
$filter->expects($this->once())->method('getField')->willReturn('Field');
$filter->expects($this->atLeastOnce())->method('getValue')->willReturn('Value');
$collection->expects($this->once())->method('addFieldToFilter')->with([['attribute' => 'Field', 'eq' => 'Value']], [['eq' => 'Value']]);
$collection->expects($this->once())->method('getSize')->willReturn(23);
$searchResults->expects($this->once())->method('setTotalCount')->with(23);
$sortOrder = $this->getMock('Magento\\Framework\\Api\\SortOrder', [], [], '', false);
$searchCriteria->expects($this->once())->method('getSortOrders')->willReturn([$sortOrder]);
$sortOrder->expects($this->once())->method('getField')->willReturn('Field');
$sortOrder->expects($this->once())->method('getDirection')->willReturn(\Magento\Framework\Api\SortOrder::SORT_ASC);
$collection->expects($this->once())->method('addOrder')->with('Field', 'ASC');
$searchCriteria->expects($this->once())->method('getCurrentPage')->willReturn(1);
$collection->expects($this->once())->method('setCurPage')->with(1);
$searchCriteria->expects($this->once())->method('getPageSize')->willReturn(10);
$collection->expects($this->once())->method('setPageSize')->with(10);
$collection->expects($this->once())->method('getItems')->willReturn([$this->address]);
$this->address->expects($this->once())->method('getId')->willReturn(12);
$customerAddress = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false);
$this->addressRegistry->expects($this->once())->method('retrieve')->with(12)->willReturn($this->address);
$this->address->expects($this->once())->method('getDataModel')->willReturn($customerAddress);
$searchResults->expects($this->once())->method('setItems')->with([$customerAddress]);
$searchResults->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
$this->assertSame($searchResults, $this->repository->getList($searchCriteria));
}
示例5: testGetItemsCollection
public function testGetItemsCollection()
{
$itemCollectionMock = $this->getMockBuilder('Magento\\Quote\\Model\\Resource\\Quote\\Collection')->disableOriginalConstructor()->setMethods(['setQuote'])->getMock();
$this->quoteItemCollectionFactoryMock->expects($this->once())->method('create')->willReturn($itemCollectionMock);
$this->extensionAttributesJoinProcessorMock->expects($this->once())->method('process')->with($this->isInstanceOf('Magento\\Quote\\Model\\Resource\\Quote\\Collection'));
$itemCollectionMock->expects($this->once())->method('setQuote')->with($this->quote);
$this->quote->getItemsCollection();
}