mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-22 19:36:12 +01:00
[TASK] Switch the TeaController
to construtor injection (#881)
Fixes #869
This commit is contained in:
parent
97a19b7816
commit
b4c93d8dea
2 changed files with 3 additions and 5 deletions
|
@ -16,7 +16,7 @@ class TeaController extends ActionController
|
||||||
{
|
{
|
||||||
private TeaRepository $teaRepository;
|
private TeaRepository $teaRepository;
|
||||||
|
|
||||||
public function injectTeaRepository(TeaRepository $teaRepository): void
|
public function __construct(TeaRepository $teaRepository)
|
||||||
{
|
{
|
||||||
$this->teaRepository = $teaRepository;
|
$this->teaRepository = $teaRepository;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,19 +40,17 @@ final class TeaControllerTest extends UnitTestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->teaRepositoryMock = $this->getMockBuilder(TeaRepository::class)->disableOriginalConstructor()->getMock();
|
||||||
// We need to create an accessible mock in order to be able to set the protected `view`.
|
// We need to create an accessible mock in order to be able to set the protected `view`.
|
||||||
$methodsToMock = ['htmlResponse', 'redirect', 'redirectToUri'];
|
$methodsToMock = ['htmlResponse', 'redirect', 'redirectToUri'];
|
||||||
if ((new Typo3Version())->getMajorVersion() <= 11) {
|
if ((new Typo3Version())->getMajorVersion() <= 11) {
|
||||||
$methodsToMock[] = 'forward';
|
$methodsToMock[] = 'forward';
|
||||||
}
|
}
|
||||||
$this->subject = $this->getAccessibleMock(TeaController::class, $methodsToMock);
|
$this->subject = $this->getAccessibleMock(TeaController::class, $methodsToMock, [$this->teaRepositoryMock]);
|
||||||
|
|
||||||
$this->viewMock = $this->createMock(TemplateView::class);
|
$this->viewMock = $this->createMock(TemplateView::class);
|
||||||
$this->subject->_set('view', $this->viewMock);
|
$this->subject->_set('view', $this->viewMock);
|
||||||
|
|
||||||
$this->teaRepositoryMock = $this->getMockBuilder(TeaRepository::class)->disableOriginalConstructor()->getMock();
|
|
||||||
$this->subject->injectTeaRepository($this->teaRepositoryMock);
|
|
||||||
|
|
||||||
$responseMock = $this->createMock(HtmlResponse::class);
|
$responseMock = $this->createMock(HtmlResponse::class);
|
||||||
$this->subject->method('htmlResponse')->willReturn($responseMock);
|
$this->subject->method('htmlResponse')->willReturn($responseMock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue