mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 23:36:13 +02:00

[TASK] Switch the functional tests to nimut/testing-framework

This commit is contained in:
Oliver Klee 2017-09-07 16:24:52 +02:00
parent a8b687a656
commit 3cc3fd09b1
7 changed files with 31 additions and 44 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<dataset> <dataset>
<tx_tea_domain_model_teabeverage> <tx_tea_domain_model_teabeverage>
<uid>1</uid> <uid>1</uid>
<size>3.141</size> <size>3.141</size>
</tx_tea_domain_model_teabeverage> </tx_tea_domain_model_teabeverage>
</dataset> </dataset>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<tx_tea_domain_model_testimonial>
<uid>1</uid>
<text>A very good Early Grey!</text>
</tx_tea_domain_model_testimonial>
</dataset>

View file

@ -24,12 +24,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
* *
* @author Oliver Klee <typo3-coding@oliverklee.de> * @author Oliver Klee <typo3-coding@oliverklee.de>
*/ */
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 * @var TeaBeverageRepository|\PHPUnit_Framework_MockObject_MockObject
@ -38,10 +38,7 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase
protected function setUp() protected function setUp()
{ {
if (!$this->createDatabase()) { parent::setUp();
self::markTestSkipped('Test database could not be created.');
}
$this->importExtensions(['tea']);
/** @var ObjectManager $objectManager */ /** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
@ -50,12 +47,6 @@ class TeaBeverageRepositoryTest extends \Tx_Phpunit_Database_TestCase
$this->subject = $objectManager->get(TeaBeverageRepository::class); $this->subject = $objectManager->get(TeaBeverageRepository::class);
} }
protected function tearDown()
{
$this->dropDatabase();
$this->switchToTypo3Database();
}
/** /**
* @test * @test
*/ */

View file

@ -24,26 +24,21 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
* *
* @author Oliver Klee <typo3-coding@oliverklee.de> * @author Oliver Klee <typo3-coding@oliverklee.de>
*/ */
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 * @var TestimonialRepository
*/ */
protected $subject = null; protected $subject = null;
/**
* @var \Tx_Phpunit_Framework
*/
protected $testingFramework = null;
protected function setUp() protected function setUp()
{ {
$this->testingFramework = new \Tx_Phpunit_Framework('tx_tea'); parent::setUp();
/** @var ObjectManager $objectManager */ /** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
@ -52,11 +47,6 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$this->subject = $objectManager->get(TestimonialRepository::class); $this->subject = $objectManager->get(TestimonialRepository::class);
} }
protected function tearDown()
{
$this->testingFramework->cleanUp();
}
/** /**
* @test * @test
*/ */
@ -72,7 +62,8 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function findAllWithOneRecordFindsThisRecord() public function findAllWithOneRecordFindsThisRecord()
{ {
$uid = $this->testingFramework->createRecord('tx_tea_domain_model_testimonial'); $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml');
$uid = 1;
$container = $this->subject->findAll(); $container = $this->subject->findAll();
/** @var Testimonial $first */ /** @var Testimonial $first */
@ -87,15 +78,14 @@ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
*/ */
public function findByUidForExistingRecordReturnsModelWithData() public function findByUidForExistingRecordReturnsModelWithData()
{ {
$text = 'A very good Early Grey!'; $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml');
$uid = $this->testingFramework->createRecord( $uid = 1;
'tx_tea_domain_model_testimonial', ['text' => $text]
);
/** @var Testimonial $model */ /** @var Testimonial $model */
$model = $this->subject->findByUid($uid); $model = $this->subject->findByUid($uid);
self::assertNotNull($model); self::assertNotNull($model);
$text = 'A very good Early Grey!';
self::assertSame($text, $model->getText()); self::assertSame($text, $model->getText());
} }
} }

View file

@ -22,12 +22,12 @@ use org\bovigo\vfs\vfsStreamDirectory;
* *
* @author Oliver Klee <typo3-coding@oliverklee.de> * @author Oliver Klee <typo3-coding@oliverklee.de>
*/ */
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 * @var \OliverKlee\Tea\Utility\FileUtility
@ -49,6 +49,8 @@ class FileUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp();
$this->root = vfsStream::setup('home'); $this->root = vfsStream::setup('home');
$this->targetFilePath = vfsStream::url('home/target.txt'); $this->targetFilePath = vfsStream::url('home/target.txt');

View file

@ -31,7 +31,6 @@
"require-dev": { "require-dev": {
"namelesscoder/typo3-repository-client": "^1.2.0", "namelesscoder/typo3-repository-client": "^1.2.0",
"nimut/testing-framework": "^2.0.0", "nimut/testing-framework": "^2.0.0",
"typo3-ter/phpunit": "*",
"phpunit/phpunit": "^5.7.0", "phpunit/phpunit": "^5.7.0",
"mikey179/vfsStream": "^1.6.0" "mikey179/vfsStream": "^1.6.0"
}, },

View file

@ -125,7 +125,7 @@ CREATE TABLE tx_tea_domain_model_testimonial (
teabeverage int(11) unsigned DEFAULT '0' NOT NULL, 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, number_of_consumed_cups int(11) DEFAULT '0' NOT NULL,
text text 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, crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL, cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
deleted tinyint(4) 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, hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
starttime int(11) unsigned DEFAULT '0' NOT NULL, starttime int(11) unsigned DEFAULT '0' NOT NULL,
endtime 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), PRIMARY KEY (uid),
KEY parent (pid), KEY parent (pid),
KEY t3ver_oid (t3ver_oid,t3ver_wsid), KEY t3ver_oid (t3ver_oid,t3ver_wsid),
KEY language (l10n_parent,sys_language_uid), KEY language (l10n_parent,sys_language_uid)
KEY phpunit_dummy (is_dummy_record)
); );
# #