mirror of
https://github.com/Codappix/typo3-php-datasets.git
synced 2024-11-14 10:16:12 +01:00
Support MM Relations (#8)
Those don't have a hash or uid field. We use a quick check whether a table is part of TCA in order to determine those tables.
This commit is contained in:
parent
dedec24de6
commit
3e594a0d15
5 changed files with 95 additions and 10 deletions
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## v1.3.1 - 2023-08-10
|
||||
|
||||
### Added
|
||||
|
||||
- Add Support for mm relations in assertions.
|
||||
|
||||
## v1.3.0 - 2023-05-11
|
||||
|
||||
### Added
|
||||
|
|
|
@ -54,7 +54,7 @@ trait TestingFramework
|
|||
$failMessages = [];
|
||||
|
||||
foreach ($dataSet as $tableName => $expectedRecords) {
|
||||
$records = $this->getAllRecords($tableName, true);
|
||||
$records = $this->getAllRecords($tableName, (isset($GLOBALS['TCA'][$tableName])));
|
||||
|
||||
foreach ($expectedRecords as $assertion) {
|
||||
$result = $this->assertInRecords($assertion, $records);
|
||||
|
|
|
@ -60,6 +60,15 @@ class AssertTest extends AbstractFunctionalTestCase
|
|||
$this->assertPHPDataSet(__DIR__ . '/Fixtures/WithDifferentColumns.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function canAssertMmRelation(): void
|
||||
{
|
||||
$this->importPHPDataSet(__DIR__ . '/Fixtures/MmRelation.php');
|
||||
$this->assertPHPDataSet(__DIR__ . '/Fixtures/MmRelation.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
@ -78,14 +87,11 @@ class AssertTest extends AbstractFunctionalTestCase
|
|||
$this->importPHPDataSet(__DIR__ . '/Fixtures/SimpleSet.php');
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
$this->expectExceptionMessage(
|
||||
'Assertion in data-set failed for "pages:1":'
|
||||
. PHP_EOL
|
||||
. 'Fields|Assertion |Record '
|
||||
. PHP_EOL
|
||||
. 'title |Rootpage without match|Rootpage'
|
||||
. PHP_EOL
|
||||
);
|
||||
$this->expectExceptionMessage(implode(PHP_EOL, [
|
||||
'Assertion in data-set failed for "pages:1":',
|
||||
'Fields|Assertion |Record ',
|
||||
'title |Rootpage without match|Rootpage',
|
||||
]));
|
||||
$this->assertPHPDataSet(__DIR__ . '/Fixtures/AssertDifferingWithUid.php');
|
||||
}
|
||||
|
||||
|
@ -103,10 +109,35 @@ class AssertTest extends AbstractFunctionalTestCase
|
|||
' \'pid\' => \'0\', ',
|
||||
' \'title\' => \'Rootpage without match\'',
|
||||
')',
|
||||
]) . PHP_EOL);
|
||||
'',
|
||||
]));
|
||||
$this->assertPHPDataSet(__DIR__ . '/Fixtures/AssertDifferingWithoutUid.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function failsForAssertionForMmRelation(): void
|
||||
{
|
||||
$this->importPHPDataSet(__DIR__ . '/Fixtures/MmRelation.php');
|
||||
|
||||
$this->expectException(AssertionFailedError::class);
|
||||
$this->expectExceptionMessage(implode(PHP_EOL, [
|
||||
'Assertion in data-set failed for "sys_category_record_mm":',
|
||||
'array(',
|
||||
' \'uid_local\' => \'1\', ',
|
||||
' \'uid_foreign\' => \'2\', ',
|
||||
' \'tablenames\' => \'pages\', ',
|
||||
' \'fieldname\' => \'categories\', ',
|
||||
' \'sorting\' => \'0\', ',
|
||||
' \'sorting_foreign\' => \'3\'',
|
||||
')',
|
||||
'',
|
||||
'Not asserted record found for "sys_category_record_mm:".',
|
||||
]));
|
||||
$this->assertPHPDataSet(__DIR__ . '/Fixtures/MmRelationBroken.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
24
Tests/Functional/Fixtures/MmRelation.php
Normal file
24
Tests/Functional/Fixtures/MmRelation.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'sys_category_record_mm' => [
|
||||
[
|
||||
'uid_local' => 1,
|
||||
'uid_foreign' => 1,
|
||||
'tablenames' => 'pages',
|
||||
'fieldname' => 'categories',
|
||||
'sorting' => 0,
|
||||
'sorting_foreign' => 1,
|
||||
],
|
||||
// A single one would work.
|
||||
// But a 2nd would have the same internal index, an empty key.
|
||||
[
|
||||
'uid_local' => 1,
|
||||
'uid_foreign' => 2,
|
||||
'tablenames' => 'pages',
|
||||
'fieldname' => 'categories',
|
||||
'sorting' => 0,
|
||||
'sorting_foreign' => 2,
|
||||
],
|
||||
],
|
||||
];
|
24
Tests/Functional/Fixtures/MmRelationBroken.php
Normal file
24
Tests/Functional/Fixtures/MmRelationBroken.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'sys_category_record_mm' => [
|
||||
[
|
||||
'uid_local' => 1,
|
||||
'uid_foreign' => 1,
|
||||
'tablenames' => 'pages',
|
||||
'fieldname' => 'categories',
|
||||
'sorting' => 0,
|
||||
'sorting_foreign' => 1,
|
||||
],
|
||||
// A single one would work.
|
||||
// But a 2nd would have the same internal index, an empty key.
|
||||
[
|
||||
'uid_local' => 1,
|
||||
'uid_foreign' => 2,
|
||||
'tablenames' => 'pages',
|
||||
'fieldname' => 'categories',
|
||||
'sorting' => 0,
|
||||
'sorting_foreign' => 3,
|
||||
],
|
||||
],
|
||||
];
|
Loading…
Reference in a new issue