mirror of
https://github.com/werkraum-media/calendar.git
synced 2024-11-22 09:56:09 +01:00
Daniel Siepmann (Codappix)
33eb0a2a3b
TYPO3 now would return a 404 if cHash doesn't match. We now exclude the parameters within our functional tests to not run into this issue.
440 lines
15 KiB
PHP
440 lines
15 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
*
|
|
* 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 $configurationToUseInTestInstance = [
|
|
'FE' => [
|
|
'cacheHash' => [
|
|
'excludedParameters' => [
|
|
'^tx_calendar_example[',
|
|
'^typoScriptDefaults',
|
|
],
|
|
],
|
|
],
|
|
];
|
|
|
|
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 pluginNameForCurrentDay(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('PluginName: Example', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function contextForCurrentDay(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('Table: pages', $html);
|
|
self::assertStringContainsString('Title: Page Title', $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 configuredDay(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('03.11.1988', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function providedDay(): 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);
|
|
}
|
|
|
|
/**
|
|
* @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 pluginNameForCurrentWeek(): 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('PluginName: Example', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function contextForCurrentWeek(): 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('Table: pages', $html);
|
|
self::assertStringContainsString('Title: Page Title', $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 configuredWeek(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('12 1988', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function providedWeek(): 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);
|
|
}
|
|
|
|
/**
|
|
* @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 pluginNameForCurrentMonth(): 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('PluginName: Example', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function contextForCurrentMonth(): 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('Table: pages', $html);
|
|
self::assertStringContainsString('Title: Page Title', $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 configuredMonth(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('November 1988', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function providedMonth(): 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 pluginNameForCurrentYear(): 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('PluginName: Example', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function contextForCurrentYear(): 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('Table: pages', $html);
|
|
self::assertStringContainsString('Title: Page Title', $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 configuredYear(): void
|
|
{
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(1);
|
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
|
$result = $this->executeFrontendRequest($request);
|
|
|
|
self::assertSame(200, $result->getStatusCode());
|
|
$html = $result->getBody()->__toString();
|
|
self::assertStringContainsString('1988', $html);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function providedYear(): 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);
|
|
}
|
|
}
|