Skip to content

Commit

Permalink
[TASK] Migrate the testing fixtures to CSV (#408)
Browse files Browse the repository at this point in the history
Fixes #200
  • Loading branch information
oliverklee authored Nov 9, 2023
1 parent 37668f4 commit f4a00e0
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 147 deletions.
3 changes: 3 additions & 0 deletions Tests/Functional/Domain/Repository/Fixtures/Pages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"pages"
,"uid"
,1
6 changes: 0 additions & 6 deletions Tests/Functional/Domain/Repository/Fixtures/Pages.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"fe_groups"
,"uid","pid","title","description"
,1,1,"editors","We build websites!"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"fe_groups"
,"uid","crdate","tstamp","title","description"
,1,1546300800,1672531200,"editors","We build websites!"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"fe_groups"
,"uid","subgroup"
,1,"2,3"
,2,""
,3,""

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"fe_users"
,"uid","crdate","tstamp","username","password","usergroup","name","first_name","middle_name","last_name","address","telephone","email","title","zip","city","country","www","company","image","lastlogin","zone","privacy","full_salutation","gender","date_of_birth","status","comments"
,1,1546300800,1672531200,"max","luif3ui4t12","","Max M. Minimau","Max","Murri","Minimau","Near the heating 4","+49 1111 1233456-78","[email protected]","Head of fur","01234","Kattingen","United States of CAT","www.example.com","Cat Scans Inc.","",1648922400,"NRW",1,"Welcome, Max MM!",2,1648857600,2,"Here we go!"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"fe_users"
,"uid","username"
,1,""

This file was deleted.

15 changes: 15 additions & 0 deletions Tests/Functional/Domain/Repository/Fixtures/UserWithImage.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"fe_users"
,"uid","image"
,1,1

"sys_file"
,"uid","storage","type","folder_hash","identifier","identifier_hash","name","extension","mime_type"
,5,1,0,"42099b4af021e53fd8fd4e056c2568d7c2e3ffa8","/model.jpg","7e53a1ace84baf4fb1708ba6aa29c85b2a9ec904","model.jpg","jpg","image/jpeg"

"sys_file_metadata"
,"uid","file","title","l10n_diffsource"
,1,5,"model image",""

"sys_file_reference"
,"uid","uid_local","uid_foreign","tablenames","fieldname"
,1,5,1,"fe_users","image"
37 changes: 0 additions & 37 deletions Tests/Functional/Domain/Repository/Fixtures/UserWithImage.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"fe_users"
,"uid","username","usergroup"
,1,"max","1,2"

"fe_groups"
,"uid"
,1
,2
14 changes: 0 additions & 14 deletions Tests/Functional/Domain/Repository/Fixtures/UserWithTwoGroups.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function findAllForNoRecordsReturnsEmptyContainer(): void
*/
public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

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

Expand All @@ -57,7 +57,7 @@ public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void
*/
public function findByUidsWithoutMatchesReturnsEmptyArray(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

$models = $this->subject->findByUids([2]);

Expand All @@ -69,7 +69,7 @@ public function findByUidsWithoutMatchesReturnsEmptyArray(): void
*/
public function findByUidsForExistingRecordReturnsMatchingModel(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

$models = $this->subject->findByUids([1]);

Expand All @@ -84,7 +84,7 @@ public function findByUidsForExistingRecordReturnsMatchingModel(): void
*/
public function findByUidsFindsRecordsOnAnyPage(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupOnPage.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupOnPage.csv');

$models = $this->subject->findByUids([1]);

Expand All @@ -99,7 +99,7 @@ public function findByUidsFindsRecordsOnAnyPage(): void
*/
public function findByUidsSilentlyIgnoresNonStringUids(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

// @phpstan-ignore-next-line We are explicitly testing with a contract-violating value.
$models = $this->subject->findByUids([1, '\'"--ab']);
Expand All @@ -115,7 +115,7 @@ public function findByUidsSilentlyIgnoresNonStringUids(): void
*/
public function findByUidsForForPartialMatchesReturnsOnlyTheMatches(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

$models = $this->subject->findByUids([1, 2]);

Expand All @@ -130,7 +130,7 @@ public function findByUidsForForPartialMatchesReturnsOnlyTheMatches(): void
*/
public function initializesSubGroupsWithEmptyStorage(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUserGroup::class, $model);
Expand All @@ -145,7 +145,7 @@ public function initializesSubGroupsWithEmptyStorage(): void
*/
public function mapsSubgroupAssociation(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserGroupWithTwoSubgroups.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithTwoSubgroups.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUserGroup::class, $model);
Expand Down
20 changes: 10 additions & 10 deletions Tests/Functional/Domain/Repository/FrontendUserRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function findAllForNoRecordsReturnsEmptyContainer(): void
*/
public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.csv');

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

Expand Down Expand Up @@ -85,7 +85,7 @@ public function findByUidForExistingRecordReturnsModelWithAllScalarData(): void
*/
public function initializesUserGroupsWithEmptyStorage(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUser::class, $model);
Expand All @@ -100,7 +100,7 @@ public function initializesUserGroupsWithEmptyStorage(): void
*/
public function mapsUserGroupsAssociation(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithTwoGroups.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithTwoGroups.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUser::class, $model);
Expand All @@ -118,7 +118,7 @@ public function mapsUserGroupsAssociation(): void
*/
public function initializesImageWithEmptyStorage(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUser::class, $model);
Expand All @@ -133,7 +133,7 @@ public function initializesImageWithEmptyStorage(): void
*/
public function mapsImageAssociation(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithImage.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithImage.csv');

$model = $this->subject->findByUid(1);
self::assertInstanceOf(FrontendUser::class, $model);
Expand Down Expand Up @@ -181,7 +181,7 @@ public function findOneByUsernameWithoutMatchReturnsNull(): void
public function findOneByUsernameWithMatchReturnsUserWithTheProvidedUsername(): void
{
$username = 'max';
$this->importDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.csv');

$result = $this->subject->findOneByUsername($username);

Expand All @@ -194,7 +194,7 @@ public function findOneByUsernameWithMatchReturnsUserWithTheProvidedUsername():
*/
public function findOneByUsernameWithEmptyUsernameReturnsNullEvenForUserWithEmptyUsername(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithEmptyUsername.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithEmptyUsername.csv');

$result = $this->subject->findOneByUsername('');

Expand All @@ -216,7 +216,7 @@ public function existsWithUsernameWithoutMatchReturnsFalse(): void
*/
public function existsWithUsernameWithMatchReturnsTrue(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithAllScalarData.csv');

$result = $this->subject->existsWithUsername('max');

Expand All @@ -228,7 +228,7 @@ public function existsWithUsernameWithMatchReturnsTrue(): void
*/
public function existsWithUsernameWithEmptyUsernameReturnsFalseEvenForUserWithEmptyUsername(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/UserWithEmptyUsername.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserWithEmptyUsername.csv');

$result = $this->subject->existsWithUsername('');

Expand All @@ -240,7 +240,7 @@ public function existsWithUsernameWithEmptyUsernameReturnsFalseEvenForUserWithEm
*/
public function willSaveNewUserWithExplicitPidOnTheGivenPage(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/Pages.xml');
$this->importCSVDataSet(__DIR__ . '/Fixtures/Pages.csv');
$pageUid = 1;

$user = new FrontendUser();
Expand Down

0 comments on commit f4a00e0

Please sign in to comment.