mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-25 21:56:13 +01:00
[FEATURE] Add tests using the database abstraction (#25)
This commit is contained in:
parent
b0ede23c29
commit
3e4d10cc12
1 changed files with 28 additions and 0 deletions
|
@ -8,6 +8,7 @@ use OliverKlee\Tea\Domain\Repository\Product\TeaRepository;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
|
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case.
|
* Test case.
|
||||||
|
@ -26,10 +27,17 @@ class TeaRepositoryTest extends FunctionalTestCase
|
||||||
*/
|
*/
|
||||||
private $subject = null;
|
private $subject = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PersistenceManager
|
||||||
|
*/
|
||||||
|
private $persistenceManager = null;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
|
||||||
|
|
||||||
/** @var ObjectManager $objectManager */
|
/** @var ObjectManager $objectManager */
|
||||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||||
$this->subject = $objectManager->get(TeaRepository::class);
|
$this->subject = $objectManager->get(TeaRepository::class);
|
||||||
|
@ -101,4 +109,24 @@ class TeaRepositoryTest extends FunctionalTestCase
|
||||||
static::assertInstanceOf(FileReference::class, $image);
|
static::assertInstanceOf(FileReference::class, $image);
|
||||||
static::assertSame(1, $image->getUid());
|
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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue