diff --git a/Classes/Controller/Frontend/CalendarController.php b/Classes/Controller/Frontend/CalendarController.php
index 9d3416b..dba9226 100644
--- a/Classes/Controller/Frontend/CalendarController.php
+++ b/Classes/Controller/Frontend/CalendarController.php
@@ -114,7 +114,9 @@ class CalendarController extends ActionController
{
if ($this->request->hasArgument('day') === false) {
$this->request->setArguments([
- 'day' => new \DateTimeImmutable(),
+ 'day' => [
+ 'day' => date('Y-m-d'),
+ ],
]);
}
diff --git a/Tests/Fixtures/BasicDatabase.xml b/Tests/Fixtures/BasicDatabase.xml
new file mode 100644
index 0000000..e62ccec
--- /dev/null
+++ b/Tests/Fixtures/BasicDatabase.xml
@@ -0,0 +1,22 @@
+
+
+
+ 1
+ 0
+ 1
+ 1
+ /
+ Page Title
+
+
+ 1
+ 1
+ 1
+ 3
+ databasePlatform = mysql
+
+
+ ]]>
+
+
diff --git a/Tests/Fixtures/Sites/default/config.yaml b/Tests/Fixtures/Sites/default/config.yaml
new file mode 100644
index 0000000..a127453
--- /dev/null
+++ b/Tests/Fixtures/Sites/default/config.yaml
@@ -0,0 +1,32 @@
+base: /
+languages:
+ -
+ title: English
+ enabled: true
+ base: /
+ typo3Language: default
+ locale: en_GB.UTF-8
+ iso-639-1: en
+ websiteTitle: ''
+ navigationTitle: English
+ hreflang: en-GB
+ direction: ''
+ flag: gb
+ languageId: 0
+ fallbackType: strict
+ fallbacks: '0'
+ -
+ title: Deutsch
+ enabled: true
+ base: /de
+ typo3Language: de
+ locale: de_DE.UTF-8
+ iso-639-1: de
+ navigationTitle: Deutsch
+ hreflang: de-DE
+ direction: ''
+ flag: de
+ websiteTitle: ''
+ languageId: 1
+rootPageId: 1
+websiteTitle: 'Example Website'
diff --git a/Tests/Fixtures/calendar_example/Classes/Domain/ExampleDataFactory.php b/Tests/Fixtures/calendar_example/Classes/Domain/ExampleDataFactory.php
new file mode 100644
index 0000000..c03b838
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Classes/Domain/ExampleDataFactory.php
@@ -0,0 +1,37 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+namespace WerkraumMedia\CalendarExample\Domain;
+
+use WerkraumMedia\Calendar\Domain\Model\Day;
+use WerkraumMedia\Calendar\Domain\Model\ForeignDataFactory;
+
+class ExampleDataFactory implements ForeignDataFactory
+{
+ public function getData(Day $day)
+ {
+ return [
+ 'exampleKey' => 'exampleValue',
+ ];
+ }
+}
diff --git a/Tests/Fixtures/calendar_example/Classes/EventListener/AssignTemplateVariables.php b/Tests/Fixtures/calendar_example/Classes/EventListener/AssignTemplateVariables.php
new file mode 100644
index 0000000..cb26338
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Classes/EventListener/AssignTemplateVariables.php
@@ -0,0 +1,36 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+namespace WerkraumMedia\CalendarExample\EventListener;
+
+use WerkraumMedia\Calendar\Events\AssignTemplateVariables as AssignTemplateVariablesEvent;
+
+class AssignTemplateVariables
+{
+ public function __invoke(AssignTemplateVariablesEvent $event): void
+ {
+ $event->setVariables(array_merge($event->getVariables(), [
+ 'customVariable' => 'modifiedVariable',
+ ]));
+ }
+}
diff --git a/Tests/Fixtures/calendar_example/Configuration/Services.yaml b/Tests/Fixtures/calendar_example/Configuration/Services.yaml
new file mode 100644
index 0000000..1478305
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Configuration/Services.yaml
@@ -0,0 +1,17 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+ public: false
+
+ WerkraumMedia\CalendarExample\:
+ resource: '../Classes/*'
+
+ WerkraumMedia\Calendar\Domain\Model\ForeignDataFactory:
+ class: 'WerkraumMedia\CalendarExample\Domain\ExampleDataFactory'
+ public: true
+
+ WerkraumMedia\CalendarExample\EventListener\AssignTemplateVariables:
+ tags:
+ - name: 'event.listener'
+ event: 'WerkraumMedia\Calendar\Events\AssignTemplateVariables'
diff --git a/Tests/Fixtures/calendar_example/Configuration/TypoScript/Setup.typoscript b/Tests/Fixtures/calendar_example/Configuration/TypoScript/Setup.typoscript
new file mode 100644
index 0000000..f7e747c
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Configuration/TypoScript/Setup.typoscript
@@ -0,0 +1,12 @@
+plugin.tx_calendar_example {
+ view {
+ templateRootPaths {
+ 10 = EXT:calendar_example/Resources/Private/Templates/
+ }
+ }
+}
+
+page = PAGE
+page {
+ 10 =< tt_content.calendar_example.20
+}
diff --git a/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Day.html b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Day.html
new file mode 100644
index 0000000..eb18a1a
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Day.html
@@ -0,0 +1,10 @@
+
+
+
{day.dateTimeInstance -> f:format.date(format: 'd.m.Y')}
+
+ {day.foreignData.exampleKey}
+
+ {customVariable}
+
diff --git a/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Month.html b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Month.html
new file mode 100644
index 0000000..a7771a5
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Month.html
@@ -0,0 +1,14 @@
+
+
+ {month.dateTimeInstance -> f:format.date(format: '%B %Y')}
+
+
+
+ {day.dateTimeInstance -> f:format.date(format: 'd')}
+ {day.foreignData.exampleKey}
+
+
+
+ {customVariable}
+
diff --git a/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Week.html b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Week.html
new file mode 100644
index 0000000..db6a7e9
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Week.html
@@ -0,0 +1,12 @@
+
+
+ {week.dateTimeInstance -> f:format.date(format: '%V %Y')}
+
+
+ {day.dateTimeInstance -> f:format.date(format: 'd')}
+ {day.foreignData.exampleKey}
+
+
+ {customVariable}
+
diff --git a/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Year.html b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Year.html
new file mode 100644
index 0000000..fbde290
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/Resources/Private/Templates/Frontend/Calendar/Year.html
@@ -0,0 +1,16 @@
+
+
+ {year.dateTimeInstance -> f:format.date(format: 'Y')}
+
+
+
+
+ {day.dateTimeInstance -> f:format.date(format: 'd')}
+ {day.foreignData.exampleKey}
+
+
+
+
+ {customVariable}
+
diff --git a/Tests/Fixtures/calendar_example/composer.json b/Tests/Fixtures/calendar_example/composer.json
new file mode 100644
index 0000000..d3e8d61
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/composer.json
@@ -0,0 +1,21 @@
+{
+ "name": "werkraummedia/calendar_example",
+ "description": "Add calendar data",
+ "type": "typo3-cms-extension",
+ "license": "GPL-2.0-or-later",
+ "autoload": {
+ "psr-4": {
+ "WerkraumMedia\\CalendarExample\\": "Classes/"
+ }
+ },
+ "require": {
+ "typo3/cms-core": "*",
+ "typo3/cms-fluid-styled-content": "*",
+ "werkraummedia/calendar": "*"
+ },
+ "extra": {
+ "typo3/cms": {
+ "extension-key": "calendar_example"
+ }
+ }
+}
diff --git a/Tests/Fixtures/calendar_example/ext_emconf.php b/Tests/Fixtures/calendar_example/ext_emconf.php
new file mode 100644
index 0000000..48745af
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/ext_emconf.php
@@ -0,0 +1,21 @@
+ 'Calendar Example',
+ 'description' => 'Example extension to demonstrate integration',
+ 'category' => 'misc',
+ 'author' => 'Daniel Siepmann',
+ 'author_email' => 'coding@daniel-siepmann.de',
+ 'author_company' => 'Codappix GmbH',
+ 'state' => 'alpha',
+ 'uploadfolder' => 0,
+ 'clearCacheOnLoad' => 0,
+ 'version' => '1.0.0',
+ 'constraints' => [
+ 'depends' => [
+ 'typo3' => '*',
+ ],
+ 'conflicts' => [],
+ 'suggests' => [],
+ ],
+];
diff --git a/Tests/Fixtures/calendar_example/ext_localconf.php b/Tests/Fixtures/calendar_example/ext_localconf.php
new file mode 100644
index 0000000..0a33597
--- /dev/null
+++ b/Tests/Fixtures/calendar_example/ext_localconf.php
@@ -0,0 +1,18 @@
+ implode(',', [
+ 'day',
+ 'week',
+ 'month',
+ 'year',
+ ]),
+ ],
+ [],
+ \TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
+ );
+})();
diff --git a/Tests/Functional/CalendarControllerTest.php b/Tests/Functional/CalendarControllerTest.php
new file mode 100644
index 0000000..1ac8451
--- /dev/null
+++ b/Tests/Functional/CalendarControllerTest.php
@@ -0,0 +1,246 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+namespace WerkraumMedia\Calendar\Tests\Functional;
+
+use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
+use WerkraumMedia\Calendar\Controller\Frontend\CalendarController;
+
+/**
+ * @coversNothing
+ * @testdox Calendar controller renders with
+ */
+class CalendarControllerTest extends FunctionalTestCase
+{
+ protected $coreExtensionsToLoad = [
+ 'fluid_styled_content',
+ ];
+
+ protected $testExtensionsToLoad = [
+ 'typo3conf/ext/calendar',
+ 'typo3conf/ext/calendar/Tests/Fixtures/calendar_example',
+ ];
+
+ protected $pathsToLinkInTestInstance = [
+ 'typo3conf/ext/calendar/Tests/Fixtures/Sites' => 'typo3conf/sites',
+ ];
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+
+ $this->importDataSet(__DIR__ . '/../Fixtures/BasicDatabase.xml');
+ }
+
+ /**
+ * @test
+ */
+ public function modifiedVariablesForCurrentDay(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('modifiedVariable', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForCurrentDay(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString(date('d.m.Y'), $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForProvidedDay(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[day][day]', '2020-11-03');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('03.11.2020', $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function modifiedVariablesForCurrentWeek(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('modifiedVariable', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForCurrentWeek(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString(date('W Y'), $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForProvidedWeek(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
+ $request = $request->withQueryParameter('tx_calendar_example[week][week]', '02');
+ $request = $request->withQueryParameter('tx_calendar_example[week][year]', '2020');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('02 2020', $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function modifiedVariablesForCurrentMonth(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('modifiedVariable', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForCurrentMonth(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString(strftime('%B %Y'), $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForProvidedMonth(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
+ $request = $request->withQueryParameter('tx_calendar_example[month][month]', '11');
+ $request = $request->withQueryParameter('tx_calendar_example[month][year]', '2020');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('November 2020', $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function modifiedVariablesForCurrentYear(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('modifiedVariable', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForCurrentYear(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString(date('Y'), $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+
+ /**
+ * @test
+ */
+ public function customDataForProvidedYear(): void
+ {
+ $request = new InternalRequest();
+ $request = $request->withPageId(1);
+ $request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
+ $request = $request->withQueryParameter('tx_calendar_example[year][year]', '2020');
+ $result = $this->executeFrontendRequest($request);
+
+ self::assertSame(200, $result->getStatusCode());
+ $html = $result->getBody()->__toString();
+ self::assertStringContainsString('2020', $html);
+ self::assertStringContainsString('exampleValue', $html);
+ }
+}
diff --git a/Tests/Unit/Controller/Frontend/CalendarControllerTest.php b/Tests/Unit/Controller/Frontend/CalendarControllerTest.php
deleted file mode 100644
index 004330f..0000000
--- a/Tests/Unit/Controller/Frontend/CalendarControllerTest.php
+++ /dev/null
@@ -1,356 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-use PHPUnit\Framework\TestCase;
-use Prophecy\Argument as ProphetArgument;
-use Prophecy\PhpUnit\ProphecyTrait;
-use Prophecy\Prophecy\ObjectProphecy;
-use Psr\EventDispatcher\EventDispatcherInterface;
-use TYPO3\CMS\Extbase\Mvc\Controller\Argument;
-use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
-use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
-use TYPO3\CMS\Extbase\Mvc\Web\Request;
-use TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration;
-use WerkraumMedia\Calendar\Controller\Frontend\CalendarController;
-use WerkraumMedia\Calendar\Domain\Model\Day;
-use WerkraumMedia\Calendar\Domain\Model\Month;
-use WerkraumMedia\Calendar\Domain\Model\Week;
-use WerkraumMedia\Calendar\Domain\Model\Year;
-use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
-use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
-
-/**
- * @covers WerkraumMedia\Calendar\Controller\Frontend\CalendarController
- * @testdox The calendar controller
- */
-class CalendarControllerTest extends TestCase
-{
- use ProphecyTrait;
- use ForcePropertyTrait;
-
- /**
- * @test
- */
- public function setsCurrentYearAsDefaultArgument(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('year')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('year')->willReturn(false);
- $request->setArguments([
- 'year' => [
- 'year' => date('Y'),
- ],
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeYearAction();
- $request->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function allowsYearToBeMapped(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('year')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('year')->willReturn(true);
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeYearAction();
- $arguments->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function addsYearToView(): void
- {
- $subject = new CalendarController();
-
- $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
- $eventDispatcher->dispatch(ProphetArgument::type(AssignTemplateVariables::class))->shouldBeCalled();
- $subject->injectEventDispatcher($eventDispatcher->reveal());
-
- $year = $this->prophesize(Year::class);
- $view = $this->prophesize(ViewInterface::class);
- $view->assignMultiple([
- 'year' => $year->reveal(),
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'view', $view->reveal());
-
- $subject->yearAction($year->reveal());
- $view->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function setsCurrentMonthAsDefaultArgument(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('month')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('month')->willReturn(false);
- $request->setArguments([
- 'month' => [
- 'month' => date('m'),
- 'year' => date('Y'),
- ],
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeMonthAction();
- $request->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function allowsMonthToBeMapped(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('month')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('month')->willReturn(true);
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeMonthAction();
- $arguments->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function addsMonthToView(): void
- {
- $subject = new CalendarController();
-
- $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
- $eventDispatcher->dispatch(ProphetArgument::type(AssignTemplateVariables::class))->shouldBeCalled();
- $subject->injectEventDispatcher($eventDispatcher->reveal());
-
- $month = $this->prophesize(Month::class);
- $view = $this->prophesize(ViewInterface::class);
- $view->assignMultiple([
- 'month' => $month->reveal(),
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'view', $view->reveal());
-
- $subject->monthAction($month->reveal());
- $view->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function setsCurrentWeekAsDefaultArgument(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('week')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('week')->willReturn(false);
- $request->setArguments([
- 'week' => [
- 'week' => date('W'),
- 'year' => date('Y'),
- ],
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeWeekAction();
- $request->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function allowsWeekToBeMapped(): void
- {
- $subject = new CalendarController();
-
- $arguments = $this->allowsMappingOfAllPropertiesForArgument('week')['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('week')->willReturn(true);
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeWeekAction();
- $arguments->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function addsWeekToView(): void
- {
- $subject = new CalendarController();
-
- $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
- $eventDispatcher->dispatch(ProphetArgument::type(AssignTemplateVariables::class))->shouldBeCalled();
- $subject->injectEventDispatcher($eventDispatcher->reveal());
-
- $week = $this->prophesize(Week::class);
- $view = $this->prophesize(ViewInterface::class);
- $view->assignMultiple([
- 'week' => $week->reveal(),
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'view', $view->reveal());
-
- $subject->weekAction($week->reveal());
- $view->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function setsCurrentDayAsDefaultArgument(): void
- {
- $subject = new CalendarController();
-
- $prophecies = $this->allowsMappingOfAllPropertiesForArgument('day');
- $propertyConfiguration = $prophecies['propertyMappingConfiguration'];
- $arguments = $prophecies['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('day')->willReturn(false);
- $request->setArguments(ProphetArgument::that(function (array $arguments) {
- return count($arguments) === 1
- && isset($arguments['day'])
- && $arguments['day'] instanceof \DateTimeImmutable
- && $arguments['day']->format('Y-m-d') === date('Y-m-d')
- ;
- }))->shouldBeCalled();
-
- $configuration = $this->prophesize(PropertyMappingConfiguration::class);
- $configuration->setTypeConverterOption(
- '',
- '',
- 'Y-m-d'
- );
- $propertyConfiguration->forProperty('day')->willReturn($configuration);
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeDayAction();
- $request->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function configuredMappingForDay(): void
- {
- $subject = new CalendarController();
-
- $prophecies = $this->allowsMappingOfAllPropertiesForArgument('day');
- $propertyConfiguration = $prophecies['propertyMappingConfiguration'];
- $arguments = $prophecies['arguments'];
-
- $request = $this->prophesize(Request::class);
- $request->hasArgument('day')->willReturn(true);
-
- $configuration = $this->prophesize(PropertyMappingConfiguration::class);
- $configuration->setTypeConverterOption(
- '',
- '',
- 'Y-m-d'
- );
- $propertyConfiguration->forProperty('day')->willReturn($configuration);
-
- $this->forceProperty($subject, 'request', $request->reveal());
- $this->forceProperty($subject, 'arguments', $arguments->reveal());
-
- $subject->initializeDayAction();
- $arguments->checkProphecyMethodsPredictions();
- }
-
- /**
- * @test
- */
- public function addsDayToView(): void
- {
- $subject = new CalendarController();
-
- $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
- $eventDispatcher->dispatch(ProphetArgument::type(AssignTemplateVariables::class))->shouldBeCalled();
- $subject->injectEventDispatcher($eventDispatcher->reveal());
-
- $day = $this->prophesize(Day::class);
- $view = $this->prophesize(ViewInterface::class);
- $view->assignMultiple([
- 'day' => $day->reveal(),
- ])->shouldBeCalled();
-
- $this->forceProperty($subject, 'view', $view->reveal());
-
- $subject->dayAction($day->reveal());
- $view->checkProphecyMethodsPredictions();
- }
-
- private function allowsMappingOfAllPropertiesForArgument(string $argumentName): array
- {
- $propertyMappingConfiguration = $this->prophesize(PropertyMappingConfiguration::class);
- $propertyMappingConfiguration->allowAllProperties()->shouldBeCalled();
-
- $argument = $this->prophesize(Argument::class);
- $argument->getPropertyMappingConfiguration()->willReturn($propertyMappingConfiguration);
-
- $arguments = $this->prophesize(Arguments::class);
- $arguments->getArgument($argumentName)->willReturn($argument->reveal());
-
- return [
- 'propertyMappingConfiguration' => $propertyMappingConfiguration,
- 'argument' => $argument,
- 'arguments' => $arguments,
- ];
- }
-}
diff --git a/composer.json b/composer.json
index 13eaaee..62220d2 100644
--- a/composer.json
+++ b/composer.json
@@ -24,7 +24,8 @@
},
"autoload-dev": {
"psr-4": {
- "WerkraumMedia\\Calendar\\Tests\\": "Tests/"
+ "WerkraumMedia\\Calendar\\Tests\\": "Tests/",
+ "WerkraumMedia\\CalendarExample\\": "Tests/Fixtures/calendar_example/Classes/"
}
},
"require-dev": {
@@ -32,7 +33,9 @@
"maglnet/composer-require-checker": "^2.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
- "symplify/easy-coding-standard": "^9.2"
+ "symplify/easy-coding-standard": "^9.2",
+ "typo3/cms-fluid-styled-content": "^10.4",
+ "typo3/testing-framework": "^6.6"
},
"extra": {
"typo3/cms": {
@@ -40,5 +43,11 @@
"extension-key": "calendar",
"web-dir": ".Build/web"
}
+ },
+ "scripts": {
+ "post-autoload-dump": [
+ "@php -r 'is_dir($extFolder = __DIR__ . \"/.Build/web/typo3conf/ext/\") || mkdir($extFolder, 0777, true);'",
+ "@php -r 'file_exists($extFolder = __DIR__ . \"/.Build/web/typo3conf/ext/calendar\") || symlink(__DIR__, $extFolder);'"
+ ]
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 7b93a5c..858b92f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -4,6 +4,7 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
+ bootstrap="vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
@@ -20,6 +21,9 @@
Tests/Unit/
+
+ Tests/Functional/
+
@@ -27,4 +31,8 @@
Classes
+
+
+
+