From e8d19e41c89ca4409b931ebf66dd794a89af20d8 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 1 Nov 2013 21:21:03 +0100 Subject: [PATCH] [FEATURE] Add an Addition model an a relation to it. --- Classes/Domain/Model/Addition.php | 57 ++++++++++ Classes/Domain/Model/TeaBeverage.php | 72 +++++++++++- Configuration/TCA/Addition.php | 107 ++++++++++++++++++ Configuration/TCA/TeaBeverage.php | 40 ++++++- ExtensionBuilder.json | 2 +- Resources/Private/Language/locallang.xlf | 11 +- ...llang_csh_tx_tea_domain_model_addition.xlf | 11 ++ ...allang_csh_tx_tea_domain_model_teatype.xlf | 2 +- Resources/Private/Language/locallang_db.xlf | 11 +- .../Icons/tx_tea_domain_model_addition.gif | Bin 0 -> 243 bytes Tests/Unit/Domain/Model/AdditionTest.php | 70 ++++++++++++ Tests/Unit/Domain/Model/TeaBeverageTest.php | 56 ++++++++- Tests/Unit/Domain/Model/TeaTypeTest.php | 2 +- ext_tables.php | 32 +++++- ext_tables.sql | 52 +++++++++ 15 files changed, 513 insertions(+), 12 deletions(-) create mode 100644 Classes/Domain/Model/Addition.php create mode 100644 Configuration/TCA/Addition.php create mode 100644 Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf create mode 100644 Resources/Public/Icons/tx_tea_domain_model_addition.gif create mode 100644 Tests/Unit/Domain/Model/AdditionTest.php diff --git a/Classes/Domain/Model/Addition.php b/Classes/Domain/Model/Addition.php new file mode 100644 index 0000000..2a4236a --- /dev/null +++ b/Classes/Domain/Model/Addition.php @@ -0,0 +1,57 @@ +, 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 an addition for tea like sugar or milk. + * + * @author Oliver Klee + */ +class Addition extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject { + /** + * @var \string + * @validate NotEmpty + */ + protected $title = ''; + + /** + * @return \string $title + */ + public function getTitle() { + return $this->title; + } + + /** + * @param \string $title + * + * @return void + */ + public function setTitle($title) { + $this->title = $title; + } +} +?> \ No newline at end of file diff --git a/Classes/Domain/Model/TeaBeverage.php b/Classes/Domain/Model/TeaBeverage.php index e64bb05..5ee35c5 100644 --- a/Classes/Domain/Model/TeaBeverage.php +++ b/Classes/Domain/Model/TeaBeverage.php @@ -32,7 +32,7 @@ namespace OliverKlee\Tea\Domain\Model; */ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** - * @var \float + * @var float */ protected $size = 0.0; @@ -43,14 +43,38 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { protected $type = NULL; /** - * @return \float $size + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> + * @lazy + */ + protected $additions = NULL; + + /** + * The constructor. + * + * @return TeaBeverage + */ + public function __construct() { + $this->initializeStorageObjects(); + } + + /** + * Initializes all ObjectStorage properties. + * + * @return void + */ + protected function initializeStorageObjects() { + $this->additions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * @return float $size */ public function getSize() { return $this->size; } /** - * @param \float $size + * @param float $size * * @return void */ @@ -73,5 +97,47 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { public function setType(\OliverKlee\Tea\Domain\Model\TeaType $type) { $this->type = $type; } + + /** + * Adds an Addition. + * + * @param \OliverKlee\Tea\Domain\Model\Addition $addition + * + * @return void + */ + public function addAddition(\OliverKlee\Tea\Domain\Model\Addition $addition) { + $this->additions->attach($addition); + } + + /** + * Removes an Addition. + * + * @param \OliverKlee\Tea\Domain\Model\Addition $additionToRemove The Addition to be removed + * + * @return void + */ + public function removeAddition(\OliverKlee\Tea\Domain\Model\Addition $additionToRemove) { + $this->additions->detach($additionToRemove); + } + + /** + * Returns the additions. + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions + */ + public function getAdditions() { + return $this->additions; + } + + /** + * Sets the 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; + } } ?> \ No newline at end of file diff --git a/Configuration/TCA/Addition.php b/Configuration/TCA/Addition.php new file mode 100644 index 0000000..79580fc --- /dev/null +++ b/Configuration/TCA/Addition.php @@ -0,0 +1,107 @@ + $TCA['tx_tea_domain_model_addition']['ctrl'], + 'interface' => array( + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title', + ), + 'types' => array( + '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, title,--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_addition', + 'foreign_table_where' => 'AND tx_tea_domain_model_addition.pid=###CURRENT_PID### AND tx_tea_domain_model_addition.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')), + ), + ), + ), + 'title' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_addition.title', + 'config' => array( + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required', + ), + ), + ), +); +?> \ No newline at end of file diff --git a/Configuration/TCA/TeaBeverage.php b/Configuration/TCA/TeaBeverage.php index 4c10d5e..b6366f6 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', + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, size, type, additions', ), 'types' => array( - '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size, type,--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,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'), ), 'palettes' => array( '1' => array('showitem' => ''), @@ -112,6 +112,42 @@ $TCA['tx_tea_domain_model_teabeverage'] = array( 'maxitems' => 1, ), ), + 'additions' => array( + 'exclude' => 0, + 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_teabeverage.additions', + 'config' => array( + 'type' => 'select', + 'foreign_table' => 'tx_tea_domain_model_addition', + 'MM' => 'tx_tea_teabeverage_addition_mm', + 'size' => 10, + 'autoSizeMax' => 30, + 'maxitems' => 9999, + 'multiple' => 0, + 'wizards' => array( + '_PADDING' => 1, + '_VERTICAL' => 1, + 'edit' => array( + 'type' => 'popup', + 'title' => 'Edit', + 'script' => 'wizard_edit.php', + 'icon' => 'edit2.gif', + 'popup_onlyOpenIfSelected' => 1, + 'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1', + ), + 'add' => Array( + 'type' => 'script', + 'title' => 'Create new', + 'icon' => 'add.gif', + 'params' => array( + 'table' => 'tx_tea_domain_model_addition', + 'pid' => '###CURRENT_PID###', + 'setValue' => 'prepend' + ), + 'script' => 'wizard_add.php', + ), + ), + ), + ), ), ); ?> \ No newline at end of file diff --git a/ExtensionBuilder.json b/ExtensionBuilder.json index e6ab284..6d5cc54 100644 --- a/ExtensionBuilder.json +++ b/ExtensionBuilder.json @@ -1 +1 @@ -{"modules":[{"config":{"position":[40,138]},"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"}]}}},{"config":{"position":[756,159]},"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":[]}}}],"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"}}],"log":{"last_modified":"2013-11-01 08:34","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"}]}}},{"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 diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 8cb0b3b..613ad91 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -1,6 +1,6 @@ - +
@@ -12,6 +12,9 @@ type + + additions + Tea type @@ -21,6 +24,12 @@ caffeinated + + addition + + + title + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf new file mode 100644 index 0000000..b0dd4f2 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf @@ -0,0 +1,11 @@ + + + +
+ + + title + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teatype.xlf b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teatype.xlf index 0244f6c..0ddeecf 100644 --- a/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teatype.xlf +++ b/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teatype.xlf @@ -1,6 +1,6 @@ - +
diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index e1cbf80..8db553c 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -1,6 +1,6 @@ - +
@@ -12,6 +12,9 @@ Type + + Additions + Tea Type @@ -21,6 +24,12 @@ Caffeinated + + Addition + + + Title + \ No newline at end of file diff --git a/Resources/Public/Icons/tx_tea_domain_model_addition.gif b/Resources/Public/Icons/tx_tea_domain_model_addition.gif new file mode 100644 index 0000000000000000000000000000000000000000..cbe435a49bb4b6c1e73e0e9d92b5e517d70aaae6 GIT binary patch literal 243 zcmZ?wbh9u|6krfwIKsfd0tTXBpaKS#mX^N0zOk{fnOT`YR8djU+}u1143>kzb}%>& z2G_vgH5hyc0|o|$REBbfe1;;1YzBP>#h)yU3=Gl?IzVxtjRFh|tOXCYg{G9wy{@wE z(UiRfW~MpPhxN|xy8hSXKrCBhgDr>tRjo;t90?sqwGSo5F`Vf+Fm<6`e7nnc%eDKY zPPlB`Q?*B{f%D+sstqqBnVBxEz8}cLz^)-)ma8Gmz}wQM)ZH?{s*jgnP*7NSn*Aix JxjKpr)&SKjVATKs literal 0 HcmV?d00001 diff --git a/Tests/Unit/Domain/Model/AdditionTest.php b/Tests/Unit/Domain/Model/AdditionTest.php new file mode 100644 index 0000000..a2da0c2 --- /dev/null +++ b/Tests/Unit/Domain/Model/AdditionTest.php @@ -0,0 +1,70 @@ +, 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 AdditionTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { + /** + * @var \OliverKlee\Tea\Domain\Model\Addition + */ + protected $fixture = NULL; + + public function setUp() { + $this->fixture = new \OliverKlee\Tea\Domain\Model\Addition(); + } + + public function tearDown() { + unset($this->fixture); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->getTitle() + ); + } + + /** + * @test + */ + public function setTitleSetsTitle() { + $this->fixture->setTitle('foo bar'); + + $this->assertSame( + 'foo bar', + $this->fixture->getTitle() + ); + } +} +?> \ No newline at end of file diff --git a/Tests/Unit/Domain/Model/TeaBeverageTest.php b/Tests/Unit/Domain/Model/TeaBeverageTest.php index 5b44662..2b0e65f 100644 --- a/Tests/Unit/Domain/Model/TeaBeverageTest.php +++ b/Tests/Unit/Domain/Model/TeaBeverageTest.php @@ -35,7 +35,7 @@ class TeaBeverageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { /** * @var \OliverKlee\Tea\Domain\Model\TeaBeverage */ - protected $fixture; + protected $fixture = NULL; public function setUp() { $this->fixture = new \OliverKlee\Tea\Domain\Model\TeaBeverage(); @@ -88,5 +88,59 @@ class TeaBeverageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { $this->fixture->getType() ); } + + /** + * @test + */ + public function getAdditionsInitiallyReturnsEmptyStorage() { + $this->assertEquals( + new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(), + $this->fixture->getAdditions() + ); + } + + /** + * @test + */ + public function setAdditionsSetsAdditions() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setAdditions($items); + + $this->assertSame( + $items, + $this->fixture->getAdditions() + ); + } + + /** + * @test + */ + public function addAdditionAddsAddition() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setAdditions($items); + + $newItem = new \OliverKlee\Tea\Domain\Model\Addition(); + $this->fixture->addAddition($newItem); + + $this->assertTrue( + $this->fixture->getAdditions()->contains($newItem) + ); + } + + /** + * @test + */ + public function removeAdditionRemovesAddition() { + $items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->fixture->setAdditions($items); + + $newItem = new \OliverKlee\Tea\Domain\Model\Addition(); + $this->fixture->addAddition($newItem); + $this->fixture->removeAddition($newItem); + + $this->assertFalse( + $this->fixture->getAdditions()->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 bd1fa5d..82abaaf 100644 --- a/Tests/Unit/Domain/Model/TeaTypeTest.php +++ b/Tests/Unit/Domain/Model/TeaTypeTest.php @@ -35,7 +35,7 @@ class TeaTypeTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { /** * @var \OliverKlee\Tea\Domain\Model\TeaType */ - protected $fixture; + protected $fixture = NULL; public function setUp() { $this->fixture = new \OliverKlee\Tea\Domain\Model\TeaType(); diff --git a/ext_tables.php b/ext_tables.php index 2437bc3..4e86750 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,', + 'searchFields' => 'size,type,additions,', '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' ), @@ -67,4 +67,34 @@ $TCA['tx_tea_domain_model_teatype'] = array( ), ); +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_tea_domain_model_addition', 'EXT:tea/Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf'); +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_tea_domain_model_addition'); +$TCA['tx_tea_domain_model_addition'] = array( + 'ctrl' => array( + 'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_addition', + 'label' => 'title', + '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' => 'title,', + 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Addition.php', + 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_addition.gif' + ), +); ?> \ No newline at end of file diff --git a/ext_tables.sql b/ext_tables.sql index b556047..72f95bd 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -7,6 +7,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, tstamp int(11) unsigned DEFAULT '0' NOT NULL, crdate int(11) unsigned DEFAULT '0' NOT NULL, @@ -74,4 +75,55 @@ CREATE TABLE tx_tea_domain_model_teatype ( KEY parent (pid), KEY t3ver_oid (t3ver_oid,t3ver_wsid), KEY language (l10n_parent,sys_language_uid) +); + +# +# Table structure for table 'tx_tea_domain_model_addition' +# +CREATE TABLE tx_tea_domain_model_addition ( + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + title varchar(255) DEFAULT '' 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' +# +CREATE TABLE tx_tea_teabeverage_addition_mm ( + uid_local int(11) unsigned DEFAULT '0' NOT NULL, + uid_foreign int(11) unsigned DEFAULT '0' NOT NULL, + sorting int(11) unsigned DEFAULT '0' NOT NULL, + sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL, + + KEY uid_local (uid_local), + KEY uid_foreign (uid_foreign) ); \ No newline at end of file