mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 18:36:12 +02:00

Mark tests to be demonstrated during the workshop

This commit is contained in:
Oliver Klee 2022-06-18 18:01:23 +02:00
parent efbc9335a6
commit 33c777d054
4 changed files with 28 additions and 89 deletions

View file

@ -36,9 +36,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findAllForNoRecordsReturnsEmptyContainer(): void public function findAllForNoRecordsReturnsEmptyContainer(): void
{ {
$result = $this->subject->findAll(); self::markTestIncomplete('Code me!');
self::assertCount(0, $result);
} }
/** /**
@ -46,11 +44,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findAllWithRecordsFindsRecordsFromAllPages(): void public function findAllWithRecordsFindsRecordsFromAllPages(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaOnPage.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findAll();
self::assertCount(1, $result);
} }
/** /**
@ -58,12 +52,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findAllSortsByTitleInAscendingOrder(): void public function findAllSortsByTitleInAscendingOrder(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TwoUnsortedTeas.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findAll();
$result->rewind();
self::assertSame(2, $result->current()->getUid());
} }
/** /**
@ -81,11 +70,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByUidForExistingRecordReturnsModel(): void public function findByUidForExistingRecordReturnsModel(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithAllScalarData.csv'); self::markTestIncomplete('Code me!');
$model = $this->subject->findByUid(1);
self::assertInstanceOf(Tea::class, $model);
} }
/** /**
@ -93,14 +78,9 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByUidForExistingRecordMapsAllScalarData(): void public function findByUidForExistingRecordMapsAllScalarData(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithAllScalarData.csv'); self::markTestIncomplete('Code me!');
$model = $this->subject->findByUid(1); // @todo: title, description
self::assertInstanceOf(Tea::class, $model);
self::assertSame('Earl Grey', $model->getTitle());
self::assertSame('Fresh and hot.', $model->getDescription());
self::assertSame(2, $model->getOwnerUid());
} }
/** /**
@ -108,13 +88,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function fillsImageRelation(): void public function fillsImageRelation(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithImage.csv'); self::markTestIncomplete('Code me!');
$model = $this->subject->findByUid(1);
$image = $model->getImage();
self::assertInstanceOf(FileReference::class, $image);
self::assertSame(1, $image->getUid());
} }
/** /**
@ -122,14 +96,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function addAndPersistAllCreatesNewRecord(): void public function addAndPersistAllCreatesNewRecord(): void
{ {
$title = 'Godesberger Burgtee'; self::markTestIncomplete('Code me!');
$model = new Tea();
$model->setTitle($title);
$this->subject->add($model);
$this->persistenceManager->persistAll();
$this->assertCSVDataSet(__DIR__ . '/../Fixtures/Product/PersistedTea.csv');
} }
/** /**
@ -137,11 +104,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByOwnerUidFindsTeaWithTheGivenOwnerUid(): void public function findByOwnerUidFindsTeaWithTheGivenOwnerUid(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithOwner.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findByOwnerUid(1);
self::assertCount(1, $result);
} }
/** /**
@ -149,11 +112,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByOwnerUidFindsIgnoresTeaWithNonMatchingOwnerUid(): void public function findByOwnerUidFindsIgnoresTeaWithNonMatchingOwnerUid(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithOwner.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findByOwnerUid(2);
self::assertCount(0, $result);
} }
/** /**
@ -161,11 +120,7 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByOwnerUidFindsIgnoresTeaWithZeroOwnerUid(): void public function findByOwnerUidFindsIgnoresTeaWithZeroOwnerUid(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithoutOwner.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findByOwnerUid(1);
self::assertCount(0, $result);
} }
/** /**
@ -173,11 +128,6 @@ final class TeaRepositoryTest extends FunctionalTestCase
*/ */
public function findByOwnerUidSortsByTitleInAscendingOrder(): void public function findByOwnerUidSortsByTitleInAscendingOrder(): void
{ {
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TwoTeasWithOwner.csv'); self::markTestIncomplete('Code me!');
$result = $this->subject->findByOwnerUid(1);
$result->rewind();
self::assertSame(2, $result->current()->getUid());
} }
} }

View file

@ -60,7 +60,7 @@ final class TeaControllerTest extends UnitTestCase
*/ */
public function isActionController(): void public function isActionController(): void
{ {
self::assertInstanceOf(ActionController::class, $this->subject); self::markTestIncomplete('Code me!');
} }
/** /**
@ -68,11 +68,7 @@ final class TeaControllerTest extends UnitTestCase
*/ */
public function indexActionAssignsAllTeaAsTeasToView(): void public function indexActionAssignsAllTeaAsTeasToView(): void
{ {
$teas = $this->createStub(QueryResultInterface::class); self::markTestIncomplete('Code me!');
$this->teaRepositoryMock->method('findAll')->willReturn($teas);
$this->viewMock->expects(self::once())->method('assign')->with('teas', $teas);
$this->subject->indexAction();
} }
/** /**
@ -90,10 +86,7 @@ final class TeaControllerTest extends UnitTestCase
*/ */
public function showActionAssignsPassedTeaAsTeaToView(): void public function showActionAssignsPassedTeaAsTeaToView(): void
{ {
$tea = new Tea(); self::markTestIncomplete('Code me!');
$this->viewMock->expects(self::once())->method('assign')->with('tea', $tea);
$this->subject->showAction($tea);
} }
/** /**

View file

@ -20,7 +20,7 @@ final class TeaTest extends UnitTestCase
{ {
parent::setUp(); parent::setUp();
$this->subject = new Tea(); // @todo: build subject
} }
/** /**
@ -28,7 +28,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function isAbstractEntity(): void public function isAbstractEntity(): void
{ {
self::assertInstanceOf(AbstractEntity::class, $this->subject); self::markTestIncomplete('Code me!');
} }
/** /**
@ -36,7 +36,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function getTitleInitiallyReturnsEmptyString(): void public function getTitleInitiallyReturnsEmptyString(): void
{ {
self::assertSame('', $this->subject->getTitle()); self::markTestIncomplete('Code me!');
} }
/** /**
@ -44,10 +44,8 @@ final class TeaTest extends UnitTestCase
*/ */
public function setTitleSetsTitle(): void public function setTitleSetsTitle(): void
{ {
$value = 'Club-Mate'; self::markTestIncomplete('Code me!');
$this->subject->setTitle($value);
self::assertSame($value, $this->subject->getTitle());
} }
/** /**
@ -55,7 +53,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function getDescriptionInitiallyReturnsEmptyString(): void public function getDescriptionInitiallyReturnsEmptyString(): void
{ {
self::assertSame('', $this->subject->getDescription()); self::markTestIncomplete('Code me!');
} }
/** /**
@ -63,10 +61,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function setDescriptionSetsDescription(): void public function setDescriptionSetsDescription(): void
{ {
$value = 'Club-Mate'; self::markTestIncomplete('Code me!');
$this->subject->setDescription($value);
self::assertSame($value, $this->subject->getDescription());
} }
/** /**
@ -74,7 +69,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function getImageInitiallyReturnsNull(): void public function getImageInitiallyReturnsNull(): void
{ {
self::assertNull($this->subject->getImage()); self::markTestIncomplete('Code me!');
} }
/** /**
@ -82,10 +77,7 @@ final class TeaTest extends UnitTestCase
*/ */
public function setImageSetsImage(): void public function setImageSetsImage(): void
{ {
$model = new FileReference(); self::markTestIncomplete('Code me!');
$this->subject->setImage($model);
self::assertSame($model, $this->subject->getImage());
} }
/** /**

View file

@ -20,6 +20,7 @@ final class TeaRepositoryTest extends UnitTestCase
{ {
parent::setUp(); parent::setUp();
<<<<<<< HEAD
if (\interface_exists(ObjectManagerInterface::class)) { if (\interface_exists(ObjectManagerInterface::class)) {
$objectManagerStub = $this->createStub(ObjectManagerInterface::class); $objectManagerStub = $this->createStub(ObjectManagerInterface::class);
// @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12. // @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.
@ -27,6 +28,9 @@ final class TeaRepositoryTest extends UnitTestCase
} else { } else {
$this->subject = new TeaRepository(); $this->subject = new TeaRepository();
} }
=======
// @todo: create subject with `ObjectManagerInterface` stub
>>>>>>> cc534d5 (Mark tests to be demonstrated during the workshop)
} }
/** /**
@ -34,6 +38,6 @@ final class TeaRepositoryTest extends UnitTestCase
*/ */
public function isRepository(): void public function isRepository(): void
{ {
self::assertInstanceOf(Repository::class, $this->subject); self::markTestIncomplete('Code me!');
} }
} }