From 3cc3fd09b140d789cbfe2014bd6c376d4ecc9384 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 7 Sep 2017 16:24:52 +0200 Subject: [PATCH] [TASK] Switch the functional tests to nimut/testing-framework --- .../Repository/Fixtures/TeaBeverages.xml | 8 +++--- .../Repository/Fixtures/Testimonials.xml | 7 +++++ .../Repository/TeaBeverageRepositoryTest.php | 17 +++-------- .../Repository/TestimonialRepositoryTest.php | 28 ++++++------------- Tests/Functional/Utility/FileUtilityTest.php | 8 ++++-- composer.json | 1 - ext_tables.sql | 6 ++-- 7 files changed, 31 insertions(+), 44 deletions(-) create mode 100644 Tests/Functional/Domain/Repository/Fixtures/Testimonials.xml diff --git a/Tests/Functional/Domain/Repository/Fixtures/TeaBeverages.xml b/Tests/Functional/Domain/Repository/Fixtures/TeaBeverages.xml index 09c9f80..29887f0 100644 --- a/Tests/Functional/Domain/Repository/Fixtures/TeaBeverages.xml +++ b/Tests/Functional/Domain/Repository/Fixtures/TeaBeverages.xml @@ -1,7 +1,7 @@ - - 1 - 3.141 - + + 1 + 3.141 + \ No newline at end of file diff --git a/Tests/Functional/Domain/Repository/Fixtures/Testimonials.xml b/Tests/Functional/Domain/Repository/Fixtures/Testimonials.xml new file mode 100644 index 0000000..2c89fb0 --- /dev/null +++ b/Tests/Functional/Domain/Repository/Fixtures/Testimonials.xml @@ -0,0 +1,7 @@ + + + + 1 + A very good Early Grey! + + \ No newline at end of file diff --git a/Tests/Functional/Domain/Repository/TeaBeverageRepositoryTest.php b/Tests/Functional/Domain/Repository/TeaBeverageRepositoryTest.php index 2cfb1d0..0088905 100644 --- a/Tests/Functional/Domain/Repository/TeaBeverageRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/TeaBeverageRepositoryTest.php @@ -24,12 +24,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; * * @author Oliver Klee */ -class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase +class TeaBeverageRepositoryTest extends \Nimut\TestingFramework\TestCase\FunctionalTestCase { /** - * @var bool + * @var string[] */ - protected $backupGlobals = false; + protected $testExtensionsToLoad = ['typo3conf/ext/tea']; /** * @var TeaBeverageRepository|\PHPUnit_Framework_MockObject_MockObject @@ -38,10 +38,7 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase protected function setUp() { - if (!$this->createDatabase()) { - self::markTestSkipped('Test database could not be created.'); - } - $this->importExtensions(['tea']); + parent::setUp(); /** @var ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance(ObjectManager::class); @@ -50,12 +47,6 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase $this->subject = $objectManager->get(TeaBeverageRepository::class); } - protected function tearDown() - { - $this->dropDatabase(); - $this->switchToTypo3Database(); - } - /** * @test */ diff --git a/Tests/Functional/Domain/Repository/TestimonialRepositoryTest.php b/Tests/Functional/Domain/Repository/TestimonialRepositoryTest.php index 557d20b..6e4d5e8 100644 --- a/Tests/Functional/Domain/Repository/TestimonialRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/TestimonialRepositoryTest.php @@ -24,26 +24,21 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; * * @author Oliver Klee */ -class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +class TestimonialRepositoryTest extends \Nimut\TestingFramework\TestCase\FunctionalTestCase { /** - * @var bool + * @var string[] */ - protected $backupGlobals = false; + protected $testExtensionsToLoad = ['typo3conf/ext/tea']; /** * @var TestimonialRepository */ protected $subject = null; - /** - * @var \Tx_Phpunit_Framework - */ - protected $testingFramework = null; - protected function setUp() { - $this->testingFramework = new \Tx_Phpunit_Framework('tx_tea'); + parent::setUp(); /** @var ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance(ObjectManager::class); @@ -52,11 +47,6 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->subject = $objectManager->get(TestimonialRepository::class); } - protected function tearDown() - { - $this->testingFramework->cleanUp(); - } - /** * @test */ @@ -72,7 +62,8 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase */ public function findAllWithOneRecordFindsThisRecord() { - $uid = $this->testingFramework->createRecord('tx_tea_domain_model_testimonial'); + $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml'); + $uid = 1; $container = $this->subject->findAll(); /** @var Testimonial $first */ @@ -87,15 +78,14 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase */ public function findByUidForExistingRecordReturnsModelWithData() { - $text = 'A very good Early Grey!'; - $uid = $this->testingFramework->createRecord( - 'tx_tea_domain_model_testimonial', ['text' => $text] - ); + $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml'); + $uid = 1; /** @var Testimonial $model */ $model = $this->subject->findByUid($uid); self::assertNotNull($model); + $text = 'A very good Early Grey!'; self::assertSame($text, $model->getText()); } } diff --git a/Tests/Functional/Utility/FileUtilityTest.php b/Tests/Functional/Utility/FileUtilityTest.php index 6762800..968f87d 100644 --- a/Tests/Functional/Utility/FileUtilityTest.php +++ b/Tests/Functional/Utility/FileUtilityTest.php @@ -22,12 +22,12 @@ use org\bovigo\vfs\vfsStreamDirectory; * * @author Oliver Klee */ -class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +class FileUtilityTest extends \Nimut\TestingFramework\TestCase\FunctionalTestCase { /** - * @var bool + * @var string[] */ - protected $backupGlobals = false; + protected $testExtensionsToLoad = ['typo3conf/ext/tea']; /** * @var \OliverKlee\Tea\Utility\FileUtility @@ -49,6 +49,8 @@ class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase protected function setUp() { + parent::setUp(); + $this->root = vfsStream::setup('home'); $this->targetFilePath = vfsStream::url('home/target.txt'); diff --git a/composer.json b/composer.json index 87fe511..b27aacc 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,6 @@ "require-dev": { "namelesscoder/typo3-repository-client": "^1.2.0", "nimut/testing-framework": "^2.0.0", - "typo3-ter/phpunit": "*", "phpunit/phpunit": "^5.7.0", "mikey179/vfsStream": "^1.6.0" }, diff --git a/ext_tables.sql b/ext_tables.sql index b311f3c..f99ebbf 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -125,7 +125,7 @@ CREATE TABLE tx_tea_domain_model_testimonial ( teabeverage int(11) unsigned DEFAULT '0' NOT NULL, - date_of_posting datetime DEFAULT '0000-00-00 00:00:00', + date_of_posting int(11) unsigned DEFAULT '0' NOT NULL, number_of_consumed_cups int(11) DEFAULT '0' NOT NULL, text text NOT NULL, @@ -133,7 +133,6 @@ CREATE TABLE tx_tea_domain_model_testimonial ( 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, - is_dummy_record tinyint(1) 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, @@ -156,8 +155,7 @@ CREATE TABLE tx_tea_domain_model_testimonial ( PRIMARY KEY (uid), KEY parent (pid), KEY t3ver_oid (t3ver_oid,t3ver_wsid), - KEY language (l10n_parent,sys_language_uid), - KEY phpunit_dummy (is_dummy_record) + KEY language (l10n_parent,sys_language_uid) ); #