Migrate TypoScript import settings

Those are now part of the import, or hard coded.

Resolves: #11483
This commit is contained in:
Daniel Siepmann (Codappix) 2024-11-04 14:30:18 +01:00
parent 578751d156
commit a07c16b723
SSH key fingerprint: SHA256:nAjx3Dpp8kuAC+S7QXj8BWmqw+KI1Miu+5e40BP3LXA
51 changed files with 260 additions and 468 deletions

View file

@ -21,13 +21,17 @@ class Import extends AbstractDomainObject
public function __construct( public function __construct(
protected Folder $filesFolder, protected Folder $filesFolder,
protected int $storagePid, protected int $storagePid,
protected string $restLicenseKey,
protected string $restExperience, protected string $restExperience,
protected string $restMode = 'next_months,12',
protected int $restLimit = 500,
protected string $restSearchQuery = '', protected string $restSearchQuery = '',
int $categoriesPid = 0, int $categoriesPid = 0,
protected ?Category $categoryParent = null, protected ?Category $categoryParent = null,
int $featuresPid = 0, int $featuresPid = 0,
protected ?Category $featuresParent = null, protected ?Category $featuresParent = null,
protected ?Region $region = null, protected ?Region $region = null,
protected string $importRepeatUntil = '+60 days',
protected int $importFeatures = 0, protected int $importFeatures = 0,
) { ) {
// Do not allow categories on pid 0 // Do not allow categories on pid 0
@ -78,18 +82,38 @@ class Import extends AbstractDomainObject
return $this->region; return $this->region;
} }
public function getFeatures(): Features
{
return new Features($this->importFeatures);
}
public function getRepeatUntil(): string
{
return $this->importRepeatUntil;
}
public function getRestLicenseKey(): string
{
return $this->restLicenseKey;
}
public function getRestExperience(): string public function getRestExperience(): string
{ {
return $this->restExperience; return $this->restExperience;
} }
public function getSearchQuery(): string public function getRestMode(): string
{
return $this->restMode;
}
public function getRestLimit(): int
{
return (int)$this->restLimit;
}
public function getRestSearchQuery(): string
{ {
return $this->restSearchQuery; return $this->restSearchQuery;
} }
public function getFeatures(): Features
{
return new Features($this->importFeatures);
}
} }

View file

@ -254,7 +254,7 @@ final class DestinationDataImportService
$this->dateRepository->remove($currentDate); $this->dateRepository->remove($currentDate);
} }
$dates = $this->datesFactory->createDates($timeIntervals, $canceled); $dates = $this->datesFactory->createDates($this->import, $timeIntervals, $canceled);
foreach ($dates as $date) { foreach ($dates as $date) {
$this->tmpCurrentEvent->addDate($date); $this->tmpCurrentEvent->addDate($date);
} }

View file

@ -1,43 +0,0 @@
<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Service\DestinationDataImportService;
final class ArrayBasedConfigurationService implements ConfigurationServiceInterface
{
public function __construct(
private readonly array $settings
) {
}
public function getLicenseKey(): string
{
return $this->settings['license'] ?? '';
}
public function getRestType(): string
{
return $this->settings['restType'] ?? '';
}
public function getRestMode(): string
{
return $this->settings['restMode'] ?? '';
}
public function getRestLimit(): string
{
return $this->settings['restLimit'] ?? '';
}
public function getRestTemplate(): string
{
return $this->settings['restTemplate'] ?? '';
}
public function getRestUrl(): string
{
return $this->settings['restUrl'] ?? '';
}
}

View file

@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Service\DestinationDataImportService;
interface ConfigurationServiceInterface
{
public function getLicenseKey(): string;
public function getRestType(): string;
public function getRestMode(): string;
public function getRestLimit(): string;
public function getRestTemplate(): string;
public function getRestUrl(): string;
}

View file

@ -12,8 +12,8 @@ use Generator;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use WerkraumMedia\Events\Domain\Model\Date; use WerkraumMedia\Events\Domain\Model\Date;
use WerkraumMedia\Events\Domain\Model\Import;
final class DatesFactory final class DatesFactory
{ {
@ -21,7 +21,6 @@ final class DatesFactory
public function __construct( public function __construct(
private readonly Context $context, private readonly Context $context,
private readonly ConfigurationManager $configurationManager,
LogManager $logManager LogManager $logManager
) { ) {
$this->logger = $logManager->getLogger(self::class); $this->logger = $logManager->getLogger(self::class);
@ -31,11 +30,12 @@ final class DatesFactory
* @return Generator<Date> * @return Generator<Date>
*/ */
public function createDates( public function createDates(
Import $import,
array $timeIntervals, array $timeIntervals,
bool $canceled bool $canceled
): Generator { ): Generator {
foreach ($timeIntervals as $date) { foreach ($timeIntervals as $date) {
$dates = $this->createDate($date, $canceled); $dates = $this->createDate($import, $date, $canceled);
if (!$dates instanceof Generator) { if (!$dates instanceof Generator) {
return null; return null;
} }
@ -50,6 +50,7 @@ final class DatesFactory
* @return Generator<Date>|null * @return Generator<Date>|null
*/ */
private function createDate( private function createDate(
Import $import,
array $date, array $date,
bool $canceled bool $canceled
): ?Generator { ): ?Generator {
@ -60,7 +61,7 @@ final class DatesFactory
if ($this->isDateInterval($date)) { if ($this->isDateInterval($date)) {
$this->logger->info('Is interval date', ['date' => $date]); $this->logger->info('Is interval date', ['date' => $date]);
return $this->createDateFromInterval($date, $canceled); return $this->createDateFromInterval($import, $date, $canceled);
} }
return null; return null;
@ -106,10 +107,11 @@ final class DatesFactory
* @return Generator<Date>|null * @return Generator<Date>|null
*/ */
private function createDateFromInterval( private function createDateFromInterval(
Import $import,
array $date, array $date,
bool $canceled bool $canceled
): ?Generator { ): ?Generator {
$date = $this->ensureRepeatUntil($date); $date = $this->ensureRepeatUntil($import, $date);
if ($date['freq'] == 'Daily') { if ($date['freq'] == 'Daily') {
return $this->createDailyDates($date, $canceled); return $this->createDailyDates($date, $canceled);
@ -122,19 +124,15 @@ final class DatesFactory
return null; return null;
} }
private function ensureRepeatUntil(array $date): array private function ensureRepeatUntil(
{ Import $import,
array $date
): array {
if (empty($date['repeatUntil']) === false) { if (empty($date['repeatUntil']) === false) {
return $date; return $date;
} }
$settings = $this->configurationManager->getConfiguration( $date['repeatUntil'] = $this->getToday()->modify($import->getRepeatUntil())->format('c');
ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
'Events',
'Import'
);
$configuredModification = $settings['repeatUntil'] ?? '+60 days';
$date['repeatUntil'] = $this->getToday()->modify($configuredModification)->format('c');
$this->logger->info('Interval did not provide repeatUntil.', ['newRepeat' => $date['repeatUntil']]); $this->logger->info('Interval did not provide repeatUntil.', ['newRepeat' => $date['repeatUntil']]);
return $date; return $date;

View file

@ -1,66 +0,0 @@
<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Service\DestinationDataImportService;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use WerkraumMedia\Events\Service\ExtbaseConfigurationManagerService;
final class ExtbaseConfigurationService implements ConfigurationServiceInterface
{
private array $settings = [];
public function __construct(
private ExtbaseConfigurationManagerService $configurationManager
) {
}
public function getLicenseKey(): string
{
return $this->getSettings()['license'] ?? '';
}
public function getRestType(): string
{
return $this->getSettings()['restType'] ?? '';
}
public function getRestMode(): string
{
return $this->getSettings()['restMode'] ?? '';
}
public function getRestLimit(): string
{
return $this->getSettings()['restLimit'] ?? '';
}
public function getRestTemplate(): string
{
return $this->getSettings()['restTemplate'] ?? '';
}
public function getRestUrl(): string
{
return $this->getSettings()['restUrl'] ?? '';
}
private function getSettings(): array
{
if ($this->settings !== []) {
return $this->settings;
}
$fullTypoScript = $this->configurationManager
->getInstanceWithBackendContext()
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
;
$this->settings = $fullTypoScript['module.']['tx_events.']['settings.']['destinationData.']
?? $fullTypoScript['module.']['tx_events_pi1.']['settings.']['destinationData.']
?? [];
return $this->settings;
}
}

View file

@ -12,11 +12,6 @@ use WerkraumMedia\Events\Domain\Model\Import;
*/ */
final class UrlFactory final class UrlFactory
{ {
public function __construct(
private readonly ConfigurationServiceInterface $configuration,
) {
}
/** /**
* URL used to fetch initial set of data. * URL used to fetch initial set of data.
*/ */
@ -25,17 +20,17 @@ final class UrlFactory
): string { ): string {
$parameter = [ $parameter = [
'experience' => $import->getRestExperience(), 'experience' => $import->getRestExperience(),
'licensekey' => $this->configuration->getLicenseKey(), 'licensekey' => $import->getRestLicenseKey(),
'type' => $this->configuration->getRestType(), 'type' => 'Event',
'mode' => $this->configuration->getRestMode(), 'mode' => $import->getRestMode(),
'limit' => $this->configuration->getRestLimit(), 'limit' => $import->getRestLimit(),
'template' => $this->configuration->getRestTemplate(), 'template' => 'ET2014A.json',
'q' => $import->getSearchQuery(), 'q' => $import->getRestSearchQuery(),
]; ];
$parameter = array_filter($parameter); $parameter = array_filter($parameter);
$url = new Uri($this->configuration->getRestUrl()); $url = new Uri('http://meta.et4.de/rest.ashx/search/');
$url = $url->withQuery(http_build_query($parameter)); $url = $url->withQuery(http_build_query($parameter));
return (string)$url; return (string)$url;
} }

View file

@ -43,9 +43,6 @@ services:
WerkraumMedia\Events\Updates\MigrateOldLocations: WerkraumMedia\Events\Updates\MigrateOldLocations:
public: true public: true
WerkraumMedia\Events\Service\DestinationDataImportService\ConfigurationServiceInterface:
alias: 'WerkraumMedia\Events\Service\DestinationDataImportService\ExtbaseConfigurationService'
WerkraumMedia\Events\Caching\PageCacheTimeout: WerkraumMedia\Events\Caching\PageCacheTimeout:
arguments: arguments:
'$runtimeCache': '@cache.runtime' '$runtimeCache': '@cache.runtime'

View file

@ -28,9 +28,13 @@ return [
'--palette--;;features', '--palette--;;features',
'--palette--;;relations', '--palette--;;relations',
'--div--;LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.div.rest', '--div--;LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.div.rest',
'rest_license_key',
'rest_experience', 'rest_experience',
'rest_mode',
'rest_limit',
'rest_search_query', 'rest_search_query',
'--div--;LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.div.import', '--div--;LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.div.import',
'import_repeat_until',
'import_features', 'import_features',
]), ]),
], ],
@ -162,16 +166,53 @@ return [
], ],
], ],
'rest_license_key' => [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_license_key',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_license_key.description',
'config' => [
'type' => 'input',
'size' => 50,
],
],
'rest_experience' => [ 'rest_experience' => [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_experience', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_experience',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_experience.description', 'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_experience.description',
'config' => [ 'config' => [
'type' => 'input', 'type' => 'input',
'required' => true,
'size' => 50, 'size' => 50,
'max' => 255, 'max' => 255,
], ],
], ],
'rest_mode' => [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_mode',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_mode.description',
'config' => [
'type' => 'input',
'default' => 'next_months,12',
'size' => 50,
'max' => 255,
],
],
'rest_limit' => [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_limit',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_limit.description',
'config' => [
'type' => 'number',
'format' => 'integer',
'default' => '500',
'size' => 50,
'required' => true,
'range' => [
'lower' => 0,
'upper' => 5000,
],
],
],
'rest_search_query' => [ 'rest_search_query' => [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_search_query', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.rest_search_query',
@ -181,6 +222,18 @@ return [
'size' => 50, 'size' => 50,
], ],
], ],
'import_repeat_until' => [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.import_repeat_until',
'description' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.import_repeat_until.description',
'config' => [
'type' => 'input',
'default' => '+60 days',
'size' => 50,
'max' => 255,
],
],
'import_features' => [ 'import_features' => [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.import_features', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_csh_import.xlf:tx_events_domain_model_import.import_features',

View file

@ -15,23 +15,5 @@ plugin.tx_events {
settings { settings {
# cat=plugin.tx_events//a; type=string; label=Default Image # cat=plugin.tx_events//a; type=string; label=Default Image
defaultImagePath = EXT:events/Resources/Public/Images/default.jpg defaultImagePath = EXT:events/Resources/Public/Images/default.jpg
destinationData {
# cat=plugin.tx_events//a; type=string; label=Rest Url
restUrl = http://meta.et4.de/rest.ashx/search/
# cat=plugin.tx_events//a; type=string; label=License
license =
# cat=plugin.tx_events//a; type=string; label=Data Type
restType = Event
# cat=plugin.tx_events//a; type=string; label=Data Limit
restLimit = 500
# cat=plugin.tx_events//a; type=string; label=Mode
restMode = next_months,12
# cat=plugin.tx_events//a; type=string; label=Data Template
restTemplate = ET2014A.json
# cat=plugin.tx_events//a; type=string; Label=Category Storage
categoriesPid = 54
# cat=plugin.tx_events//a; type=string; Label=Category Parent ID
categoryParentUid = 6
}
} }
} }

View file

@ -42,17 +42,6 @@ plugin.tx_events {
maximumNumberOfLinks = 10 maximumNumberOfLinks = 10
} }
destinationData {
restUrl = {$plugin.tx_events.settings.destinationData.restUrl}
license = {$plugin.tx_events.settings.destinationData.license}
restType = {$plugin.tx_events.settings.destinationData.restType}
restLimit = {$plugin.tx_events.settings.destinationData.restLimit}
restMode = {$plugin.tx_events.settings.destinationData.restMode}
restTemplate = {$plugin.tx_events.settings.destinationData.restTemplate}
categoriesPid = {$plugin.tx_events.settings.destinationData.categoriesPid}
categoryParentUid = {$plugin.tx_events.settings.destinationData.categoryParentUid}
}
dataProcessing { dataProcessing {
WerkraumMedia\Events\Domain\Model\Event { WerkraumMedia\Events\Domain\Model\Event {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor 10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor

View file

@ -14,12 +14,23 @@ Breaking
We recommend not to use the provided plugins but build your own tailored content We recommend not to use the provided plugins but build your own tailored content
elements instead. elements instead.
* Remaining TypoScript constants for import were moved.
Those are now part of the import configuration record.
The previous default values will be inserted.
Make sure to update the existing records to include the necessary values.
Some value are now hard coded as we do not support other values anyway.
This also affects the `repeatUntil` TypoScript setting which is now moved to the import configuration.
Features Features
-------- --------
* Add Support for TYPO3 v13.4 LTS. * Add Support for TYPO3 v13.4 LTS.
* Support large rest search queries. * Support large rest search queries.
The field no longer has a limitation. The field no longer has a limitation.
The field is now stored as text instead of varchar. The field is now stored as text instead of varchar.

View file

@ -72,17 +72,41 @@
<trans-unit id="tx_events_domain_model_import.files_folder.description"> <trans-unit id="tx_events_domain_model_import.files_folder.description">
<source>TYPO3 folder to use for storing imported files.</source> <source>TYPO3 folder to use for storing imported files.</source>
</trans-unit> </trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_license_key">
<source>License Key</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_license_key.description">
<source>See: https://developer.et4.de/reference/current/#eT4META-search-param-licensekey.html</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_experience"> <trans-unit id="tx_events_domain_model_import.rest_experience">
<source>Experience</source> <source>Experience</source>
</trans-unit> </trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_experience.description"> <trans-unit id="tx_events_domain_model_import.rest_experience.description">
<source>See: https://developer.et4.de/reference/current/#eT4META-search-param-experience.html (todo check, was not loadable)</source> <source>See: https://developer.et4.de/reference/current/#eT4META-search-param-experience.html</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_mode">
<source>Mode</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_mode.description">
<source>See: https://developer.et4.de/reference/current/#eT4META-search-param-mode.html</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_limit">
<source>Limit</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_limit.description">
<source>See: https://developer.et4.de/reference/current/#eT4META-search-param-limit.html</source>
</trans-unit> </trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_search_query"> <trans-unit id="tx_events_domain_model_import.rest_search_query">
<source>Search Query</source> <source>Search Query</source>
</trans-unit> </trans-unit>
<trans-unit id="tx_events_domain_model_import.rest_search_query.description"> <trans-unit id="tx_events_domain_model_import.rest_search_query.description">
<source>See: https://developer.et4.de/reference/current/#eT4META-search-param-q.html (todo check, was not loadable)</source> <source>See: https://developer.et4.de/reference/current/#eT4META-search-param-q.html</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.import_repeat_until">
<source>Repeat events until</source>
</trans-unit>
<trans-unit id="tx_events_domain_model_import.import_repeat_until.description">
<source>Some events will repeat. This will define how many dates will be created. See: https://www.php.net/manual/en/datetimeimmutable.modify.php</source>
</trans-unit> </trans-unit>
<trans-unit id="tx_events_domain_model_import.import_features"> <trans-unit id="tx_events_domain_model_import.import_features">
<source>Import Features</source> <source>Import Features</source>

View file

@ -114,22 +114,6 @@ abstract class AbstractFunctionalTestCase extends FunctionalTestCase
return new TypoScriptInstruction(); return new TypoScriptInstruction();
} }
protected function setUpConfiguration(
array $destinationDataSettings,
array $importSettings = []
): void {
$this->setUpFrontendRootPage(1, [], [
'config' => implode(PHP_EOL, [
'module.tx_events_pi1.settings.destinationData {',
implode(PHP_EOL, $destinationDataSettings),
'}',
'module.tx_events_import.settings {',
implode(PHP_EOL, $importSettings),
'}',
]),
]);
}
protected function &setUpResponses(array $responses): array protected function &setUpResponses(array $responses): array
{ {
$requests = []; $requests = [];

View file

@ -269,14 +269,6 @@ class CacheTest extends AbstractFunctionalTestCase
// Import // Import
$this->importPHPDataSet(__DIR__ . '/../Import/DestinationDataTest/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/../Import/DestinationDataTest/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$this->setUpResponses([ $this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/../Import/DestinationDataTest/Fixtures/ResponseWithSingleImageForSingleEvent.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/../Import/DestinationDataTest/Fixtures/ResponseWithSingleImageForSingleEvent.json') ?: ''),
new Response(200, [], file_get_contents(__DIR__ . '/../Import/DestinationDataTest/Fixtures/ExampleImage.jpg') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/../Import/DestinationDataTest/Fixtures/ExampleImage.jpg') ?: ''),

View file

@ -12,6 +12,9 @@ return [
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
]; ];

View file

@ -12,6 +12,10 @@ return [
'features_pid' => '3', 'features_pid' => '3',
'features_parent' => '4', 'features_parent' => '4',
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
'pages' => [ 'pages' => [

View file

@ -10,6 +10,10 @@ return [
'title' => 'Example for test', 'title' => 'Example for test',
'storage_pid' => '2', 'storage_pid' => '2',
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
'pages' => [ 'pages' => [

View file

@ -12,6 +12,9 @@ return [
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
'import_features' => '1', 'import_features' => '1',
], ],
], ],

View file

@ -10,6 +10,9 @@ return [
'title' => 'Example import configuration', 'title' => 'Example import configuration',
'storage_pid' => '2', 'storage_pid' => '2',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
], ],
], ],

View file

@ -14,6 +14,9 @@ return [
'category_parent' => '2', 'category_parent' => '2',
'region' => '1', 'region' => '1',
'rest_experience' => 'anderestadt', 'rest_experience' => 'anderestadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
'rest_search_query' => 'name:"Beispiel2"', 'rest_search_query' => 'name:"Beispiel2"',
], ],
], ],

View file

@ -14,6 +14,9 @@ return [
'category_parent' => '2', 'category_parent' => '2',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
'rest_search_query' => 'name:"Beispiel"', 'rest_search_query' => 'name:"Beispiel"',
], ],
], ],

View file

@ -14,6 +14,9 @@ return [
'category_parent' => '2', 'category_parent' => '2',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
]; ];

View file

@ -11,6 +11,9 @@ return [
'storage_pid' => '2', 'storage_pid' => '2',
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
]; ];

View file

@ -17,14 +17,6 @@ class ImportCleansTransientFilesTest extends AbstractTestCase
public function cleansTransientFiles(): void public function cleansTransientFiles(): void
{ {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -38,7 +30,7 @@ class ImportCleansTransientFilesTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.'); self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());

View file

@ -17,14 +17,6 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTestCase
public function doesNotUseUploadsFolder(): void public function doesNotUseUploadsFolder(): void
{ {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -37,7 +29,7 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.'); self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());

View file

@ -15,14 +15,6 @@ class ImportDoesntBreakWithLongFileTitleTest extends AbstractTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithCategories.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithCategories.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithVeryLongFileName.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithVeryLongFileName.json') ?: ''),

View file

@ -17,14 +17,6 @@ class ImportDoesntEndUpInEndlessDateCreationTest extends AbstractTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithPotentiellyEndlessDateCreation.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithPotentiellyEndlessDateCreation.json') ?: ''),

View file

@ -21,14 +21,6 @@ class ImportHandlesImagesTest extends AbstractTestCase
parent::setUp(); parent::setUp();
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
} }
#[Test] #[Test]

View file

@ -17,14 +17,6 @@ class ImportHandlesPricesTest extends AbstractTestCase
parent::setUp(); parent::setUp();
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
} }
#[Test] #[Test]

View file

@ -28,14 +28,6 @@ class ImportsAllConfigurationTest extends AbstractTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfiguration.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SecondImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SecondImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restTemplate = ET2014A.json',
'restLimit = 3',
'restMode = next_months,12',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -54,12 +46,12 @@ class ImportsAllConfigurationTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(8, $requests, 'Unexpected number of requests were made.'); self::assertCount(8, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel%22', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel%22', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());
self::assertSame('https://example.com/some-path/?experience=anderestadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel2%22', (string)$requests[4]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel%22', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[5]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[5]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[6]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[6]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[7]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[7]['request']->getUri());

View file

@ -14,20 +14,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
#[TestDox('DestinationData import')] #[TestDox('DestinationData import')]
class ImportsExampleAsExpectedTest extends AbstractTestCase class ImportsExampleAsExpectedTest extends AbstractTestCase
{ {
protected function setUp(): void
{
parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
}
#[Test] #[Test]
public function importsExampleAsExpected(): void public function importsExampleAsExpected(): void
{ {
@ -49,7 +35,7 @@ class ImportsExampleAsExpectedTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.'); self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());

View file

@ -14,9 +14,6 @@ class ImportsFeaturesTest extends AbstractTestCase
#[Test] #[Test]
public function addsNewFeatures(): void public function addsNewFeatures(): void
{ {
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
]);
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FeaturesImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FeaturesImportConfiguration.php');
$this->setUpResponses([ $this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithFeatures.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithFeatures.json') ?: ''),
@ -30,9 +27,6 @@ class ImportsFeaturesTest extends AbstractTestCase
#[Test] #[Test]
public function addsNewFeaturesToExistingOnes(): void public function addsNewFeaturesToExistingOnes(): void
{ {
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
]);
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FeaturesImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FeaturesImportConfiguration.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ExistingFeatures.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ExistingFeatures.php');
$this->setUpResponses([ $this->setUpResponses([

View file

@ -17,9 +17,6 @@ class ImportsFirstDateOfDatesTest extends AbstractTestCase
{ {
parent::setUp(); parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
]);
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FirstDateOfRecurringDatesImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/FirstDateOfRecurringDatesImportConfiguration.php');
$this->setDateAspect(new DateTimeImmutable('2022-07-13', new DateTimeZone('UTC'))); $this->setDateAspect(new DateTimeImmutable('2022-07-13', new DateTimeZone('UTC')));
} }

View file

@ -22,14 +22,6 @@ class ImportsSingleConfigurationTest extends AbstractTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restTemplate = ET2014A.json',
'restLimit = 3',
'restMode = next_months,12',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -43,7 +35,7 @@ class ImportsSingleConfigurationTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.'); self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel%22', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json&q=name%3A%22Beispiel%22', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri()); self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());

View file

@ -12,20 +12,6 @@ use PHPUnit\Framework\Attributes\TestDox;
#[TestDox('DestinationData import')] #[TestDox('DestinationData import')]
class ImportsTextsTest extends AbstractTestCase class ImportsTextsTest extends AbstractTestCase
{ {
protected function setUp(): void
{
parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
}
protected function tearDown(): void protected function tearDown(): void
{ {
$this->assertEmptyLog(); $this->assertEmptyLog();

View file

@ -21,14 +21,6 @@ class ImportsTicketsTest extends AbstractTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithTickets.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithTickets.json') ?: ''),
@ -39,7 +31,7 @@ class ImportsTicketsTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(1, $requests, 'Unexpected number of requests were made.'); self::assertCount(1, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri()); self::assertSame('http://meta.et4.de/rest.ashx/search/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
$this->assertPHPDataSet(__DIR__ . '/Assertions/ImportsTickets.php'); $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportsTickets.php');

View file

@ -24,11 +24,14 @@ class ImportsWithConfiguredRepeatUntilTest extends AbstractTestCase
#[Test] #[Test]
public function recurringWeekly(): void public function recurringWeekly(): void
{ {
$this->setUpConfiguration([ $this->getConnectionPool()
'restUrl = https://example.com/some-path/', ->getConnectionForTable('tx_events_domain_model_import')
], [ ->update(
'repeatUntil = +30 days', 'tx_events_domain_model_import',
]); ['import_repeat_until' => '+30 days'],
['uid' => '1']
)
;
$this->setUpResponses([new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithRecurringWeeklyWithoutRepeatUntil.json') ?: '')]); $this->setUpResponses([new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithRecurringWeeklyWithoutRepeatUntil.json') ?: '')]);
$this->executeCommand(); $this->executeCommand();
@ -40,11 +43,14 @@ class ImportsWithConfiguredRepeatUntilTest extends AbstractTestCase
#[Test] #[Test]
public function recurringDaily(): void public function recurringDaily(): void
{ {
$this->setUpConfiguration([ $this->getConnectionPool()
'restUrl = https://example.com/some-path/', ->getConnectionForTable('tx_events_domain_model_import')
], [ ->update(
'repeatUntil = +10 days', 'tx_events_domain_model_import',
]); ['import_repeat_until' => '+10 days'],
['uid' => '1']
)
;
$this->setUpResponses([new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithRecurringDailyWithoutRepeatUntil.json') ?: '')]); $this->setUpResponses([new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithRecurringDailyWithoutRepeatUntil.json') ?: '')]);
$this->executeCommand(); $this->executeCommand();

View file

@ -16,14 +16,6 @@ final class ImportsWithLocationsTest extends AbstractTestCase
parent::setUp(); parent::setUp();
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
} }
#[Test] #[Test]

View file

@ -24,9 +24,6 @@ class ImportsWithSystemConfiguredTimeZoneTest extends AbstractTestCase
parent::setUp(); parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
]);
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->setDateAspect(new DateTimeImmutable('2022-07-13', new DateTimeZone('UTC'))); $this->setDateAspect(new DateTimeImmutable('2022-07-13', new DateTimeZone('UTC')));
} }

View file

@ -17,14 +17,6 @@ class ImportsWithoutCategoryIfNotProvidedTest extends AbstractTestCase
{ {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -37,12 +29,6 @@ class ImportsWithoutCategoryIfNotProvidedTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());
self::assertCount( self::assertCount(
0, 0,
$this->getAllRecords('tx_events_domain_model_partner'), $this->getAllRecords('tx_events_domain_model_partner'),

View file

@ -15,14 +15,6 @@ class ImportsWithoutLocationTest extends AbstractTestCase
public function importsWithoutLocationIfNotProvided(): void public function importsWithoutLocationIfNotProvided(): void
{ {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithoutLocation.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithoutLocation.json') ?: ''),

View file

@ -17,14 +17,6 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTestCase
{ {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php');
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
$requests = &$this->setUpResponses([ $requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''), new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Response.json') ?: ''),
@ -36,12 +28,6 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTestCase
self::assertSame(0, $tester->getStatusCode()); self::assertSame(0, $tester->getStatusCode());
self::assertCount(4, $requests, 'Unexpected number of requests were made.');
self::assertSame('https://example.com/some-path/?experience=beispielstadt&licensekey=example-license&type=Event&mode=next_months%2C12&limit=3&template=ET2014A.json', (string)$requests[0]['request']->getUri());
self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[1]['request']->getUri());
self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri());
self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri());
self::assertCount( self::assertCount(
0, 0,
$this->getAllRecords('tx_events_domain_model_partner'), $this->getAllRecords('tx_events_domain_model_partner'),

View file

@ -34,15 +34,6 @@ final class CategoriesAssignEventTest extends AbstractTestCase
$this->testExtensionsToLoad[] = 'typo3conf/ext/events/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_categories/'; $this->testExtensionsToLoad[] = 'typo3conf/ext/events/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_categories/';
parent::setUp(); parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
} }
#[Test] #[Test]

View file

@ -34,15 +34,6 @@ final class EventImportEventTest extends AbstractTestCase
$this->testExtensionsToLoad[] = 'typo3conf/ext/events/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event'; $this->testExtensionsToLoad[] = 'typo3conf/ext/events/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event';
parent::setUp(); parent::setUp();
$this->setUpConfiguration([
'restUrl = https://example.com/some-path/',
'license = example-license',
'restType = Event',
'restLimit = 3',
'restMode = next_months,12',
'restTemplate = ET2014A.json',
]);
} }
#[Test] #[Test]

View file

@ -12,6 +12,9 @@ return [
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
'categories_pid' => 2, 'categories_pid' => 2,
'category_parent' => 2, 'category_parent' => 2,
], ],

View file

@ -12,6 +12,9 @@ return [
'files_folder' => '1:/staedte/beispielstadt/events/', 'files_folder' => '1:/staedte/beispielstadt/events/',
'region' => '1', 'region' => '1',
'rest_experience' => 'beispielstadt', 'rest_experience' => 'beispielstadt',
'rest_license_key' => 'example-license',
'rest_limit' => '3',
'rest_mode' => 'next_months,12',
], ],
], ],
]; ];

View file

@ -21,7 +21,8 @@ class ImportTest extends TestCase
$subject = new Import( $subject = new Import(
$folder, $folder,
0, 0,
'' '',
'',
); );
self::assertInstanceOf( self::assertInstanceOf(
@ -38,7 +39,8 @@ class ImportTest extends TestCase
$subject = new Import( $subject = new Import(
$folder, $folder,
0, 0,
'experience' '',
'experience',
); );
self::assertSame( self::assertSame(
@ -55,7 +57,8 @@ class ImportTest extends TestCase
$subject = new Import( $subject = new Import(
$folder, $folder,
20, 20,
'' '',
'',
); );
self::assertSame( self::assertSame(
@ -75,6 +78,9 @@ class ImportTest extends TestCase
0, 0,
'', '',
'', '',
'next_months,12',
500,
'',
0, 0,
null, null,
0, 0,
@ -96,7 +102,8 @@ class ImportTest extends TestCase
$subject = new Import( $subject = new Import(
$folder, $folder,
0, 0,
'' '',
'',
); );
self::assertSame( self::assertSame(
@ -115,6 +122,9 @@ class ImportTest extends TestCase
0, 0,
'', '',
'', '',
'next_months,12',
500,
'',
10 10
); );
@ -135,6 +145,9 @@ class ImportTest extends TestCase
0, 0,
'', '',
'', '',
'next_months,12',
500,
'',
0, 0,
$category $category
); );
@ -155,6 +168,9 @@ class ImportTest extends TestCase
0, 0,
'', '',
'', '',
'next_months,12',
500,
'',
0, 0,
null, null,
10 10
@ -177,6 +193,9 @@ class ImportTest extends TestCase
0, 0,
'', '',
'', '',
'next_months,12',
500,
'',
0, 0,
null, null,
0, 0,
@ -198,12 +217,15 @@ class ImportTest extends TestCase
$folder, $folder,
0, 0,
'', '',
'',
'next_months,12',
500,
'name:"Test"' 'name:"Test"'
); );
self::assertSame( self::assertSame(
'name:"Test"', 'name:"Test"',
$subject->getSearchQuery() $subject->getRestSearchQuery()
); );
} }
} }

View file

@ -13,8 +13,8 @@ use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\DateTimeAspect; use TYPO3\CMS\Core\Context\DateTimeAspect;
use TYPO3\CMS\Core\Log\Logger; use TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use WerkraumMedia\Events\Domain\Model\Date; use WerkraumMedia\Events\Domain\Model\Date;
use WerkraumMedia\Events\Domain\Model\Import;
use WerkraumMedia\Events\Service\DestinationDataImportService\DatesFactory; use WerkraumMedia\Events\Service\DestinationDataImportService\DatesFactory;
class DatesFactoryTest extends TestCase class DatesFactoryTest extends TestCase
@ -28,7 +28,6 @@ class DatesFactoryTest extends TestCase
return new DatesFactory( return new DatesFactory(
$this->createContext(new DateTimeImmutable($contextDate)), $this->createContext(new DateTimeImmutable($contextDate)),
$this->createStub(ConfigurationManager::class),
$logManager $logManager
); );
} }
@ -50,7 +49,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates($unkownInput, false); $result = $subject->createDates($this->createStub(Import::class), $unkownInput, false);
self::assertInstanceOf(Generator::class, $result); self::assertInstanceOf(Generator::class, $result);
self::assertCount(0, iterator_to_array($result)); self::assertCount(0, iterator_to_array($result));
@ -76,7 +75,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'start' => '2022-04-01T16:00:00+02:00', 'start' => '2022-04-01T16:00:00+02:00',
'end' => '2022-04-01T17:00:00+02:00', 'end' => '2022-04-01T17:00:00+02:00',
'tz' => 'Europe/Berlin', 'tz' => 'Europe/Berlin',
@ -98,9 +97,11 @@ class DatesFactoryTest extends TestCase
#[Test] #[Test]
public function returnsWeeklyWithConfiguredRepeat(): void public function returnsWeeklyWithConfiguredRepeat(): void
{ {
$import = $this->createStub(Import::class);
$import->method('getRepeatUntil')->willReturn('+60 days');
$subject = $this->createTestSubject('2023-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2023-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($import, [[
'weekdays' => [ 'weekdays' => [
'Monday', 'Monday',
'Friday', 'Friday',
@ -123,7 +124,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'start' => '2022-04-01T16:00:00+02:00', 'start' => '2022-04-01T16:00:00+02:00',
'end' => '2022-04-01T17:00:00+02:00', 'end' => '2022-04-01T17:00:00+02:00',
'tz' => 'Europe/Berlin', 'tz' => 'Europe/Berlin',
@ -147,7 +148,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'start' => '2022-10-29T16:00:00+02:00', 'start' => '2022-10-29T16:00:00+02:00',
'end' => '2022-10-29T17:00:00+02:00', 'end' => '2022-10-29T17:00:00+02:00',
'repeatUntil' => '2022-11-02T17:00:00+01:00', 'repeatUntil' => '2022-11-02T17:00:00+01:00',
@ -176,7 +177,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'start' => '2022-10-29T16:00:00+02:00', 'start' => '2022-10-29T16:00:00+02:00',
'end' => '2022-10-29T17:00:00+02:00', 'end' => '2022-10-29T17:00:00+02:00',
'repeatUntil' => '2022-11-02T17:00:00+01:00', 'repeatUntil' => '2022-11-02T17:00:00+01:00',
@ -205,7 +206,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'weekdays' => [ 'weekdays' => [
'Saturday', 'Saturday',
'Sunday', 'Sunday',
@ -246,7 +247,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-08-29T13:17:24 Europe/Berlin');
$result = $subject->createDates([[ $result = $subject->createDates($this->createStub(Import::class), [[
'weekdays' => [ 'weekdays' => [
'Saturday', 'Saturday',
'Sunday', 'Sunday',
@ -287,7 +288,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([ $result = $subject->createDates($this->createStub(Import::class), [
[ [
'start' => '2022-06-21T16:00:00+02:00', 'start' => '2022-06-21T16:00:00+02:00',
'end' => '2022-06-21T22:00:00+02:00', 'end' => '2022-06-21T22:00:00+02:00',
@ -332,7 +333,7 @@ class DatesFactoryTest extends TestCase
{ {
$subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin'); $subject = $this->createTestSubject('2022-01-01T13:17:24 Europe/Berlin');
$result = $subject->createDates([ $result = $subject->createDates($this->createStub(Import::class), [
[ [
'start' => '2022-06-21T16:00:00+02:00', 'start' => '2022-06-21T16:00:00+02:00',
'end' => '2022-06-21T22:00:00+02:00', 'end' => '2022-06-21T22:00:00+02:00',

View file

@ -9,7 +9,6 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use WerkraumMedia\Events\Domain\Model\Import; use WerkraumMedia\Events\Domain\Model\Import;
use WerkraumMedia\Events\Service\DestinationDataImportService\ArrayBasedConfigurationService;
use WerkraumMedia\Events\Service\DestinationDataImportService\UrlFactory; use WerkraumMedia\Events\Service\DestinationDataImportService\UrlFactory;
class UrlFactoryTest extends TestCase class UrlFactoryTest extends TestCase
@ -17,11 +16,7 @@ class UrlFactoryTest extends TestCase
#[Test] #[Test]
public function canBeCreated(): void public function canBeCreated(): void
{ {
$configurationManager = new ArrayBasedConfigurationService([]); $subject = new UrlFactory();
$subject = new UrlFactory(
$configurationManager
);
self::assertInstanceOf( self::assertInstanceOf(
UrlFactory::class, UrlFactory::class,
@ -31,16 +26,14 @@ class UrlFactoryTest extends TestCase
#[DataProvider('possibleImports')] #[DataProvider('possibleImports')]
#[Test] #[Test]
/**
* @param Stub&Import $import
*/
public function createSearchResultUrl( public function createSearchResultUrl(
Stub $import, Import $import,
array $settings,
string $expectedResult string $expectedResult
): void { ): void {
$configurationManager = new ArrayBasedConfigurationService($settings); $subject = new UrlFactory();
$subject = new UrlFactory(
$configurationManager
);
$result = $subject->createSearchResultUrl($import); $result = $subject->createSearchResultUrl($import);
@ -56,62 +49,42 @@ class UrlFactoryTest extends TestCase
'All provided' => [ 'All provided' => [
'import' => (function () { 'import' => (function () {
$import = self::createStub(Import::class); $import = self::createStub(Import::class);
$import->method('getRestLicenseKey')->willReturn('licenseKey');
$import->method('getRestExperience')->willReturn('experience'); $import->method('getRestExperience')->willReturn('experience');
$import->method('getSearchQuery')->willReturn(''); $import->method('getRestMode')->willReturn('restMode');
$import->method('getRestLimit')->willReturn(500);
$import->method('getRestSearchQuery')->willReturn('');
return $import; return $import;
})(), })(),
'settings' => [ 'expectedResult' => 'http://meta.et4.de/rest.ashx/search/?experience=experience&licensekey=licenseKey&type=Event&mode=restMode&limit=500&template=ET2014A.json',
'restUrl' => 'https://example.com/path',
'license' => 'licenseKey',
'restType' => 'restType',
'restMode' => 'restMode',
'restLimit' => 'restLimit',
'restTemplate' => 'restTemplate',
],
'expectedResult' => 'https://example.com/path?experience=experience&licensekey=licenseKey&type=restType&mode=restMode&limit=restLimit&template=restTemplate',
], ],
'All missing' => [ 'All missing' => [
'import' => (function () { 'import' => (function () {
$import = self::createStub(Import::class); return self::createStub(Import::class);
$import->method('getRestExperience')->willReturn('');
$import->method('getSearchQuery')->willReturn('');
return $import;
})(), })(),
'settings' => [ 'expectedResult' => 'http://meta.et4.de/rest.ashx/search/?type=Event&template=ET2014A.json',
'restUrl' => 'https://example.com/path',
],
'expectedResult' => 'https://example.com/path',
], ],
'Some missing' => [ 'Some missing' => [
'import' => (function () { 'import' => (function () {
$import = self::createStub(Import::class); $import = self::createStub(Import::class);
$import->method('getRestLicenseKey')->willReturn('licenseKey');
$import->method('getRestExperience')->willReturn('experience'); $import->method('getRestExperience')->willReturn('experience');
$import->method('getSearchQuery')->willReturn(''); $import->method('getRestLimit')->willReturn(500);
return $import; return $import;
})(), })(),
'settings' => [ 'expectedResult' => 'http://meta.et4.de/rest.ashx/search/?experience=experience&licensekey=licenseKey&type=Event&limit=500&template=ET2014A.json',
'restUrl' => 'https://example.com/path',
'license' => 'licenseKey',
'restLimit' => 'restLimit',
'restTemplate' => 'restTemplate',
],
'expectedResult' => 'https://example.com/path?experience=experience&licensekey=licenseKey&limit=restLimit&template=restTemplate',
], ],
'With search query' => [ 'With search query' => [
'import' => (function () { 'import' => (function () {
$import = self::createStub(Import::class); $import = self::createStub(Import::class);
$import->method('getRestExperience')->willReturn('experience'); $import->method('getRestExperience')->willReturn('experience');
$import->method('getSearchQuery')->willReturn('name:"Test Something"'); $import->method('getRestSearchQuery')->willReturn('name:"Test Something"');
return $import; return $import;
})(), })(),
'settings' => [ 'expectedResult' => 'http://meta.et4.de/rest.ashx/search/?experience=experience&type=Event&template=ET2014A.json&q=name%3A%22Test+Something%22',
'restUrl' => 'https://example.com/path',
],
'expectedResult' => 'https://example.com/path?experience=experience&q=name%3A%22Test+Something%22',
], ],
]; ];
} }

View file

@ -83,10 +83,14 @@ CREATE TABLE tx_events_domain_model_import (
region int(11) unsigned DEFAULT '0' NOT NULL, region int(11) unsigned DEFAULT '0' NOT NULL,
rest_license_key text,
rest_experience varchar(1024) DEFAULT '' NOT NULL, rest_experience varchar(1024) DEFAULT '' NOT NULL,
rest_mode varchar(1024) DEFAULT 'next_months,12' NOT NULL,
rest_limit int(11) unsigned DEFAULT '500' NOT NULL,
rest_search_query text, rest_search_query text,
import_features tinyint(4) DEFAULT '0' NOT NULL, import_features tinyint(4) DEFAULT '0' NOT NULL,
import_repeat_until varchar(255) DEFAULT '' NOT NULL,
); );
CREATE TABLE tx_events_domain_model_location ( CREATE TABLE tx_events_domain_model_location (