subject = $this->getAccessibleMock( TeaController::class, ['forward', 'redirect', 'redirectToUri', 'htmlResponse'] ); $this->viewMock = $this->createMock(TemplateView::class); $this->subject->_set('view', $this->viewMock); $this->teaRepositoryMock = $this->getMockBuilder(TeaRepository::class)->disableOriginalConstructor()->getMock(); $this->subject->injectTeaRepository($this->teaRepositoryMock); $responseMock = $this->createMock(HtmlResponse::class); $this->subject->method('htmlResponse')->willReturn($responseMock); } /** * @test */ public function isActionController(): void { self::assertInstanceOf(ActionController::class, $this->subject); } /** * @test */ public function indexActionAssignsAllTeaAsTeasToView(): void { $teas = $this->createMock(QueryResultInterface::class); $this->teaRepositoryMock->method('findAll')->willReturn($teas); $this->viewMock->expects(self::once())->method('assign')->with('teas', $teas); self::assertInstanceOf( HtmlResponse::class, $this->subject->indexAction() ); } /** * @test */ public function showActionAssignsPassedTeaAsTeaToView(): void { $tea = new Tea(); $this->viewMock->expects(self::once())->method('assign')->with('tea', $tea); self::assertInstanceOf( HtmlResponse::class, $this->subject->showAction($tea) ); } }