From 3664458d519335ae57907738e6f1746d3c97bd9e Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 27 Oct 2015 22:46:01 +0100 Subject: [PATCH] [CLEANUP] Use @inject and the magic inject method --- Classes/Controller/TestimonialController.php | 27 +------------------ .../Controller/TestimonialControllerTest.php | 4 +-- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Classes/Controller/TestimonialController.php b/Classes/Controller/TestimonialController.php index fc73ddb..331c688 100644 --- a/Classes/Controller/TestimonialController.php +++ b/Classes/Controller/TestimonialController.php @@ -15,8 +15,6 @@ namespace OliverKlee\Tea\Controller; */ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; -use OliverKlee\Tea\Domain\Repository\TestimonialRepository; /** * This controller takes care of displaying testimonials. @@ -25,21 +23,11 @@ use OliverKlee\Tea\Domain\Repository\TestimonialRepository; */ class TestimonialController extends ActionController { /** + * @inject * @var \OliverKlee\Tea\Domain\Repository\TestimonialRepository */ protected $testimonialRepository = null; - /** - * Injects the TestimonialRepository. - * - * @param \OliverKlee\Tea\Domain\Repository\TestimonialRepository $repository - * - * @return void - */ - public function injectTestimonialRepository(TestimonialRepository $repository) { - $this->testimonialRepository = $repository; - } - /** * Lists all testimonials. * @@ -48,17 +36,4 @@ class TestimonialController extends ActionController { public function indexAction() { $this->view->assign('testimonials', $this->testimonialRepository->findAll()); } - - /** - * Injects the view. - * - * Note: This function is intended for unit-testing purposes only. - * - * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view - * - * @return void - */ - public function setView(ViewInterface $view) { - $this->view = $view; - } } \ No newline at end of file diff --git a/Tests/Unit/Controller/TestimonialControllerTest.php b/Tests/Unit/Controller/TestimonialControllerTest.php index a1ab348..ecbf877 100644 --- a/Tests/Unit/Controller/TestimonialControllerTest.php +++ b/Tests/Unit/Controller/TestimonialControllerTest.php @@ -44,10 +44,10 @@ class TestimonialControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { $this->subject = new TestimonialController(); $this->view = $this->getMock(ViewInterface::class); - $this->subject->setView($this->view); + $this->inject($this->subject, 'view', $this->view); $this->testimonialRepository = $this->getMock(TestimonialRepository::class, array(), array(), '', false); - $this->subject->injectTestimonialRepository($this->testimonialRepository); + $this->inject($this->subject, 'testimonialRepository', $this->testimonialRepository); } /**