From 3e4d10cc124bdbb3aab131e77202d1fd01fa4eaa Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Mon, 28 May 2018 15:17:19 +0200 Subject: [PATCH] [FEATURE] Add tests using the database abstraction (#25) --- .../Repository/Product/TeaRepositoryTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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']); + } }