[FEATURE] Add CSV dataset export for functional tests#698
[FEATURE] Add CSV dataset export for functional tests#698bmack wants to merge 1 commit intoTYPO3:mainfrom
Conversation
| } | ||
|
|
||
| if (!empty($failMessages)) { | ||
| if (getenv('TYPO3_TESTING_EXPORT_DATASETS')) { |
There was a problem hiding this comment.
Not sure about that ... at least we should use a naming reflecting the case DATASETS are not always exported:
| if (getenv('TYPO3_TESTING_EXPORT_DATASETS')) { | |
| if ((bool)getenv('TYPO3_TESTING_EXPORT_DATASETS_ON_FAILED_ASSERTION')) { |
| if ($value === null) { | ||
| return '\\NULL'; | ||
| } | ||
| $stringValue = (string)$value; |
There was a problem hiding this comment.
Not sure about the implementation here, all values are converted to strings and some generic formating.
Not sure if we should bind that to the real database schema inforamation for table/column ... , having text/string/varchar field values always enquoted and other data (int, float/double, ) in the respected form.
Also thinking about native json fields for supported dbms (not using fallback TEXT/CBOLB for the others etc ) ....
Needs some thinking about this ...
| return '""'; | ||
| } | ||
| if (preg_match('/[,"\n\r\\\\]/', $stringValue)) { | ||
| return '"' . str_replace('"', '""', $stringValue) . '"'; |
There was a problem hiding this comment.
This only quotes text values if they contain , " or some line breaks. If not, they are not quoted ...
GIVEN...: Some Text
EXPECTED: "Some Text"
ACTUAL..: Some Text
ce2c366 to
9baf42c
Compare
Introduce exportCSVDataSet() to write current database state
to CSV files matching the existing fixture format. This completes
the import → assert → export workflow for functional tests.
Usage example:
$this->exportCSVDataSet(
$this->instancePath . '/export.csv',
['pages' => ['uid', 'pid', 'title'], 'tt_content']
);
Tables can specify explicit fields or export all columns.
Additionally, assertCSVDataSet() now auto-exports the actual
database state to a _actual.csv file when assertions fail and
the TYPO3_TESTING_EXPORT_DATASETS environment variable is set.
|
|
Introduce exportCSVDataSet() to write current database state to CSV files matching the existing fixture format. This completes the import → assert → export workflow for functional tests.
Usage example:
Tables can specify explicit fields or export all columns.
Additionally, assertCSVDataSet() now auto-exports the actual database state to a _actual.csv file when assertions fail and the TYPO3_TESTING_EXPORT_DATASETS environment variable is set.