mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-25 04:56:13 +01:00

[FEATURE] Add the TeaBeverage model and repository.

This commit is contained in:
Oliver Klee 2013-11-01 20:11:03 +01:00
parent c408357dc6
commit c51c06715d
12 changed files with 435 additions and 5 deletions

View file

@ -0,0 +1,60 @@
<?php
namespace OliverKlee\Tea\Domain\Model;
/***************************************************************
* 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 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 good cup of tea.
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* size
*
* @var \float
*/
protected $size = 0.0;
/**
* Returns the size
*
* @return \float $size
*/
public function getSize() {
return $this->size;
}
/**
* Sets the size
*
* @param \float $size
* @return void
*/
public function setSize($size) {
$this->size = $size;
}
}
?>

View file

@ -0,0 +1,35 @@
<?php
namespace OliverKlee\Tea\Domain\Repository;
/***************************************************************
* 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 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 TeaBeverages.
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class TeaBeverageRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
}
?>

View file

@ -0,0 +1,110 @@
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
$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',
),
'types' => array(
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size,--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_teabeverage',
'foreign_table_where' => 'AND tx_tea_domain_model_teabeverage.pid=###CURRENT_PID### AND tx_tea_domain_model_teabeverage.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')),
),
),
),
'size' => array(
'exclude' => 0,
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_teabeverage.size',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'double2',
),
),
),
);
?>

View file

@ -1 +1 @@
{"modules":[],"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":"","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[],"log":{"last_modified":"2013-11-01 07:50","extension_builder_version":"2.5.2","be_user":"Oliver Klee (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":[]}}}],"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":"","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[],"log":{"last_modified":"2013-11-01 07:54","extension_builder_version":"2.5.2","be_user":"Oliver Klee (1)"}}

View file

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0"> <xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T19:50:01Z" product-name="tea"> <file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T19:54:17Z" product-name="tea">
<header/> <header/>
<body> <body>
<trans-unit id="tx_tea_domain_model_teabeverage">
<source>Tea beverage</source>
</trans-unit>
<trans-unit id="tx_tea_domain_model_teabeverage.size">
<source>size</source>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T19:54:17Z" product-name="tea">
<header/>
<body>
<trans-unit id="size.description">
<source>size</source>
</trans-unit>
</body>
</file>
</xliff>

View file

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0"> <xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T19:50:01Z" product-name="tea"> <file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T19:54:17Z" product-name="tea">
<header/> <header/>
<body> <body>
<trans-unit id="tx_tea_domain_model_teabeverage">
<source>Tea Beverage</source>
</trans-unit>
<trans-unit id="tx_tea_domain_model_teabeverage.size">
<source>Size</source>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

View file

@ -0,0 +1,70 @@
<?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!
***************************************************************/
/**
* Test case.
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class TeaBeverageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
/**
* @var \OliverKlee\Tea\Domain\Model\TeaBeverage
*/
protected $fixture;
public function setUp() {
$this->fixture = new \OliverKlee\Tea\Domain\Model\TeaBeverage();
}
public function tearDown() {
unset($this->fixture);
}
/**
* @test
*/
public function getSizeInitiallyReturnsZero() {
$this->assertSame(
0.0,
$this->fixture->getSize()
);
}
/**
* @test
*/
public function setSizeSetsSize() {
$this->fixture->setSize(1234.56);
$this->assertSame(
1234.56,
$this->fixture->getSize()
);
}
}
?>

View file

@ -0,0 +1,64 @@
<?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!
***************************************************************/
/**
* Test case.
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class TeaBeverageRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
/**
* @var \OliverKlee\Tea\Domain\Model\TeaBeverage
*/
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\TeaBeverageRepository($this->objectManager);
}
public function tearDown() {
unset($this->fixture, $this->objectManager);
}
/**
* @test
*/
public function canBeInstantiated() {
$this->assertNotNull(
$this->fixture
);
}
}
?>

View file

@ -5,4 +5,35 @@ if (!defined('TYPO3_MODE')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Tea example'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Tea example');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_tea_domain_model_teabeverage', 'EXT:tea/Resources/Private/Language/locallang_csh_tx_tea_domain_model_teabeverage.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_tea_domain_model_teabeverage');
$TCA['tx_tea_domain_model_teabeverage'] = array(
'ctrl' => array(
'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_teabeverage',
'label' => 'size',
'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' => 'size,',
'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'
),
);
?> ?>

View file

@ -0,0 +1,39 @@
#
# Table structure for table 'tx_tea_domain_model_teabeverage'
#
CREATE TABLE tx_tea_domain_model_teabeverage (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
size double(11,2) DEFAULT '0.00' 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)
);