From 436a10b9d66c373014dffa703d14f5439db24669 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sat, 26 May 2018 20:46:55 +0200 Subject: [PATCH] [FEATURE] Tea plugin with TeaController and index action (#19) --- Classes/Controller/.gitkeep | 0 Classes/Controller/TeaController.php | 37 ++++++++++ Configuration/FlexForms/Plugin.xml | 35 +++++++++ Configuration/TCA/Overrides/.gitkeep | 0 Configuration/TCA/Overrides/tt_content.php | 23 ++++++ Resources/Private/Language/de.locallang.xlf | 24 +++++++ Resources/Private/Language/locallang.xlf | 20 ++++++ Resources/Private/Layouts/.gitkeep | 0 Resources/Private/Layouts/Default.html | 5 ++ Resources/Private/Templates/.gitkeep | 0 Resources/Private/Templates/Tea/Index.html | 25 +++++++ Tests/Unit/Controller/.gitkeep | 0 Tests/Unit/Controller/TeaControllerTest.php | 79 +++++++++++++++++++++ ext_localconf.php | 16 +++++ 14 files changed, 264 insertions(+) delete mode 100644 Classes/Controller/.gitkeep create mode 100644 Classes/Controller/TeaController.php create mode 100644 Configuration/FlexForms/Plugin.xml delete mode 100644 Configuration/TCA/Overrides/.gitkeep create mode 100644 Configuration/TCA/Overrides/tt_content.php create mode 100644 Resources/Private/Language/de.locallang.xlf create mode 100644 Resources/Private/Language/locallang.xlf delete mode 100644 Resources/Private/Layouts/.gitkeep create mode 100644 Resources/Private/Layouts/Default.html delete mode 100644 Resources/Private/Templates/.gitkeep create mode 100644 Resources/Private/Templates/Tea/Index.html delete mode 100644 Tests/Unit/Controller/.gitkeep create mode 100644 Tests/Unit/Controller/TeaControllerTest.php create mode 100644 ext_localconf.php diff --git a/Classes/Controller/.gitkeep b/Classes/Controller/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Classes/Controller/TeaController.php b/Classes/Controller/TeaController.php new file mode 100644 index 0000000..13078f8 --- /dev/null +++ b/Classes/Controller/TeaController.php @@ -0,0 +1,37 @@ +teaRepository = $teaRepository; + } + + /** + * @return void + */ + public function indexAction() + { + $this->view->assign('teas', $this->teaRepository->findAll()); + } +} diff --git a/Configuration/FlexForms/Plugin.xml b/Configuration/FlexForms/Plugin.xml new file mode 100644 index 0000000..53f069d --- /dev/null +++ b/Configuration/FlexForms/Plugin.xml @@ -0,0 +1,35 @@ + + + + + + + + + + array + + + + + reload + + select + selectSingle + + + LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.index + Tea->index + + + + + + + + + + diff --git a/Configuration/TCA/Overrides/.gitkeep b/Configuration/TCA/Overrides/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php new file mode 100644 index 0000000..3906beb --- /dev/null +++ b/Configuration/TCA/Overrides/tt_content.php @@ -0,0 +1,23 @@ + + + +
+ + + Tea + Tee + + + View + Ansicht + + + Tea list + Teeliste + + + Our selection of assorted teas + Unsere Auswahl an erlesenen Tees + + + + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf new file mode 100644 index 0000000..4d8a893 --- /dev/null +++ b/Resources/Private/Language/locallang.xlf @@ -0,0 +1,20 @@ + + + +
+ + + Tea + + + View + + + Tea list + + + Our selection of assorted teas + + + + diff --git a/Resources/Private/Layouts/.gitkeep b/Resources/Private/Layouts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html new file mode 100644 index 0000000..d2f12bd --- /dev/null +++ b/Resources/Private/Layouts/Default.html @@ -0,0 +1,5 @@ + +
+ +
+ diff --git a/Resources/Private/Templates/.gitkeep b/Resources/Private/Templates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Resources/Private/Templates/Tea/Index.html b/Resources/Private/Templates/Tea/Index.html new file mode 100644 index 0000000..327b61b --- /dev/null +++ b/Resources/Private/Templates/Tea/Index.html @@ -0,0 +1,25 @@ + + + + + +

+ +

+ + + + + + + + + + +
+ {tea.uid} + + {tea.title} +
+
+ diff --git a/Tests/Unit/Controller/.gitkeep b/Tests/Unit/Controller/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Tests/Unit/Controller/TeaControllerTest.php b/Tests/Unit/Controller/TeaControllerTest.php new file mode 100644 index 0000000..6601a1c --- /dev/null +++ b/Tests/Unit/Controller/TeaControllerTest.php @@ -0,0 +1,79 @@ +subject = new TeaController(); + + $this->viewProphecy = $this->prophesize(TemplateView::class); + $this->view = $this->viewProphecy->reveal(); + $this->inject($this->subject, 'view', $this->view); + + $this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class); + $this->teaRepository = $this->teaRepositoryProphecy->reveal(); + $this->subject->injectTeaRepository($this->teaRepository); + } + + /** + * @test + */ + public function isActionController() + { + static::assertInstanceOf(ActionController::class, $this->subject); + } + + /** + * @test + */ + public function indexActionAssignsAllTeaAsTeasToView() + { + $teas = $this->prophesize(QueryResultInterface::class)->reveal(); + $this->teaRepositoryProphecy->findAll()->willReturn($teas); + $this->viewProphecy->assign('teas', $teas)->shouldBeCalled(); + + $this->subject->indexAction(); + } +} diff --git a/ext_localconf.php b/ext_localconf.php new file mode 100644 index 0000000..777cb67 --- /dev/null +++ b/ext_localconf.php @@ -0,0 +1,16 @@ + 'index', + ], + // non-cacheable actions + [ + 'Tea' => '', + ] +);