public function testGetTaxClassIdByNameType() { $taxClassKey = $this->getMock('\\Magento\\Tax\\Api\\Data\\TaxClassKeyInterface'); $taxClassKey->expects($this->once())->method('getType')->willReturn(\Magento\Tax\Api\Data\TaxClassKeyInterface::TYPE_NAME); $taxClassKey->expects($this->once())->method('getValue')->willReturn('value'); $this->filterBuilder->expects($this->exactly(2))->method('setField')->with($this->logicalOr(\Magento\Tax\Api\Data\TaxClassInterface::KEY_TYPE, \Magento\Tax\Api\Data\TaxClassInterface::KEY_NAME))->willReturnSelf(); $this->filterBuilder->expects($this->exactly(2))->method('setValue')->with($this->logicalOr('PRODUCT', 'value'))->willReturnSelf(); $filter = $this->getMock('\\Magento\\Framework\\Api\\Filter', [], [], '', false); $this->filterBuilder->expects($this->exactly(2))->method('create')->willReturn($filter); $this->searchCriteriaBuilder->expects($this->exactly(2))->method('addFilter')->with([$filter])->willReturnSelf(); $searchCriteria = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteriaInterface'); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $result = $this->getMock('\\Magento\\Tax\\Api\\Data\\TaxRateSearchResultsInterface'); $result->expects($this->once())->method('getItems')->willReturn([]); $this->classRepository->expects($this->once())->method('getList')->with($searchCriteria)->willReturn($result); $this->assertNull($this->model->getTaxClassId($taxClassKey), 'PRODUCT'); }