From d9ddc7bae595cbb1f0ca5e85aae5da7451490775 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 1 Nov 2013 22:03:14 +0100 Subject: [PATCH] [FEATURE] Add a Testimonial model and a relation to it. --- Classes/Domain/Model/Addition.php | 1 - Classes/Domain/Model/TeaBeverage.php | 62 ++++++-- Classes/Domain/Model/Testimonial.php | 97 +++++++++++++ .../Repository/TeaBeverageRepository.php | 2 +- .../Repository/TestimonialRepository.php | 35 +++++ Configuration/TCA/TeaBeverage.php | 27 +++- Configuration/TCA/Testimonial.php | 134 ++++++++++++++++++ ExtensionBuilder.json | 2 +- Resources/Private/Language/locallang.xlf | 17 ++- ...ng_csh_tx_tea_domain_model_teabeverage.xlf | 8 +- ...ng_csh_tx_tea_domain_model_testimonial.xlf | 17 +++ Resources/Private/Language/locallang_db.xlf | 17 ++- .../Icons/tx_tea_domain_model_testimonial.gif | Bin 0 -> 533 bytes Tests/Unit/Domain/Model/AdditionTest.php | 1 - Tests/Unit/Domain/Model/TeaBeverageTest.php | 55 ++++++- Tests/Unit/Domain/Model/TeaTypeTest.php | 1 - Tests/Unit/Domain/Model/TestimonialTest.php | 113 +++++++++++++++ .../Repository/TeaBeverageRepositoryTest.php | 1 - .../Repository/TestimonialRepositoryTest.php | 63 ++++++++ ext_tables.php | 33 ++++- ext_tables.sql | 43 ++++++ 21 files changed, 703 insertions(+), 26 deletions(-) create mode 100644 Classes/Domain/Model/Testimonial.php create mode 100644 Classes/Domain/Repository/TestimonialRepository.php create mode 100644 Configuration/TCA/Testimonial.php create mode 100644 Resources/Private/Language/locallang_csh_tx_tea_domain_model_testimonial.xlf create mode 100644 Resources/Public/Icons/tx_tea_domain_model_testimonial.gif create mode 100644 Tests/Unit/Domain/Model/TestimonialTest.php create mode 100644 Tests/Unit/Domain/Repository/TestimonialRepositoryTest.php diff --git a/Classes/Domain/Model/Addition.php b/Classes/Domain/Model/Addition.php index 2a4236a..08b0c32 100644 --- a/Classes/Domain/Model/Addition.php +++ b/Classes/Domain/Model/Addition.php @@ -1,5 +1,4 @@ + * @lazy + */ + protected $testimonials = NULL; + /** * The constructor. * @@ -64,6 +70,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { */ protected function initializeStorageObjects() { $this->additions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->testimonials = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); } /** @@ -98,6 +105,22 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { $this->type = $type; } + /** + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions + */ + public function getAdditions() { + return $this->additions; + } + + /** + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions + * + * @return void + */ + public function setAdditions(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additions) { + $this->additions = $additions; + } + /** * Adds an Addition. * @@ -121,23 +144,42 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { } /** - * Returns the additions. - * - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Testimonial> $testimonials */ - public function getAdditions() { - return $this->additions; + public function getTestimonials() { + return $this->testimonials; } /** - * Sets the additions. - * - * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Testimonial> $testimonials * * @return void */ - public function setAdditions(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additions) { - $this->additions = $additions; + public function setTestimonials(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $testimonials) { + $this->testimonials = $testimonials; } + + /** + * Adds an Testimonial. + * + * @param \OliverKlee\Tea\Domain\Model\Testimonial $testimonial + * + * @return void + */ + public function addTestimonial(\OliverKlee\Tea\Domain\Model\Testimonial $testimonial) { + $this->testimonials->attach($testimonial); + } + + /** + * Removes an Testimonial. + * + * @param \OliverKlee\Tea\Domain\Model\Testimonial $testimonialToRemove The Testimonial to be removed + * + * @return void + */ + public function removeTestimonial(\OliverKlee\Tea\Domain\Model\Testimonial $testimonialToRemove) { + $this->testimonials->detach($testimonialToRemove); + } + } ?> \ No newline at end of file diff --git a/Classes/Domain/Model/Testimonial.php b/Classes/Domain/Model/Testimonial.php new file mode 100644 index 0000000..1ee2c01 --- /dev/null +++ b/Classes/Domain/Model/Testimonial.php @@ -0,0 +1,97 @@ +, 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 3 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! + ***************************************************************/ + +/** + * This model represents a testimonial for a TeaBeverage. + * + * @author Oliver Klee + */ +class Testimonial extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { + /** + * @var \DateTime + */ + protected $dateOfPosting = NULL; + + /** + * @var integer + */ + protected $numberOfConsumedCups = 0; + + /** + * @var string + */ + protected $text = ''; + + /** + * @return \DateTime $dateOfPosting + */ + public function getDateOfPosting() { + return $this->dateOfPosting; + } + + /** + * @param \DateTime $dateOfPosting + * + * @return void + */ + public function setDateOfPosting($dateOfPosting) { + $this->dateOfPosting = $dateOfPosting; + } + + /** + * @return integer $numberOfConsumedCups + */ + public function getNumberOfConsumedCups() { + return $this->numberOfConsumedCups; + } + + /** + * @param integer $numberOfConsumedCups + * + * @return void + */ + public function setNumberOfConsumedCups($numberOfConsumedCups) { + $this->numberOfConsumedCups = $numberOfConsumedCups; + } + + /** + * @return string $text + */ + public function getText() { + return $this->text; + } + + /** + * @param string $text + * + * @return void + */ + public function setText($text) { + $this->text = $text; + } +} +?> \ No newline at end of file diff --git a/Classes/Domain/Repository/TeaBeverageRepository.php b/Classes/Domain/Repository/TeaBeverageRepository.php index 13189b0..c2ea47a 100644 --- a/Classes/Domain/Repository/TeaBeverageRepository.php +++ b/Classes/Domain/Repository/TeaBeverageRepository.php @@ -26,7 +26,7 @@ namespace OliverKlee\Tea\Domain\Repository; ***************************************************************/ /** - * This is the repository for TeaBeverages. + * This is the repository for TeaBeverage models. * * @author Oliver Klee */ diff --git a/Classes/Domain/Repository/TestimonialRepository.php b/Classes/Domain/Repository/TestimonialRepository.php new file mode 100644 index 0000000..79e02c4 --- /dev/null +++ b/Classes/Domain/Repository/TestimonialRepository.php @@ -0,0 +1,35 @@ +, 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 3 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! + ***************************************************************/ + +/** + * This is the repository for Testimonial models. + * + * @author Oliver Klee + */ +class TestimonialRepository extends \TYPO3\CMS\Extbase\Persistence\Repository { +} +?> \ No newline at end of file diff --git a/Configuration/TCA/TeaBeverage.php b/Configuration/TCA/TeaBeverage.php index b6366f6..82e96eb 100644 --- a/Configuration/TCA/TeaBeverage.php +++ b/Configuration/TCA/TeaBeverage.php @@ -6,10 +6,10 @@ if (!defined ('TYPO3_MODE')) { $TCA['tx_tea_domain_model_teabeverage'] = array( 'ctrl' => $TCA['tx_tea_domain_model_teabeverage']['ctrl'], 'interface' => array( - 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, size, type, additions', + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, size, type, additions, testimonials', ), 'types' => array( - '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size, type, additions,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'), + '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size, type, additions, testimonials,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'), ), 'palettes' => array( '1' => array('showitem' => ''), @@ -133,8 +133,8 @@ $TCA['tx_tea_domain_model_teabeverage'] = array( 'icon' => 'edit2.gif', 'popup_onlyOpenIfSelected' => 1, 'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1', - ), - 'add' => Array( + ), + 'add' => array( 'type' => 'script', 'title' => 'Create new', 'icon' => 'add.gif', @@ -142,12 +142,29 @@ $TCA['tx_tea_domain_model_teabeverage'] = array( 'table' => 'tx_tea_domain_model_addition', 'pid' => '###CURRENT_PID###', 'setValue' => 'prepend' - ), + ), 'script' => 'wizard_add.php', ), ), ), ), + 'testimonials' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_teabeverage.testimonials', + 'config' => array( + 'type' => 'inline', + 'foreign_table' => 'tx_tea_domain_model_testimonial', + 'foreign_field' => 'teabeverage', + 'maxitems' => 9999, + 'appearance' => array( + 'collapseAll' => 0, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + ), + ), + ), ), ); ?> \ No newline at end of file diff --git a/Configuration/TCA/Testimonial.php b/Configuration/TCA/Testimonial.php new file mode 100644 index 0000000..4c4a9df --- /dev/null +++ b/Configuration/TCA/Testimonial.php @@ -0,0 +1,134 @@ + $TCA['tx_tea_domain_model_testimonial']['ctrl'], + 'interface' => array( + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, date_of_posting, number_of_consumed_cups, text', + ), + 'types' => array( + '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, date_of_posting, number_of_consumed_cups, text,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'), + ), + 'palettes' => array( + '1' => array('showitem' => ''), + ), + 'columns' => array( + 'sys_language_uid' => array( + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => array( + 'type' => 'select', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => array( + array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1), + array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0), + ), + ), + ), + 'l10n_parent' => array( + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => array( + 'type' => 'select', + 'items' => array( + array('', 0), + ), + 'foreign_table' => 'tx_tea_domain_model_testimonial', + 'foreign_table_where' => 'AND tx_tea_domain_model_testimonial.pid=###CURRENT_PID### AND tx_tea_domain_model_testimonial.sys_language_uid IN (-1,0)', + ), + ), + 'l10n_diffsource' => array( + 'config' => array( + 'type' => 'passthrough', + ), + ), + 't3ver_label' => array( + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => array( + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ) + ), + 'hidden' => array( + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => array( + 'type' => 'check', + ), + ), + 'starttime' => array( + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => array( + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => array( + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')), + ), + ), + ), + 'endtime' => array( + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => array( + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => array( + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')), + ), + ), + ), + 'date_of_posting' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_testimonial.date_of_posting', + 'config' => array( + 'dbType' => 'datetime', + 'type' => 'input', + 'size' => 12, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => '0000-00-00 00:00:00', + ), + ), + 'number_of_consumed_cups' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_testimonial.number_of_consumed_cups', + 'config' => array( + 'type' => 'input', + 'size' => 4, + 'eval' => 'int', + ), + ), + 'text' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_testimonial.text', + 'config' => array( + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim', + ), + ), + 'teabeverage' => array( + 'config' => array( + 'type' => 'passthrough', + ), + ), + ), +); +?> \ No newline at end of file diff --git a/ExtensionBuilder.json b/ExtensionBuilder.json index 6d5cc54..faa7689 100644 --- a/ExtensionBuilder.json +++ b/ExtensionBuilder.json @@ -1 +1 @@ -{"modules":[{"config":{"position":[658,132]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaBeverage","objectsettings":{"aggregateRoot":true,"description":"Tea beverage","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"264022070620"},"propertyGroup":{"properties":[{"propertyDescription":"size","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"size","propertyType":"Float","uid":"686745089204"}]},"relationGroup":{"relations":[{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"type","relationName":"type","relationType":"manyToOne","relationWire":"[wired]","uid":"381688624164"},{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"additions","relationName":"additions","relationType":"manyToMany","relationWire":"[wired]","uid":"1077905653897"}]}}},{"config":{"position":[71,142]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaType","objectsettings":{"aggregateRoot":false,"description":"Tea type","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"1351448414985"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"514346914201"},{"propertyDescription":"caffeinated","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"caffeinated","propertyType":"Boolean","uid":"314036724989"}]},"relationGroup":{"relations":[]}}},{"config":{"position":[35,391]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"Addition","objectsettings":{"aggregateRoot":false,"description":"addition","mapToTable":"","parentClass":"","sorting":false,"type":"ValueObject","uid":"1270408953807"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"846205806952"}]},"relationGroup":{"relations":[]}}}],"properties":{"backendModules":[],"description":"This extension serves as an example on how to unit-test different data types and relation types in TYPO3 extensions.","emConf":{"category":"plugin","custom_category":"","dependsOn":"extbase => 6.0\nfluid => 6.0\ntypo3 => 6.0\n","disableLocalization":false,"disableVersioning":false,"priority":"","shy":false,"state":"alpha","targetVersion":"6.0","version":""},"extensionKey":"tea","name":"Tea example","originalExtensionKey":"tea","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[{"src":{"moduleId":0,"terminal":"relationWire_0","uid":"381688624164"},"tgt":{"moduleId":1,"terminal":"SOURCES","uid":"1351448414985"}},{"src":{"moduleId":0,"terminal":"relationWire_1","uid":"1077905653897"},"tgt":{"moduleId":2,"terminal":"SOURCES","uid":"1270408953807"}}],"log":{"last_modified":"2013-11-01 08:56","extension_builder_version":"2.5.2","be_user":"Oliver Klee (1)"}} \ No newline at end of file +{"modules":[{"config":{"position":[658,132]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaBeverage","objectsettings":{"aggregateRoot":true,"description":"Tea beverage","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"264022070620"},"propertyGroup":{"properties":[{"propertyDescription":"size","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"size","propertyType":"Float","uid":"686745089204"}]},"relationGroup":{"relations":[{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"type","relationName":"type","relationType":"manyToOne","relationWire":"[wired]","uid":"381688624164"},{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"additions","relationName":"additions","relationType":"manyToMany","relationWire":"[wired]","uid":"1077905653897"},{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"testimonials","relationName":"testimonials","relationType":"zeroToMany","relationWire":"[wired]","uid":"612872844633"}]}}},{"config":{"position":[71,142]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaType","objectsettings":{"aggregateRoot":false,"description":"Tea type","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"1351448414985"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"514346914201"},{"propertyDescription":"caffeinated","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"caffeinated","propertyType":"Boolean","uid":"314036724989"}]},"relationGroup":{"relations":[]}}},{"config":{"position":[35,391]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"Addition","objectsettings":{"aggregateRoot":false,"description":"addition","mapToTable":"","parentClass":"","sorting":false,"type":"ValueObject","uid":"1270408953807"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"846205806952"}]},"relationGroup":{"relations":[]}}},{"config":{"position":[642,507]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"Testimonial","objectsettings":{"aggregateRoot":true,"description":"Testimonial","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"539309147575"},"propertyGroup":{"properties":[{"propertyDescription":"date of posting","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"dateOfPosting","propertyType":"NativeDateTime","uid":"927757775346"},{"propertyDescription":"number of consumed cups","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"numberOfConsumedCups","propertyType":"Integer","uid":"193382428427"},{"propertyDescription":"text","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"text","propertyType":"Text","uid":"563552582384"}]},"relationGroup":{"relations":[]}}}],"properties":{"backendModules":[],"description":"This extension serves as an example on how to unit-test different data types and relation types in TYPO3 extensions.","emConf":{"category":"plugin","custom_category":"","dependsOn":"extbase => 6.0\nfluid => 6.0\ntypo3 => 6.0\n","disableLocalization":false,"disableVersioning":false,"priority":"","shy":false,"state":"alpha","targetVersion":"6.0","version":""},"extensionKey":"tea","name":"Tea example","originalExtensionKey":"tea","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[{"src":{"moduleId":0,"terminal":"relationWire_0","uid":"381688624164"},"tgt":{"moduleId":1,"terminal":"SOURCES","uid":"1351448414985"}},{"src":{"moduleId":0,"terminal":"relationWire_1","uid":"1077905653897"},"tgt":{"moduleId":2,"terminal":"SOURCES","uid":"1270408953807"}},{"src":{"moduleId":0,"terminal":"relationWire_2","uid":"612872844633"},"tgt":{"moduleId":3,"terminal":"SOURCES","uid":"539309147575"}}],"log":{"last_modified":"2013-11-01 09:35","extension_builder_version":"2.5.2","be_user":"Oliver Klee (1)"}} \ No newline at end of file diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 613ad91..d110f8d 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -1,6 +1,6 @@ - +
@@ -15,6 +15,9 @@ additions + + testimonials + Tea type @@ -30,6 +33,18 @@ title + + Testimonial + + + date of posting + + + number of consumed cups + + + text + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teabeverage.xlf b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teabeverage.xlf index d127239..21a6460 100644 --- a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teabeverage.xlf +++ b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teabeverage.xlf @@ -1,6 +1,6 @@ - +
@@ -9,6 +9,12 @@ type + + additions + + + testimonials + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_testimonial.xlf b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_testimonial.xlf new file mode 100644 index 0000000..b7a7621 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_testimonial.xlf @@ -0,0 +1,17 @@ + + + +
+ + + date of posting + + + number of consumed cups + + + text + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 8db553c..9fdd331 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -1,6 +1,6 @@ - +
@@ -15,6 +15,9 @@ Additions + + Testimonials + Tea Type @@ -30,6 +33,18 @@ Title + + Testimonial + + + Date Of Posting + + + Number Of Consumed Cups + + + Text + \ No newline at end of file diff --git a/Resources/Public/Icons/tx_tea_domain_model_testimonial.gif b/Resources/Public/Icons/tx_tea_domain_model_testimonial.gif new file mode 100644 index 0000000000000000000000000000000000000000..6cc5f16355d84652db5ce39fcbc7256b7ea457cd GIT binary patch literal 533 zcmZ?wbhEHb6krfwc;>^PT&ti`uNc2IM6Fr5d*_GlT^}Mg`l>Z4?cBL@{mqr@Zmft{ z7wEdsHlXM1p|kH6En2i~+qT*bFHc_i5WY6x!0ESfTY`5SewDjFA!B!R!NKH=-7#5v z<8pIzr=96jYgDqIV-eVU&ToZld3pKFnKKjS+;FNpvSrJblpPUfQw-u~UN@U;5Wc}@ z$BrEa{W=>rZk&4HOZ}!-d-m*!-W0Ir`qGWJ*7TfcZfa@@UE^PKph&A-&32ZV$71`A zWAz0q9tEs&-?wjHUteGDl80Iy>iRueDs>7`>w{xsV{`V!C+`Sfvt~_7N=o9k(EtDc zGYnRs_>+Z^fx(AC2joCdoG`E#HTX0&x3sqT=(8Hwwzskf@u~E-2#Sa)Om246yZMom0cTFy<3E({D?-?uh0SOWmDq@H{L literal 0 HcmV?d00001 diff --git a/Tests/Unit/Domain/Model/AdditionTest.php b/Tests/Unit/Domain/Model/AdditionTest.php index a2da0c2..70a349d 100644 --- a/Tests/Unit/Domain/Model/AdditionTest.php +++ b/Tests/Unit/Domain/Model/AdditionTest.php @@ -1,5 +1,4 @@ fixture->getAdditions()->contains($newItem) ); } + + /** + * @test + */ + public function getTestimonialsInitiallyReturnsEmptyStorage() { + $this->assertEquals( + new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(), + $this->fixture->getTestimonials() + ); + } + + /** + * @test + */ + public function setTestimonialsSetsTestimonials() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setTestimonials($items); + + $this->assertSame( + $items, + $this->fixture->getTestimonials() + ); + } + + /** + * @test + */ + public function addTestimonialAddsTestimonial() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setTestimonials($items); + + $newItem = new \OliverKlee\Tea\Domain\Model\Testimonial(); + $this->fixture->addTestimonial($newItem); + + $this->assertTrue( + $this->fixture->getTestimonials()->contains($newItem) + ); + } + + /** + * @test + */ + public function removeTestimonialRemovesTestimonial() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setTestimonials($items); + + $newItem = new \OliverKlee\Tea\Domain\Model\Testimonial(); + $this->fixture->addTestimonial($newItem); + $this->fixture->removeTestimonial($newItem); + + $this->assertFalse( + $this->fixture->getTestimonials()->contains($newItem) + ); + } } ?> \ No newline at end of file diff --git a/Tests/Unit/Domain/Model/TeaTypeTest.php b/Tests/Unit/Domain/Model/TeaTypeTest.php index 82abaaf..f6ddba8 100644 --- a/Tests/Unit/Domain/Model/TeaTypeTest.php +++ b/Tests/Unit/Domain/Model/TeaTypeTest.php @@ -1,5 +1,4 @@ , 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! + ***************************************************************/ + +/** + * Test case. + * + * @author Oliver Klee + */ +class TestimonialTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { + /** + * @var \OliverKlee\Tea\Domain\Model\Testimonial + */ + protected $fixture = NULL; + + public function setUp() { + $this->fixture = new \OliverKlee\Tea\Domain\Model\Testimonial(); + } + + public function tearDown() { + unset($this->fixture); + } + + /** + * @test + */ + public function getDateOfPostingInitiallyReturnsNull() { + $this->assertNull( + $this->fixture->getDateOfPosting() + ); + } + + /** + * @test + */ + public function setDateOfPostingSetsDateOfPosting() { + $date = new \DateTime(); + $this->fixture->setDateOfPosting($date); + + $this->assertSame( + $date, + $this->fixture->getDateOfPosting() + ); + } + + /** + * @test + */ + public function getNumberOfConsumedCupsInitiallyReturnsZero() { + $this->assertSame( + 0, + $this->fixture->getNumberOfConsumedCups() + ); + } + + /** + * @test + */ + public function setNumberOfConsumedCupsSetsNumberOfConsumedCups() { + $this->fixture->setNumberOfConsumedCups(123456); + + $this->assertSame( + 123456, + $this->fixture->getNumberOfConsumedCups() + ); + } + + /** + * @test + */ + public function getTextInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getText() + ); + } + + /** + * @test + */ + public function setTextSetsText() { + $this->fixture->setText('foo bar'); + + $this->assertSame( + 'foo bar', + $this->fixture->getText() + ); + } +} +?> \ No newline at end of file diff --git a/Tests/Unit/Domain/Repository/TeaBeverageRepositoryTest.php b/Tests/Unit/Domain/Repository/TeaBeverageRepositoryTest.php index 4054d30..c1bc6b3 100644 --- a/Tests/Unit/Domain/Repository/TeaBeverageRepositoryTest.php +++ b/Tests/Unit/Domain/Repository/TeaBeverageRepositoryTest.php @@ -1,5 +1,4 @@ , 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! + ***************************************************************/ + +/** + * Test case. + * + * @author Oliver Klee + */ +class TestimonialRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { + /** + * @var \OliverKlee\Tea\Domain\Model\Testimonial + */ + protected $fixture; + + /** + * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface|PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager = NULL; + + public function setUp() { + $this->objectManager = $this->getMock('TYPO3\CMS\Extbase\Object\ObjectManagerInterface'); + + $this->fixture = new \OliverKlee\Tea\Domain\Repository\TestimonialRepository($this->objectManager); + } + + public function tearDown() { + unset($this->fixture, $this->objectManager); + } + + /** + * @test + */ + public function canBeInstantiated() { + $this->assertNotNull( + $this->fixture + ); + } +} +?> \ No newline at end of file diff --git a/ext_tables.php b/ext_tables.php index 4e86750..b9bcdcf 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -30,7 +30,7 @@ $TCA['tx_tea_domain_model_teabeverage'] = array( 'starttime' => 'starttime', 'endtime' => 'endtime', ), - 'searchFields' => 'size,type,additions,', + 'searchFields' => 'size,type,additions,testimonials,', 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/TeaBeverage.php', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_teabeverage.gif' ), @@ -97,4 +97,35 @@ $TCA['tx_tea_domain_model_addition'] = array( 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_addition.gif' ), ); + +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_tea_domain_model_testimonial', 'EXT:tea/Resources/Private/Language/locallang_csh_tx_tea_domain_model_testimonial.xlf'); +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_tea_domain_model_testimonial'); +$TCA['tx_tea_domain_model_testimonial'] = array( + 'ctrl' => array( + 'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_testimonial', + 'label' => 'date_of_posting', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => TRUE, + + 'versioningWS' => 2, + 'versioning_followPages' => TRUE, + + 'origUid' => 't3_origuid', + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + + 'delete' => 'deleted', + 'enablecolumns' => array( + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ), + 'searchFields' => 'date_of_posting,number_of_consumed_cups,text,', + 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Testimonial.php', + 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_testimonial.gif' + ), +); ?> \ No newline at end of file diff --git a/ext_tables.sql b/ext_tables.sql index 72f95bd..527b60e 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -8,6 +8,7 @@ CREATE TABLE tx_tea_domain_model_teabeverage ( size double(11,2) DEFAULT '0.00' NOT NULL, type int(11) unsigned DEFAULT '0', additions int(11) unsigned DEFAULT '0' NOT NULL, + testimonials int(11) unsigned DEFAULT '0' NOT NULL, tstamp int(11) unsigned DEFAULT '0' NOT NULL, crdate int(11) unsigned DEFAULT '0' NOT NULL, @@ -115,6 +116,48 @@ CREATE TABLE tx_tea_domain_model_addition ( KEY language (l10n_parent,sys_language_uid) ); +# +# Table structure for table 'tx_tea_domain_model_testimonial' +# +CREATE TABLE tx_tea_domain_model_testimonial ( + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + teabeverage int(11) unsigned DEFAULT '0' NOT NULL, + + date_of_posting datetime DEFAULT '0000-00-00 00:00:00', + number_of_consumed_cups int(11) DEFAULT '0' NOT NULL, + text text NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) +); + # # Table structure for table 'tx_tea_teabeverage_addition_mm' #