/** * @test */ public function findDemanded() { $itemDemand = $this->getMock(ItemDemand::class); $result = $this->getMock(QueryResult::class, array(), array(), '', FALSE); $query = $this->getMock(Query::class, array('execute'), array(), '', FALSE); $itemDemand->expects($this->once())->method('getTitle')->will($this->returnValue('')); $itemDemand->expects($this->once())->method('getLimit')->will($this->returnValue(0)); $query->expects($this->once())->method('execute')->will($this->returnValue($result)); $this->subject->expects($this->once())->method('createQuery')->will($this->returnValue($query)); $this->assertEquals($result, $this->subject->findDemanded($itemDemand)); }
/** * @test * @dataProvider searchByTitleDataProvider */ public function searchByTitle($title, $matches) { $itemDemand = new ItemDemand(); $itemDemand->setTitle($title); $items = $this->itemRepository->findDemanded($itemDemand); $this->assertCount($matches, $items); $this->assertContainsOnlyInstancesOf(Item::class, $items); }
/** * action list * * @param \Frappant\FrpExample\Domain\Model\Dto\ItemDemand $itemDemand * @return void */ public function listAction(\Frappant\FrpExample\Domain\Model\Dto\ItemDemand $itemDemand) { $items = $this->itemRepository->findDemanded($itemDemand); $this->view->assign('items', $items); $this->view->assign('itemDemand', $itemDemand); }