*/ class TestimonialRepositoryTest extends \Nimut\TestingFramework\TestCase\FunctionalTestCase { /** * @var string[] */ protected $testExtensionsToLoad = ['typo3conf/ext/tea']; /** * @var TestimonialRepository */ protected $subject = null; protected function setUp() { parent::setUp(); /** @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); } /** * @test */ public function findAllForNoRecordsReturnsEmptyContainer() { $container = $this->subject->findAll(); self::assertCount(0, $container); } /** * @test */ public function findAllWithOneRecordFindsThisRecord() { $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml'); $uid = 1; $container = $this->subject->findAll(); /** @var Testimonial $first */ $first = $container->getFirst(); self::assertCount(1, $container); self::assertSame($uid, $first->getUid()); } /** * @test */ public function findByUidForExistingRecordReturnsModelWithData() { $this->importDataSet(__DIR__ . '/Fixtures/Testimonials.xml'); $uid = 1; /** @var Testimonial $model */ $model = $this->subject->findByUid($uid); self::assertNotNull($model); $text = 'A very good Early Grey!'; self::assertSame($text, $model->getText()); } }