*/ class TestimonialRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { /** * @var bool */ protected $backupGlobals = false; /** * @var TestimonialRepository */ protected $subject = null; /** * @var \Tx_Phpunit_Framework */ protected $testingFramework = null; protected function setUp() { $this->testingFramework = new \Tx_Phpunit_Framework('tx_tea'); /** @var ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance(ObjectManager::class); // We are using the object manager instead of new so that the dependencies get injected. // In a unit test, we would inject the mocked dependencies instead. $this->subject = $objectManager->get(TestimonialRepository::class); } protected function tearDown() { $this->testingFramework->cleanUp(); } /** * @test */ public function findAllForNoRecordsReturnsEmptyContainer() { $container = $this->subject->findAll(); self::assertCount(0, $container); } /** * @test */ public function findAllWithOneRecordFindsThisRecord() { $uid = $this->testingFramework->createRecord('tx_tea_domain_model_testimonial'); $container = $this->subject->findAll(); /** @var Testimonial $first */ $first = $container->getFirst(); self::assertCount(1, $container); self::assertSame($uid, $first->getUid()); } /** * @test */ public function findByUidForExistingRecordReturnsModelWithData() { $text = 'A very good Early Grey!'; $uid = $this->testingFramework->createRecord( 'tx_tea_domain_model_testimonial', ['text' => $text] ); /** @var Testimonial $model */ $model = $this->subject->findByUid($uid); self::assertNotNull($model); self::assertSame($text, $model->getText()); } }