mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-12-22 13:06:11 +01:00
[FEATURE] Add missing files for indexAction.
This commit is contained in:
parent
3bdff176e7
commit
ee93fac2b7
7 changed files with 236 additions and 0 deletions
77
Classes/Controller/TestimonialController.php
Normal file
77
Classes/Controller/TestimonialController.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
namespace OliverKlee\Tea\Controller;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Oliver Klee <typo3-coding@oliverklee.de>, oliverklee.de
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
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.
|
||||
*
|
||||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||||
*/
|
||||
class TestimonialController extends ActionController {
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 view
|
||||
*/
|
||||
public function setView(ViewInterface $view) {
|
||||
$this->view = $view;
|
||||
}
|
||||
}
|
||||
?>
|
18
Configuration/TypoScript/constants.txt
Normal file
18
Configuration/TypoScript/constants.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
plugin.tx_tea {
|
||||
view {
|
||||
# cat=plugin.tx_tea/file; type=string; label=Path to template root (FE)
|
||||
templateRootPath = EXT:tea/Resources/Private/Templates/
|
||||
# cat=plugin.tx_tea/file; type=string; label=Path to template partials (FE)
|
||||
partialRootPath = EXT:tea/Resources/Private/Partials/
|
||||
# cat=plugin.tx_tea/file; type=string; label=Path to template layouts (FE)
|
||||
layoutRootPath = EXT:tea/Resources/Private/Layouts/
|
||||
}
|
||||
persistence {
|
||||
# cat=plugin.tx_tea//a; type=string; label=Default storage PID
|
||||
storagePid =
|
||||
# cat=plugin.tx_tea//a; type=int; label=UID of the page/folder where all new records will be created
|
||||
newRecordStoragePid =
|
||||
}
|
||||
settings {
|
||||
}
|
||||
}
|
13
Configuration/TypoScript/setup.txt
Normal file
13
Configuration/TypoScript/setup.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
plugin.tx_tea {
|
||||
view {
|
||||
templateRootPath = {$plugin.tx_tea.view.templateRootPath}
|
||||
partialRootPath = {$plugin.tx_tea.view.partialRootPath}
|
||||
layoutRootPath = {$plugin.tx_tea.view.layoutRootPath}
|
||||
}
|
||||
persistence {
|
||||
storagePid = {$plugin.tx_tea.persistence.storagePid}
|
||||
}
|
||||
features {
|
||||
rewrittenPropertyMapper = 1
|
||||
}
|
||||
}
|
3
Resources/Private/Layouts/Default.html
Normal file
3
Resources/Private/Layouts/Default.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="tx-tea">
|
||||
<f:render section="main" />
|
||||
</div>
|
16
Resources/Private/Templates/Testimonial/Index.html
Normal file
16
Resources/Private/Templates/Testimonial/Index.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="main">
|
||||
<h2><f:translate key="heading.testimonials"/></h2>
|
||||
<f:for each="{testimonials}" as="testimonial">
|
||||
<h3>
|
||||
<f:format.printf arguments="{cups: testimonial.numberOfConsumedCups}">
|
||||
<f:translate key="testimonials.cups.and.date"/>
|
||||
</f:format.printf>
|
||||
<f:format.date format="{f:translate(key: 'date-and-time-format')}">{testimonial.dateOfPosting}</f:format.date>
|
||||
</h3>
|
||||
<f:format.html>
|
||||
{testimonial.text}
|
||||
</f:format.html>
|
||||
</f:for>
|
||||
</f:section>
|
91
Tests/Unit/Controller/TestimonialControllerTest.php
Normal file
91
Tests/Unit/Controller/TestimonialControllerTest.php
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
namespace OliverKlee\Tea\Tests;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Oliver Klee <typo3-coding@oliverklee.de>, oliverklee.de
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
|
||||
use OliverKlee\Tea\Controller\TestimonialController;
|
||||
use OliverKlee\Tea\Domain\Repository\TestimonialRepository;
|
||||
|
||||
/**
|
||||
* Test case.
|
||||
*
|
||||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||||
*/
|
||||
class TestimonialControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
|
||||
/**
|
||||
* @var TestimonialController
|
||||
*/
|
||||
protected $fixture;
|
||||
|
||||
/**
|
||||
* @var ViewInterface
|
||||
*/
|
||||
protected $view = NULL;
|
||||
|
||||
/**
|
||||
* @var TestimonialRepository
|
||||
*/
|
||||
protected $testimonialRepository = NULL;
|
||||
|
||||
public function setUp() {
|
||||
$this->fixture = new TestimonialController();
|
||||
|
||||
$this->view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface');
|
||||
$this->fixture->setView($this->view);
|
||||
|
||||
$this->testimonialRepository = $this->getMock(
|
||||
'OliverKlee\\Tea\\Domain\\Repository\\TestimonialRepository', array(), array(), '', FALSE
|
||||
);
|
||||
$this->fixture->injectTestimonialRepository($this->testimonialRepository);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
unset($this->fixture, $this->view, $this->testimonialRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexActionCanBeCalled() {
|
||||
$this->fixture->indexAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexActionPassesAllTestimonialsAsTestimonialsToView() {
|
||||
$allTestimonials = new ObjectStorage();
|
||||
$this->testimonialRepository->expects($this->any())->method('findAll')
|
||||
->will($this->returnValue($allTestimonials));
|
||||
|
||||
$this->view->expects($this->once())->method('assign')->with('testimonials', $allTestimonials);
|
||||
|
||||
$this->fixture->indexAction();
|
||||
}
|
||||
}
|
||||
?>
|
18
ext_localconf.php
Normal file
18
ext_localconf.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
if (!defined('TYPO3_MODE')) {
|
||||
die('Access denied.');
|
||||
}
|
||||
|
||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||
'OliverKlee.' . $_EXTKEY,
|
||||
'Tea',
|
||||
// all actions
|
||||
array(
|
||||
'Testimonial' => 'index',
|
||||
),
|
||||
// non-cacheable actions
|
||||
array(
|
||||
'Testimonial' => 'index',
|
||||
)
|
||||
);
|
||||
?>
|
Loading…
Reference in a new issue