/** * @test */ public function testBranchesAreFiltered() { $branches = array(new Branch('DUMM', 'DUMMY_NAME_1', 'DUMMY_DESC_1'), new Branch('DUMMY', 'DUMMY_NAME_2', 'DUMMY_DESC_2')); $pagingInfo = new PagingInfo(1, new FilterPagingProperties()); $command = new FilterBranchesCommand(); $command->name = 'NAME_2'; $this->branchRepository->expects($this->once())->method('filter')->with($this->equalTo(array(array('name', 'like', 'NAME_2'))), $this->equalTo(new FilterPagingProperties()))->will($this->returnValue(array($branches[0]))); $this->apiPagingService->expects($this->once())->method('getPagingInfo')->will($this->returnValue($pagingInfo)); $retrievedBranches = $this->branchServiceImpl->listAllBranches($command); $this->assertNotNull($retrievedBranches); $this->assertTrue(is_array($retrievedBranches)); $this->assertNotEmpty($retrievedBranches); $this->assertEquals($branches[0], $retrievedBranches[0]); }
public function testCommentsFiltered() { $comments = array(new Comment("DUMMY_CONTENT_1", $this->_dummyTicket, $this->createAuthor(), false), new Comment("DUMMY_CONTENT_2", $this->_dummyTicket, $this->createAuthor(), false)); $command = new FilterCommentsCommand(); $command->author = 'oro_1'; $pagingInfo = new PagingInfo(1, new FilterPagingProperties()); $this->commentRepository->expects($this->once())->method('filter')->with($this->equalTo(array(array('author', 'eq', 'oro_1'))), $this->equalTo(new FilterPagingProperties()))->will($this->returnValue(array($comments[1]))); $this->apiPagingService->expects($this->once())->method('getPagingInfo')->will($this->returnValue($pagingInfo)); $retrievedComments = $this->service->listAllComments($command); $this->assertNotNull($retrievedComments); $this->assertTrue(is_array($retrievedComments)); $this->assertNotEmpty($retrievedComments); $this->assertEquals($comments[1], $retrievedComments[0]); }