Commit 437b3baf authored by Marc Bastian Heinrichs's avatar Marc Bastian Heinrichs Committed by Christian Kuhn
Browse files

[TASK] Add functional test for imports with forced uids

Adds a functional test to verify imports with forced uids.
The regarding error message for uncompatible forcing sys_file
uids is also shown now after the import is done.

Resolves: #58824
Releases: master, 6.2
Change-Id: If6062866903277ff32eae24354b6fd264fb65600
Reviewed-on: http://review.typo3.org/30141


Reviewed-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 3beac52f
......@@ -1601,6 +1601,7 @@ class ImportExport {
if (!isset($this->dat['header']['records']['sys_file'])) {
return;
}
$this->addGeneralErrorsByTable('sys_file');
// fetch fresh storage records from database
$storageRecords = $this->fetchStorageRecords();
......@@ -1839,6 +1840,7 @@ class ImportExport {
public function writeRecords_pages($pid) {
// First, write page structure if any:
if (is_array($this->dat['header']['records']['pages'])) {
$this->addGeneralErrorsByTable('pages');
// $pageRecords is a copy of the pages array in the imported file. Records here are unset one by one when the addSingle function is called.
$pageRecords = $this->dat['header']['records']['pages'];
$this->import_data = array();
......@@ -1935,6 +1937,7 @@ class ImportExport {
$this->import_data = array();
if (is_array($this->dat['header']['records'])) {
foreach ($this->dat['header']['records'] as $table => $recs) {
$this->addGeneralErrorsByTable($table);
if ($table != 'pages') {
foreach ($recs as $uid => $thisRec) {
// PID: Set the main $pid, unless a NEW-id is found
......@@ -3463,12 +3466,7 @@ class ImportExport {
*/
public function traverseAllRecords($pT, &$lines) {
foreach ($pT as $t => $recUidArr) {
if ($this->update && $t === 'sys_file') {
$this->error('Updating sys_file records is not supported! They will be imported as new records!');
}
if ($this->force_all_UIDS && $t === 'sys_file') {
$this->error('Forcing uids of sys_file records is not supported! They will be imported as new records!');
}
$this->addGeneralErrorsByTable($t);
if ($t != 'pages') {
$preCode = '';
foreach ($recUidArr as $ruid => $value) {
......@@ -3478,6 +3476,21 @@ class ImportExport {
}
}
/**
* Log general error message for a given table
*
* @param string $table database table name
* @return void
*/
protected function addGeneralErrorsByTable($table) {
if ($this->update && $table === 'sys_file') {
$this->error('Updating sys_file records is not supported! They will be imported as new records!');
}
if ($this->force_all_UIDS && $table === 'sys_file') {
$this->error('Forcing uids of sys_file records is not supported! They will be imported as new records!');
}
}
/**
* Add entries for a single record
*
......
"pages"
,"uid","pid","sorting","deleted","title"
,5,0,256,0,"Root"
,8,5,256,0,"Dummy 1-2"
"tt_content"
,"uid","pid","sorting","deleted","header","header_link","image"
,21,8,256,0,"Test content","file:1",1
"sys_file_storage"
,"uid","pid","name","driver"
,1,0,"fileadmin/ (auto-created)","Local"
"sys_file"
,"uid","pid","storage","type","identifier","identifier_hash","folder_hash","extension","mime_type","name","sha1","size"
,1,0,1,2,"/user_upload/typo3_image2.jpg","f90bb9a35622f35b5279195e324eddbaec8164b2","19669f1e02c2f16705ec7587044c66443be70725","jpg","image/jpeg","typo3_image2.jpg","da9acdf1e105784a57bbffec9520969578287797","7958"
"sys_file_reference"
,"uid","pid","uid_local","uid_foreign","tablenames","fieldname","table_local","title","description","alternative","link"
,101,8,1,21,"tt_content","image","sys_file",\NULL,\NULL,\NULL,""
"sys_file_metadata"
,"uid","pid","file","title","width","height","description","alternative"
,1,0,1,Dummy image,400,300,"This is a dummy image.","Photo of program code"
......@@ -118,5 +118,24 @@ class ImportInEmptyDatabaseTest extends \TYPO3\CMS\Impexp\Tests\Functional\Impor
$this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
}
/**
* @test
*/
public function importPagesAndRelatedTtContentWithImageWithForcedUids() {
$this->import->loadFile(__DIR__ . '/ImportExportXml/pages-and-ttcontent-with-image-with-forced-uids.xml', 1);
$this->import->force_all_UIDS = TRUE;
$this->import->importData(0);
$this->assertAssertionDataSet('importPagesAndRelatedTtContentWithImageWithForcedUids');
$this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
$expectedErrors = array(
'Forcing uids of sys_file records is not supported! They will be imported as new records!'
);
$errors = $this->import->errorLog;
$this->assertSame($expectedErrors, $errors);
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment