Skip to content

Commit

Permalink
Fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Mar 12, 2024
1 parent 9c34c44 commit 3f62be0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 11 additions & 1 deletion Classes/Service/TimeTableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@
*/
class TimeTableService extends AbstractService
{
protected ConfigurationRepository $configurationRepository;

public function setConfigurationRepository(ConfigurationRepository $configurationRepository): void
{
$this->configurationRepository = $configurationRepository;
}

/**
* Build the timetable for the given configuration matrix (sorted).
*/
public function getTimeTablesByConfigurationIds(array $ids, int $workspace): array
{
if (!$this->configurationRepository instanceof ConfigurationRepository) {
$this->configurationRepository = GeneralUtility::makeInstance(ConfigurationRepository::class);
}
$timeTable = [];
if (!$ids) {
return $timeTable;
Expand All @@ -41,7 +51,7 @@ public function getTimeTablesByConfigurationIds(array $ids, int $workspace): arr
// Disable Workspace for selection to get also offline versions of configuration
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['ctrl']['versioningWS'] = false;
// Do not use DI for repo to avoid problem in ext_localconf.php loading context
$configuration = GeneralUtility::makeInstance(ConfigurationRepository::class)->findByUid($configurationUid);
$configuration = $this->configurationRepository->findByUid($configurationUid);
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['ctrl']['versioningWS'] = true;
if (!($configuration instanceof Configuration)) {
continue;
Expand Down
9 changes: 5 additions & 4 deletions Tests/Functional/Indexing/TimeTableServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function testIndexConfiguration(array $configurations, callable $assert)
return $configurations[$id] ?? null;
});

$timeTableService = new TimeTableService($configurationRepository);
$timeTableService = new TimeTableService();
$timeTableService->setConfigurationRepository($configurationRepository);

$result = $timeTableService->getTimeTablesByConfigurationIds(array_keys($configurations), 0);

self::assertNotEmpty($result, 'There should be index entries');
$assert($result);
}
Expand All @@ -58,7 +58,7 @@ public static function configurationProvider(): \Generator
yield 'simple index Entry' => [
[
1 => $new_configuration(102)
->setType(Configuration::TYPE_TIME)
->setType(ConfigurationInterface::TYPE_TIME)
->setStartDate(new \DateTime('2022-07-01'))
->setStartTime(60 * 60 * 12)
->setOpenEndTime(true)
Expand All @@ -70,7 +70,7 @@ function ($result) {
yield 'simple index Entry with hourly frequency' => [
[
1 => $new_configuration(102)
->setType(Configuration::TYPE_TIME)
->setType(ConfigurationInterface::TYPE_TIME)
->setStartDate(new \DateTime('2022-07-01'))
->setStartTime(60 * 60 * 12)
->setEndTime(60 * 60 * 12 + (30 * 60))
Expand All @@ -81,6 +81,7 @@ function ($result) {
],
function ($result) {
$items = array_values($result);

self::assertCount(6, $items);
self::assertEquals('12:00:00', BackendUtility::time($items[0]['start_time']));
self::assertEquals('12:30:00', BackendUtility::time($items[0]['end_time']));
Expand Down

0 comments on commit 3f62be0

Please sign in to comment.