Reflect TYPO3 behaviour in tests

TYPO3 scheduler tasks always have a value for console commands.
Region uid will be an empty string if omitted within scheduler task.
We reflect that in our tests and adapt code to not break.
Furthermore tests call only with strings, as that's what TYPO3 does.
This commit is contained in:
Daniel Siepmann 2021-12-16 14:34:17 +01:00
parent 6aa4681cb9
commit a8c475fbd7
5 changed files with 15 additions and 7 deletions

View file

@ -54,10 +54,17 @@ class DestinationDataImportCommand extends Command
{ {
Bootstrap::initializeBackendAuthentication(); Bootstrap::initializeBackendAuthentication();
$regionUid = $input->getArgument('region-uid');
if (is_numeric($regionUid)) {
$regionUid = (int) $regionUid;
} else {
$regionUid = null;
}
return $this->destinationDataImportService->import( return $this->destinationDataImportService->import(
$input->getArgument('rest-experience'), $input->getArgument('rest-experience'),
$input->getArgument('storage-pid'), $input->getArgument('storage-pid'),
$input->getArgument('region-uid'), $regionUid,
$input->getArgument('files-folder') $input->getArgument('files-folder')
); );
} }

View file

@ -35,7 +35,7 @@ class ImportCleansTransientFilesTest extends AbstractTest
]); ]);
$tester = $this->executeCommand([ $tester = $this->executeCommand([
'storage-pid' => 2, 'storage-pid' => '2',
'rest-experience' => 'beispielstadt', 'rest-experience' => 'beispielstadt',
'files-folder' => $fileImportPath, 'files-folder' => $fileImportPath,
]); ]);

View file

@ -36,7 +36,7 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTest
]); ]);
$tester = $this->executeCommand([ $tester = $this->executeCommand([
'storage-pid' => 2, 'storage-pid' => '2',
'rest-experience' => 'beispielstadt', 'rest-experience' => 'beispielstadt',
'files-folder' => $fileImportPath, 'files-folder' => $fileImportPath,
]); ]);

View file

@ -36,10 +36,10 @@ class ImportsExampleAsExpectedTest extends AbstractTest
]); ]);
$tester = $this->executeCommand([ $tester = $this->executeCommand([
'storage-pid' => 2, 'storage-pid' => '2',
'rest-experience' => 'beispielstadt', 'rest-experience' => 'beispielstadt',
'files-folder' => $fileImportPath, 'files-folder' => $fileImportPath,
'region-uid' => 1, 'region-uid' => '1',
]); ]);
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());

View file

@ -8,7 +8,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* @testdox DestinationData import * @testdox DestinationData import
*/ */
class ImportsWithoutRegionIfNotProvided extends AbstractTest class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest
{ {
/** /**
* @test * @test
@ -33,9 +33,10 @@ class ImportsWithoutRegionIfNotProvided extends AbstractTest
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''),
]); ]);
$tester = $this->executeCommand([ $tester = $this->executeCommand([
'storage-pid' => 2, 'storage-pid' => '2',
'rest-experience' => 'beispielstadt', 'rest-experience' => 'beispielstadt',
'files-folder' => $fileImportPath, 'files-folder' => $fileImportPath,
'region-uid' => '',
]); ]);
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());