Example #1
0
 public function testSearch()
 {
     $searchCriteria = $this->createSearchCriteria();
     $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
     /** @var \PHPUnit_Framework_MockObject_MockObject $taxClassModelMock */
     $taxClassModelMock = $this->getMockBuilder('Magento\\Tax\\Model\\ClassModel')->disableOriginalConstructor()->getMock();
     $collectionMock = $this->mockTaxClassCollection($taxClassModelMock);
     $this->taxClassCollectionFactory->expects($this->once())->method('create')->will($this->returnValue($collectionMock));
     /** @var \PHPUnit_Framework_MockObject_MockObject $taxMock */
     $taxClassMock = $this->getMockBuilder('Magento\\Tax\\Service\\V1\\Data\\TaxClass')->disableOriginalConstructor()->getMock();
     $this->converterMock->expects($this->once())->method('createTaxClassData')->with($taxClassModelMock)->will($this->returnValue($taxClassMock));
     $this->searchResultBuilder->expects($this->once())->method('setItems')->will($this->returnValue([$taxClassMock]));
     $this->taxClassService->searchTaxClass($searchCriteria);
 }
 public function testSearch()
 {
     $collectionSize = 3;
     $currentPage = 1;
     $pageSize = 10;
     $searchCriteria = $this->createSearchCriteria();
     $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteria);
     /** @var \PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Tax\\Model\\Resource\\TaxClass\\Collection')->disableOriginalConstructor()->setMethods(['addFieldToFilter', 'getSize', 'setCurPage', 'setPageSize', 'getItems', 'addOrder'])->getMock();
     $this->taxClassCollectionFactory->expects($this->once())->method('create')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->exactly(2))->method('addFieldToFilter');
     $collectionMock->expects($this->any())->method('getSize')->will($this->returnValue($collectionSize));
     $collectionMock->expects($this->once())->method('setCurPage')->with($currentPage);
     $collectionMock->expects($this->once())->method('setPageSize')->with($pageSize);
     $collectionMock->expects($this->once())->method('addOrder')->with('class_name', 'ASC');
     /** @var \PHPUnit_Framework_MockObject_MockObject $taxClassModelMock */
     $taxClassModelMock = $this->getMockBuilder('Magento\\Tax\\Model\\ClassModel')->disableOriginalConstructor()->getMock();
     $collectionMock->expects($this->once())->method('getItems')->will($this->returnValue([$taxClassModelMock]));
     /** @var \PHPUnit_Framework_MockObject_MockObject $taxMock */
     $taxClassMock = $this->getMockBuilder('Magento\\Tax\\Service\\V1\\Data\\TaxClass')->disableOriginalConstructor()->getMock();
     $this->converterMock->expects($this->once())->method('createTaxClassData')->with($taxClassModelMock)->will($this->returnValue($taxClassMock));
     $this->searchResultBuilder->expects($this->once())->method('setItems')->will($this->returnValue([$taxClassMock]));
     $this->taxClassService->searchTaxClass($searchCriteria);
 }