示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getList');
     if (!$pluginInfo) {
         return parent::getList($searchCriteria);
     } else {
         return $this->___callPlugins('getList', func_get_args(), $pluginInfo);
     }
 }
 /**
  * @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));
 }