Skip to content

Commit

Permalink
[TASK] Split up the DB fixtures for the functional tests
Browse files Browse the repository at this point in the history
This makes the fixture more minimal and reduces cross-dependencies
between tests.

Also consistently avoid quotes for integer data in CSV DB fixtures.

Fixes #988
  • Loading branch information
oliverklee committed Nov 17, 2023
1 parent 1cd6ec4 commit 2c56205
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
8 changes: 0 additions & 8 deletions Tests/Functional/Domain/Repository/Fixtures/Product/Tea.csv

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title"
,1,1,"Earl Grey"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title","description","owner"
,1,1,"Earl Grey","Fresh and hot.",2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title","image",
,1,1,"Gunpowder",1

"sys_file_reference"
,"uid","uid_foreign","tablenames","fieldname"
,1,1,"tx_tea_domain_model_product_tea","image"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title","owner"
,"1","1","Earl Grey",0
,1,1,"Earl Grey",0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title","owner"
,"1","1","Earl Grey",1
,"2","1","Assam",1
,1,1,"Earl Grey",1
,2,1,"Assam",1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"tx_tea_domain_model_product_tea"
,"uid","pid","title"
,1,1,"Earl Grey"
,2,1,"Assam"
15 changes: 7 additions & 8 deletions Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ public function findAllForNoRecordsReturnsEmptyContainer(): void
*/
public function findAllWithRecordsFindsRecordsFromAllPages(): void
{
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/Tea.csv');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaOnPage.csv');

$result = $this->subject->findAll();

self::assertGreaterThanOrEqual(1, \count($result));
self::assertCount(1, $result);
}

/**
* @test
*/
public function findAllSortsByTitleInAscendingOrder(): void
{
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/Tea.csv');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TwoUnsortedTeas.csv');

$result = $this->subject->findAll();

Expand All @@ -71,7 +71,7 @@ public function findAllSortsByTitleInAscendingOrder(): void
*/
public function findByUidForExistingRecordReturnsModel(): void
{
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/Tea.csv');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithAllScalarData.csv');

$uid = 1;
$model = $this->subject->findByUid($uid);
Expand All @@ -84,7 +84,7 @@ public function findByUidForExistingRecordReturnsModel(): void
*/
public function findByUidForExistingRecordMapsAllScalarData(): void
{
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/Tea.csv');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithAllScalarData.csv');

$uid = 1;
$model = $this->subject->findByUid($uid);
Expand All @@ -100,10 +100,9 @@ public function findByUidForExistingRecordMapsAllScalarData(): void
*/
public function fillsImageRelation(): void
{
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/Tea.csv');
$this->importCSVDataSet(__DIR__ . '/../Fixtures/Product/TeaWithImage.csv');

$uid = 3;
$model = $this->subject->findByUid($uid);
$model = $this->subject->findByUid(1);

$image = $model->getImage();
self::assertInstanceOf(FileReference::class, $image);
Expand Down

0 comments on commit 2c56205

Please sign in to comment.