mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-12-22 23:06:11 +01:00

[CLEANUP] Use @inject and the magic inject method

This commit is contained in:
Oliver Klee 2015-10-27 22:46:01 +01:00
parent a4721b0d1c
commit 3664458d51
2 changed files with 3 additions and 28 deletions

View file

@ -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;
}
}

View file

@ -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);
}
/**