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

[FEATURE] Add tests using the database abstraction (#25)

This commit is contained in:
Oliver Klee 2018-05-28 15:17:19 +02:00 committed by GitHub
parent b0ede23c29
commit 3e4d10cc12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ use OliverKlee\Tea\Domain\Repository\Product\TeaRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
/**
* Test case.
@ -26,10 +27,17 @@ class TeaRepositoryTest extends FunctionalTestCase
*/
private $subject = null;
/**
* @var PersistenceManager
*/
private $persistenceManager = null;
protected function setUp()
{
parent::setUp();
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
/** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->subject = $objectManager->get(TeaRepository::class);
@ -101,4 +109,24 @@ class TeaRepositoryTest extends FunctionalTestCase
static::assertInstanceOf(FileReference::class, $image);
static::assertSame(1, $image->getUid());
}
/**
* @test
*/
public function addAndPersistAllCreatesNewRecord()
{
$title = 'Godesberger Burgtee';
$model = new Tea();
$model->setTitle($title);
$this->subject->add($model);
$this->persistenceManager->persistAll();
$databaseRow = $this->getDatabaseConnection()->selectSingleRow(
'*',
'tx_tea_domain_model_product_tea',
'uid = ' . $model->getUid()
);
static::assertSame($title, $databaseRow['title']);
}
}