subject = $this->getAccessibleMock(TeaController::class, ['redirect', 'forward']); $this->viewProphecy = $this->prophesize(TemplateView::class); $view = $this->viewProphecy->reveal(); $this->subject->_set('view', $view); $this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class); /** @var TeaRepository&ProphecySubjectInterface $teaRepository */ $teaRepository = $this->teaRepositoryProphecy->reveal(); $this->subject->injectTeaRepository($teaRepository); } /** * @test */ public function isActionController(): void { self::assertInstanceOf(ActionController::class, $this->subject); } /** * @test */ public function indexActionAssignsAllTeaAsTeasToView(): void { $teas = $this->prophesize(QueryResultInterface::class)->reveal(); $this->teaRepositoryProphecy->findAll()->willReturn($teas); $this->viewProphecy->assign('teas', $teas)->shouldBeCalled(); $this->subject->indexAction(); } /** * @test */ public function showActionAssignsPassedTeaAsTeaToView(): void { $tea = new Tea(); $this->viewProphecy->assign('tea', $tea)->shouldBeCalled(); $this->subject->showAction($tea); } }