/** * Run test getCommentsList method */ public function testGetCommentsList() { $id = 25; $returnValue = 'return-value'; $filterMock = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false); $searchCriteriaMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('setValue')->with($id)->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('create')->will($this->returnValue($filterMock)); $this->criteriaBuilderMock->expects($this->once())->method('addFilter')->with(['eq' => $filterMock]); $this->criteriaBuilderMock->expects($this->once())->method('create')->will($this->returnValue($searchCriteriaMock)); $this->commentRepositoryMock->expects($this->once())->method('getList')->with($searchCriteriaMock)->will($this->returnValue($returnValue)); $this->assertEquals($returnValue, $this->invoiceService->getCommentsList($id)); }
/** * @inheritdoc */ public function getCommentsList($id) { $this->criteriaBuilder->addFilters([$this->filterBuilder->setField('parent_id')->setValue($id)->setConditionType('eq')->create()]); $criteria = $this->criteriaBuilder->create(); return $this->commentRepository->getList($criteria); }