diff --git a/.travis.yml b/.travis.yml
index 1301117..d7f5f62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,8 +7,12 @@ php:
- 7.1
env:
-- TYPO3_VERSION="^7.6"
-- TYPO3_VERSION="^8.7"
+ global:
+ - typo3DatabaseHost=localhost typo3DatabaseName=typo3 typo3DatabaseUsername=travis typo3DatabasePassword=''
+ - TYPO3_PATH_ROOT=$PWD/.Build/public
+ matrix:
+ - TYPO3_VERSION="^7.6"
+ - TYPO3_VERSION="^8.7"
matrix:
exclude:
@@ -24,7 +28,6 @@ before_install:
install:
- composer require-typo3-version "$TYPO3_VERSION"
- git checkout .
-- export TYPO3_PATH_ROOT=$PWD/.Build/public
script:
- >
@@ -36,3 +39,13 @@ script:
echo;
echo "Linting all TypoScript files";
composer ci:ts:lint;
+
+- >
+ echo;
+ echo "Running the unit tests";
+ composer ci:tests:unit;
+
+- >
+ echo;
+ echo "Running the functional tests";
+ composer ci:tests:functional;
diff --git a/Classes/Domain/Model/Product/Tea.php b/Classes/Domain/Model/Product/Tea.php
new file mode 100644
index 0000000..754abf7
--- /dev/null
+++ b/Classes/Domain/Model/Product/Tea.php
@@ -0,0 +1,59 @@
+title;
+ }
+
+ /**
+ * @param string $title
+ *
+ * @return void
+ */
+ public function setTitle(string $title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription(): string
+ {
+ return $this->description;
+ }
+
+ /**
+ * @param string $description
+ *
+ * @return void
+ */
+ public function setDescription(string $description)
+ {
+ $this->description = $description;
+ }
+}
diff --git a/Classes/Domain/Repository/.gitkeep b/Classes/Domain/Repository/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Classes/Domain/Repository/Product/TeaRepository.php b/Classes/Domain/Repository/Product/TeaRepository.php
new file mode 100644
index 0000000..d090de1
--- /dev/null
+++ b/Classes/Domain/Repository/Product/TeaRepository.php
@@ -0,0 +1,16 @@
+objectManager->get(QuerySettingsInterface::class);
+ $querySettings->setRespectStoragePage(false);
+ $this->setDefaultQuerySettings($querySettings);
+ }
+}
diff --git a/Configuration/TCA/tx_tea_domain_model_product_tea.php b/Configuration/TCA/tx_tea_domain_model_product_tea.php
new file mode 100644
index 0000000..4abf6e5
--- /dev/null
+++ b/Configuration/TCA/tx_tea_domain_model_product_tea.php
@@ -0,0 +1,42 @@
+ [
+ 'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea',
+ 'label' => 'title',
+ 'tstamp' => 'tstamp',
+ 'crdate' => 'crdate',
+ 'cruser_id' => 'cruser_id',
+ 'delete' => 'deleted',
+ 'default_sortby' => 'title',
+ 'dividers2tabs' => true,
+ 'iconfile' => 'EXT:tea/Resources/Public/Icons/Record.svg',
+ 'searchFields' => 'title, description',
+ ],
+ 'interface' => [
+ 'showRecordFieldList' => 'title, description',
+ ],
+ 'types' => [
+ '1' => ['showitem' => 'title, description'],
+ ],
+ 'columns' => [
+ 'title' => [
+ 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.title',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 40,
+ 'max' => 255,
+ 'eval' => 'trim,required',
+ ],
+ ],
+ 'description' => [
+ 'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_product_tea.description',
+ 'config' => [
+ 'type' => 'text',
+ 'rows' => 8,
+ 'cols' => 40,
+ 'max' => 2000,
+ 'eval' => 'trim',
+ ],
+ ],
+ ],
+];
diff --git a/README.md b/README.md
index 0db0010..12c753a 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,46 @@ For information on the different ways to execute the tests, please have a look
at the [handout to my workshops on test-driven development (TDD)](https://github.com/oliverklee/tdd-reader).
+## Running the tests in PhpStorm
+
+### General PHPUnit setup
+
+```bash
+composer install
+```
+
+File > Settings > Languages & Frameworks > PHP > Test Frameworks
+
+- (*) Use Composer autoloader
+- Path to script: select `vendor/autoload.php` in your project folder
+
+In the Run configurations, edit the PHPUnit configuration and use these
+settings so this configuration can serve as a template:
+
+- Directory: use the `Tests/Unit` directory in your project
+- [x] Use alternative configuration file
+- use `.Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml`
+ in your project folder
+- Add the following environment variables:
+ - typo3DatabaseUsername
+ - typo3DatabasePassword
+ - typo3DatabaseHost
+ - typo3DatabaseName
+
+### Unit tests configuration
+
+In the Run configurations, copy the PHPUnit configuration and use these settings:
+
+- Directory: use the `Tests/Unit` directory in your project
+
+### Functional tests configuration
+
+In the Run configurations, copy the PHPUnit configuration and use these settings:
+
+- Directory: use the `Tests/Functionsal` directory in your project
+- [x] Use alternative configuration file
+- use `.Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml`
+
## Creating new extensions with automated tests
For creating new extensions, I recommend taking
diff --git a/Resources/Private/Language/.gitkeep b/Resources/Private/Language/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf
new file mode 100644
index 0000000..77c6869
--- /dev/null
+++ b/Resources/Private/Language/de.locallang_db.xlf
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+ Tee
+
+
+
+ Titel
+
+
+
+ Beschreibung
+
+
+
+
diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf
new file mode 100644
index 0000000..545b5d5
--- /dev/null
+++ b/Resources/Private/Language/locallang_db.xlf
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/Public/Icons/.gitkeep b/Resources/Public/Icons/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Resources/Public/Icons/Record.svg b/Resources/Public/Icons/Record.svg
new file mode 100644
index 0000000..a234846
--- /dev/null
+++ b/Resources/Public/Icons/Record.svg
@@ -0,0 +1,119 @@
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Functional/Domain/Repository/Fixtures/Product/Tea.xml b/Tests/Functional/Domain/Repository/Fixtures/Product/Tea.xml
new file mode 100644
index 0000000..1117c65
--- /dev/null
+++ b/Tests/Functional/Domain/Repository/Fixtures/Product/Tea.xml
@@ -0,0 +1,9 @@
+
+
+
+ 1
+ 1
+ Earl Grey
+ Fresh and hot.
+
+
diff --git a/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php
new file mode 100644
index 0000000..888f1c0
--- /dev/null
+++ b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php
@@ -0,0 +1,74 @@
+subject = $objectManager->get(TeaRepository::class);
+ }
+
+ /**
+ * @test
+ */
+ public function findAllForNoRecordsReturnsEmptyContainer()
+ {
+ $container = $this->subject->findAll();
+
+ static::assertCount(0, $container);
+ }
+
+ /**
+ * @test
+ */
+ public function findAllWithRecordsFindsRecordsFromAllPages()
+ {
+ $this->importDataSet(__DIR__ . '/../Fixtures/Product/Tea.xml');
+
+ $container = $this->subject->findAll();
+
+ static::assertGreaterThanOrEqual(1, \count($container));
+ }
+
+ /**
+ * @test
+ */
+ public function findByUidForExistingRecordReturnsModelWithData()
+ {
+ $this->importDataSet(__DIR__ . '/../Fixtures/Product/Tea.xml');
+
+ $uid = 1;
+ /** @var Tea $model */
+ $model = $this->subject->findByUid($uid);
+
+ static::assertNotNull($model);
+ static::assertSame('Earl Grey', $model->getTitle());
+ static::assertSame('Fresh and hot.', $model->getDescription());
+ }
+}
diff --git a/Tests/Unit/Domain/Model/.gitkeep b/Tests/Unit/Domain/Model/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Tests/Unit/Domain/Model/Product/TeaTest.php b/Tests/Unit/Domain/Model/Product/TeaTest.php
new file mode 100644
index 0000000..cf867dc
--- /dev/null
+++ b/Tests/Unit/Domain/Model/Product/TeaTest.php
@@ -0,0 +1,71 @@
+subject = new Tea();
+ }
+
+ /**
+ * @test
+ */
+ public function isAbstractEntity()
+ {
+ static::assertInstanceOf(AbstractEntity::class, $this->subject);
+ }
+
+ /**
+ * @test
+ */
+ public function getTitleInitiallyReturnsEmptyString()
+ {
+ static::assertSame('', $this->subject->getTitle());
+ }
+
+ /**
+ * @test
+ */
+ public function setTitleSetsTitle()
+ {
+ $value = 'Club-Mate';
+ $this->subject->setTitle($value);
+
+ static::assertSame($value, $this->subject->getTitle());
+ }
+
+ /**
+ * @test
+ */
+ public function getDescriptionInitiallyReturnsEmptyString()
+ {
+ static::assertSame('', $this->subject->getDescription());
+ }
+
+ /**
+ * @test
+ */
+ public function setDescriptionSetsDescription()
+ {
+ $value = 'Club-Mate';
+ $this->subject->setDescription($value);
+
+ static::assertSame($value, $this->subject->getDescription());
+ }
+}
diff --git a/Tests/Unit/Domain/Repository/.gitkeep b/Tests/Unit/Domain/Repository/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php
new file mode 100644
index 0000000..f9a5cb6
--- /dev/null
+++ b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php
@@ -0,0 +1,42 @@
+prophesize(ObjectManagerInterface::class);
+ $this->objectManager = $objectManagerProphecy->reveal();
+ $this->subject = new TeaRepository($this->objectManager);
+ }
+
+ /**
+ * @test
+ */
+ public function isRepository()
+ {
+ static::assertInstanceOf(Repository::class, $this->subject);
+ }
+}
diff --git a/composer.json b/composer.json
index ec00f79..6559be6 100644
--- a/composer.json
+++ b/composer.json
@@ -65,6 +65,15 @@
"scripts": {
"ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l",
"ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/",
+ "ci:tests:unit": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit/",
+ "ci:tests:functional": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml Tests/Functional/",
+ "ci:tests": [
+ "@ci:tests:unit",
+ "@ci:tests:functional"
+ ],
+ "ci:dynamic": [
+ "@ci:tests"
+ ],
"ci:static": [
"@ci:php:lint",
"@ci:ts:lint"
diff --git a/ext_tables.sql b/ext_tables.sql
new file mode 100644
index 0000000..5b2803c
--- /dev/null
+++ b/ext_tables.sql
@@ -0,0 +1,16 @@
+CREATE TABLE tx_tea_domain_model_product_tea (
+ uid int(11) NOT NULL auto_increment,
+ pid int(11) DEFAULT '0' 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,
+
+ title varchar(255) DEFAULT '' NOT NULL,
+ description varchar(2000) DEFAULT '' NOT NULL,
+
+ PRIMARY KEY (uid),
+ KEY parent (pid)
+);