public function testInitAddToCustomerGroups() { $searchCriteria = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $groupSearchResult = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], '', false); $this->groupRepository->expects($this->once())->method('getList')->with($searchCriteria)->willReturn($groupSearchResult); $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass(); $expectedCode = 'code'; $expectedId = 'id'; $expectedCustomerGroups = [$expectedCode => $expectedId]; $groupTest->expects($this->once())->method('getCode')->willReturn($expectedCode); $groupTest->expects($this->once())->method('getId')->willReturn($expectedId); $groups = [$groupTest]; $groupSearchResult->expects($this->once())->method('getItems')->willReturn($groups); $this->tierPrice->init(); $this->assertEquals($expectedCustomerGroups, $this->getPropertyValue($this->tierPrice, 'customerGroups')); }
/** * @dataProvider isValidAddMessagesCallDataProvider * * @param array $value * @param bool $hasEmptyColumns * @param array $customerGroups * @param array $expectedMessages */ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGroups, $expectedMessages) { $priceContextMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', [], ['\\Magento\\Framework\\Json\\Helper\\Data', '\\Magento\\ImportExport\\Helper\\Data', '\\Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', '\\Magento\\Eav\\Model\\Config', '\\Magento\\Framework\\App\\ResourceConnection', '\\Magento\\ImportExport\\Model\\ResourceModel\\Helper', '\\Magento\\Framework\\Stdlib\\StringUtils', 'ProcessingErrorAggregatorInterface'], '', false); $this->tierPrice->expects($this->once())->method('isValidValueAndLength')->willReturn(true); $this->tierPrice->expects($this->any())->method('hasEmptyColumns')->willReturn($hasEmptyColumns); $this->setPropertyValue($this->tierPrice, 'customerGroups', $customerGroups); $searchCriteria = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria); $groupSearchResult = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], '', false); $this->groupRepository->expects($this->any())->method('getList')->with($searchCriteria)->willReturn($groupSearchResult); $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass(); $groupTest->expects($this->once())->method('getCode'); $groupTest->expects($this->any())->method('getId'); $groups = [$groupTest]; $groupSearchResult->expects($this->any())->method('getItems')->willReturn($groups); $this->tierPrice->init($priceContextMock); $this->tierPrice->isValid($value); }