diff --git a/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php index a00efd7..5812758 100644 --- a/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php @@ -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']); + } }