TYPO3 v12 (#11)

This commit is contained in:
Daniel Siepmann (Codappix) 2024-09-17 15:00:31 +02:00 committed by GitHub
parent b087098793
commit 891871a8ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 453 additions and 453 deletions

11
.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
Tests export-ignore
.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php-cs-fixer.dist.php export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
shell.nix export-ignore

View file

@ -20,11 +20,9 @@ jobs:
strategy:
matrix:
php-version:
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
steps:
- name: Checkout
uses: actions/checkout@v3
@ -78,31 +76,27 @@ jobs:
with:
coverage: none
tools: composer:v2
php-version: "8.2"
php-version: "8.3"
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Coding Guideline
run: ./vendor/bin/ecs
run: ./vendor/bin/php-cs-fixer fix --dry-run
tests:
phpstan:
runs-on: ubuntu-latest
needs:
- xml-linting
strategy:
matrix:
include:
- php-version: '7.3'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '^11.5'
typo3-version: '^12.4'
- php-version: '8.2'
typo3-version: '^11.5'
typo3-version: '^12.4'
- php-version: '8.3'
typo3-version: '^12.4'
steps:
- uses: actions/checkout@v3
@ -114,7 +108,36 @@ jobs:
php-version: "${{ matrix.php-version }}"
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
run: composer req "typo3/cms-core:${{ matrix.typo3-version }}" --prefer-dist --no-progress --no-interaction
- name: PHPStan
run: ./vendor/bin/phpstan
tests:
runs-on: ubuntu-latest
needs:
- xml-linting
strategy:
matrix:
include:
- php-version: '8.1'
typo3-version: '^12.4'
- php-version: '8.2'
typo3-version: '^12.4'
- php-version: '8.3'
typo3-version: '^12.4'
steps:
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: "${{ matrix.php-version }}"
- name: Install dependencies
run: composer req "typo3/cms-core:${{ matrix.typo3-version }}" --prefer-dist --no-progress --no-interaction
- name: PHPUnit Tests
run: ./vendor/bin/phpunit --testdox

63
.php-cs-fixer.dist.php Normal file
View file

@ -0,0 +1,63 @@
<?php
$finder = (new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(realpath(__DIR__));
return (new \PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
->setFinder($finder);

View file

@ -21,11 +21,14 @@ namespace WerkraumMedia\Calendar\Controller\Frontend;
* 02110-1301, USA.
*/
use Psr\Http\Message\ResponseInterface;
use RuntimeException;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use WerkraumMedia\Calendar\Domain\Model\Context;
use WerkraumMedia\Calendar\Domain\Model\ContextSpecificFactory;
use WerkraumMedia\Calendar\Domain\Model\Day;
@ -35,7 +38,7 @@ use WerkraumMedia\Calendar\Domain\Model\Week;
use WerkraumMedia\Calendar\Domain\Model\Year;
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
class CalendarController extends ActionController
final class CalendarController extends ActionController
{
/**
* @var ForeignDataFactory
@ -55,19 +58,19 @@ class CalendarController extends ActionController
$this->typoScriptService = $typoScriptService;
}
public function initializeAction()
public function initializeAction(): void
{
if ($this->foreignDataFactory instanceof ContextSpecificFactory) {
$this->foreignDataFactory->setContext(
Context::createFromContentObjectRenderer($this->configurationManager->getContentObject())
Context::createFromContentObjectRenderer($this->getContentObjectRenderer())
);
}
}
public function initializeYearAction()
public function initializeYearAction(): void
{
if ($this->request->hasArgument('year') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'year' => [
'year' => $this->getDefaultArgumentValue('year'),
],
@ -82,17 +85,19 @@ class CalendarController extends ActionController
/**
* @Extbase\IgnoreValidation("year")
*/
public function yearAction(Year $year)
public function yearAction(Year $year): ResponseInterface
{
$this->assignVariables([
'year' => $year,
]);
return $this->htmlResponse();
}
public function initializeMonthAction()
public function initializeMonthAction(): void
{
if ($this->request->hasArgument('month') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'month' => [
'month' => $this->getDefaultArgumentValue('month'),
'year' => $this->getDefaultArgumentValue('year'),
@ -108,17 +113,19 @@ class CalendarController extends ActionController
/**
* @Extbase\IgnoreValidation("month")
*/
public function monthAction(Month $month)
public function monthAction(Month $month): ResponseInterface
{
$this->assignVariables([
'month' => $month,
]);
return $this->htmlResponse();
}
public function initializeWeekAction()
public function initializeWeekAction(): void
{
if ($this->request->hasArgument('week') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'week' => [
'week' => $this->getDefaultArgumentValue('week'),
'year' => $this->getDefaultArgumentValue('year'),
@ -134,17 +141,19 @@ class CalendarController extends ActionController
/**
* @Extbase\IgnoreValidation("week")
*/
public function weekAction(Week $week)
public function weekAction(Week $week): ResponseInterface
{
$this->assignVariables([
'week' => $week,
]);
return $this->htmlResponse();
}
public function initializeDayAction()
public function initializeDayAction(): void
{
if ($this->request->hasArgument('day') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'day' => [
'day' => $this->getDefaultArgumentValue('day'),
],
@ -167,11 +176,13 @@ class CalendarController extends ActionController
/**
* @Extbase\IgnoreValidation("day")
*/
public function dayAction(Day $day)
public function dayAction(Day $day): ResponseInterface
{
$this->assignVariables([
'day' => $day,
]);
return $this->htmlResponse();
}
private function assignVariables(array $variables): void
@ -202,12 +213,23 @@ class CalendarController extends ActionController
'day' => date('Y-m-d'),
];
$value = $this->configurationManager->getContentObject()->stdWrapValue(
$value = $this->getContentObjectRenderer()->stdWrapValue(
$argumentName,
$arguments,
$fallbackValues[$argumentName]
);
return $value;
return (string)$value;
}
private function getContentObjectRenderer(): ContentObjectRenderer
{
$contentObjectRenderer = $this->request->getAttribute('currentContentObject');
if (! $contentObjectRenderer instanceof ContentObjectRenderer) {
throw new RuntimeException('Could not fetch currentContentObject from request.', 1726490796);
}
return $contentObjectRenderer;
}
}

View file

@ -22,7 +22,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Day
{
@ -44,7 +43,6 @@ class Day
public function __construct(
\DateTime $day
) {
$this->periods = new ObjectStorage();
$this->day = \DateTimeImmutable::createFromMutable($day)->modify('midnight');
}
@ -58,7 +56,7 @@ class Day
return false;
}
public function getForeignData()
public function getForeignData(): mixed
{
$this->initializeForeignData();

View file

@ -27,5 +27,5 @@ interface ForeignDataFactory
* Receives a specific day and may return arbirtrary data.
* This data is attached to the day and available through getter.
*/
public function getData(Day $day);
public function getData(Day $day): mixed;
}

View file

@ -21,9 +21,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
* 02110-1301, USA.
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Month
{
/**
@ -77,8 +74,8 @@ class Month
while ($currentDay <= $lastDay) {
$this->weeks[] = new Week(
(int) $currentDay->format('W'),
(int) $currentDay->format('o')
(int)$currentDay->format('W'),
(int)$currentDay->format('o')
);
$currentDay = $currentDay->modify('+7 days');

View file

@ -23,7 +23,7 @@ namespace WerkraumMedia\Calendar\Domain\Model;
class NullDataFactory implements ForeignDataFactory
{
public function getData(Day $day)
public function getData(Day $day): mixed
{
return null;
}

View file

@ -79,8 +79,8 @@ class Week
$newDay = $this->getWeek()->modify('-1 week');
return new self(
(int) $newDay->format('W'),
(int) $newDay->format('o')
(int)$newDay->format('W'),
(int)$newDay->format('o')
);
}
@ -89,8 +89,8 @@ class Week
$newDay = $this->getWeek()->modify('+1 week');
return new self(
(int) $newDay->format('W'),
(int) $newDay->format('o')
(int)$newDay->format('W'),
(int)$newDay->format('o')
);
}

View file

@ -21,9 +21,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
* 02110-1301, USA.
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Year
{
/**
@ -64,7 +61,7 @@ class Year
while ($currentMonth <= $lastMonth) {
$this->months[] = new Month(
(int) $currentMonth->format('n'),
(int)$currentMonth->format('n'),
$this->year
);

View file

@ -0,0 +1,36 @@
2.0.0
=====
Breaking
--------
* Drop support for TYPO3 v10.4 LTS and PHP 7.3, 7.4, 8.0.
Features
--------
* Add compatibility for TYPO3 v12.4.0 and PHP 8.3.
Fixes
-----
Nothing
Tasks
-----
* Switch CGL from ecs to php-cs-fixer.
As that's the tool we use everywhere else.
Use the same config as well.
* Add PHPStan
As we always add that tool.
It helps us to find bugs and keep code clean.
Deprecation
-----------
Nothing

View file

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
return [
'pages' => [
0 => [
'uid' => 1,
'pid' => 0,
'doktype' => 1,
'is_siteroot' => 1,
'slug' => '/',
'title' => 'Page Title',
],
],
'sys_template' => [
0 => [
'uid' => 1,
'pid' => 1,
'root' => 1,
'clear' => 3,
'constants' => 'databasePlatform = mysql',
'config' => '
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:calendar_example/Configuration/TypoScript/Setup.typoscript">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript">
',
],
],
];

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<pages>
<uid>1</uid>
<pid>0</pid>
<doktype>1</doktype>
<is_siteroot>1</is_siteroot>
<slug>/</slug>
<title>Page Title</title>
</pages>
<sys_template>
<uid>1</uid>
<pid>1</pid>
<root>1</root>
<clear>3</clear>
<constants>databasePlatform = mysql</constants>
<config><![CDATA[
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:calendar_example/Configuration/TypoScript/Setup.typoscript">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript">
]]></config>
</sys_template>
</dataset>

View file

@ -40,7 +40,7 @@ class ExampleDataFactory implements ForeignDataFactory, ContextSpecificFactory
$this->context = $context;
}
public function getData(Day $day)
public function getData(Day $day): mixed
{
return [
'exampleKey' => 'exampleValue',

View file

@ -11,7 +11,7 @@ page {
10 =< tt_content.calendar_example.20
}
[request.getQueryParams()['typoScriptDefaults'] == 1]
[traverse(request.getQueryParams(), 'typoScriptDefaults') == 1]
plugin.tx_calendar_example {
settings {
arguments {

View file

@ -23,7 +23,7 @@ namespace WerkraumMedia\Calendar\Tests;
trait ForcePropertyTrait
{
protected function forceProperty($subject, string $name, $value)
protected function forceProperty(object $subject, string $name, mixed $value): void
{
$objectReflection = new \ReflectionObject($subject);
$property = $objectReflection->getProperty($name);

View file

@ -23,30 +23,32 @@ declare(strict_types=1);
namespace WerkraumMedia\Calendar\Tests\Functional;
use Codappix\Typo3PhpDatasets\TestingFramework;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use TYPO3\CMS\Core\Localization\DateFormatter;
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
*/
#[TestDox('Calendar controller renders with')]
class CalendarControllerTest extends FunctionalTestCase
{
protected $coreExtensionsToLoad = [
use TestingFramework;
protected array $coreExtensionsToLoad = [
'fluid_styled_content',
];
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/calendar',
'typo3conf/ext/calendar/Tests/Fixtures/calendar_example',
];
protected $pathsToLinkInTestInstance = [
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/calendar/Tests/Fixtures/Sites' => 'typo3conf/sites',
];
protected $configurationToUseInTestInstance = [
protected array $configurationToUseInTestInstance = [
'FE' => [
'cacheHash' => [
'excludedParameters' => [
@ -61,45 +63,39 @@ class CalendarControllerTest extends FunctionalTestCase
{
parent::setUp();
$this->importDataSet(__DIR__ . '/../Fixtures/BasicDatabase.xml');
$this->importPHPDataSet(__DIR__ . '/../Fixtures/BasicDatabase.php');
}
/**
* @test
*/
#[Test]
public function modifiedVariablesForCurrentDay(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('modifiedVariable', $html);
}
/**
* @test
*/
#[Test]
public function pluginNameForCurrentDay(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('PluginName: Example', $html);
}
/**
* @test
*/
#[Test]
public function contextForCurrentDay(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -107,14 +103,12 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('Title: Page Title', $html);
}
/**
* @test
*/
#[Test]
public function customDataForCurrentDay(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -122,75 +116,65 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('exampleValue', $html);
}
/**
* @test
*/
#[Test]
public function configuredDay(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('typoScriptDefaults', '1');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('03.11.1988', $html);
}
/**
* @test
*/
#[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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('03.11.2020', $html);
}
/**
* @test
*/
#[Test]
public function modifiedVariablesForCurrentWeek(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('modifiedVariable', $html);
}
/**
* @test
*/
#[Test]
public function pluginNameForCurrentWeek(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('PluginName: Example', $html);
}
/**
* @test
*/
#[Test]
public function contextForCurrentWeek(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -198,15 +182,13 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('Title: Page Title', $html);
}
/**
* @test
*/
#[Test]
public function customDataForCurrentWeek(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -214,25 +196,21 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('exampleValue', $html);
}
/**
* @test
*/
#[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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('12 1988', $html);
}
/**
* @test
*/
#[Test]
public function providedWeek(): void
{
$request = new InternalRequest();
@ -240,52 +218,46 @@ class CalendarControllerTest extends FunctionalTestCase
$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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('02 2020', $html);
}
/**
* @test
*/
#[Test]
public function modifiedVariablesForCurrentMonth(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('modifiedVariable', $html);
}
/**
* @test
*/
#[Test]
public function pluginNameForCurrentMonth(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('PluginName: Example', $html);
}
/**
* @test
*/
#[Test]
public function contextForCurrentMonth(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -293,41 +265,35 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('Title: Page Title', $html);
}
/**
* @test
*/
#[Test]
public function customDataForCurrentMonth(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString(strftime('%B %Y'), $html);
self::assertStringContainsString((new DateFormatter())->strftime('%B %Y', 'now', 'de-DE'), $html);
self::assertStringContainsString('exampleValue', $html);
}
/**
* @test
*/
#[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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('November 1988', $html);
}
/**
* @test
*/
#[Test]
public function providedMonth(): void
{
$request = new InternalRequest();
@ -335,7 +301,7 @@ class CalendarControllerTest extends FunctionalTestCase
$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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -343,45 +309,39 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('exampleValue', $html);
}
/**
* @test
*/
#[Test]
public function modifiedVariablesForCurrentYear(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('modifiedVariable', $html);
}
/**
* @test
*/
#[Test]
public function pluginNameForCurrentYear(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('PluginName: Example', $html);
}
/**
* @test
*/
#[Test]
public function contextForCurrentYear(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -389,15 +349,13 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('Title: Page Title', $html);
}
/**
* @test
*/
#[Test]
public function customDataForCurrentYear(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
$result = $this->executeFrontendRequest($request);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
@ -405,32 +363,28 @@ class CalendarControllerTest extends FunctionalTestCase
self::assertStringContainsString('exampleValue', $html);
}
/**
* @test
*/
#[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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();
self::assertStringContainsString('1988', $html);
}
/**
* @test
*/
#[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);
$result = $this->executeFrontendSubRequest($request);
self::assertSame(200, $result->getStatusCode());
$html = $result->getBody()->__toString();

View file

@ -23,32 +23,14 @@ declare(strict_types=1);
namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use WerkraumMedia\Calendar\Domain\Model\Context;
/**
* @covers \WerkraumMedia\Calendar\Domain\Model\Context
*/
class ContextTest extends TestCase
{
/**
* @test
*/
public function canNotBeCreatedViaNew(): void
{
$this->expectError();
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->expectErrorMessage('Call to private WerkraumMedia\Calendar\Domain\Model\Context::__construct() from scope WerkraumMedia\Calendar\Tests\Unit\Domain\Model\ContextTest');
} else {
$this->expectErrorMessage('Call to private WerkraumMedia\Calendar\Domain\Model\Context::__construct() from context \'WerkraumMedia\Calendar\Tests\Unit\Domain\Model\ContextTest\'');
}
$subject = new Context();
}
/**
* @test
*/
#[Test]
public function canBeCreatedFromContentObjectRenderer(): void
{
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
@ -57,9 +39,7 @@ class ContextTest extends TestCase
self::assertInstanceOf(Context::class, $subject);
}
/**
* @test
*/
#[Test]
public function providesTableNameInheritedFromContentObjectRenderer(): void
{
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
@ -69,9 +49,7 @@ class ContextTest extends TestCase
self::assertSame('tx_calendar_example_table', $subject->getTableName());
}
/**
* @test
*/
#[Test]
public function providesDatabaseRowInheritedFromContentObjectRenderer(): void
{
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);

View file

@ -21,19 +21,16 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use WerkraumMedia\Calendar\Domain\Model\Day;
use WerkraumMedia\Calendar\Domain\Model\ForeignDataFactory;
use WerkraumMedia\Calendar\Domain\Model\IsDayActive;
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
/**
* @covers WerkraumMedia\Calendar\Domain\Model\Day
* @testdox A day
*/
#[TestDox('A day')]
class DayTest extends TestCase
{
use ForcePropertyTrait;
@ -44,9 +41,7 @@ class DayTest extends TestCase
parent::tearDown();
}
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new Day(
@ -56,9 +51,7 @@ class DayTest extends TestCase
self::assertInstanceOf(Day::class, $subject);
}
/**
* @test
*/
#[Test]
public function providesDateTimeInstance(): void
{
$dateTimeInstance = new \DateTime();
@ -69,9 +62,7 @@ class DayTest extends TestCase
self::assertInstanceOf(\DateTimeImmutable::class, $subject->getDateTimeInstance());
}
/**
* @test
*/
#[Test]
public function providedDateTimeInstanceHasExpectedDay(): void
{
$dateTimeInstance = new \DateTime();
@ -82,9 +73,7 @@ class DayTest extends TestCase
self::assertSame($dateTimeInstance->format('d.m.Y'), $subject->getDateTimeInstance()->format('d.m.Y'));
}
/**
* @test
*/
#[Test]
public function providedDateTimeInstanceHasMidnight(): void
{
$dateTimeInstance = new \DateTime();
@ -95,9 +84,7 @@ class DayTest extends TestCase
self::assertSame('00:00:00', $subject->getDateTimeInstance()->format('H:i:s'));
}
/**
* @test
*/
#[Test]
public function providesItselfAsUrlArgument(): void
{
$subject = new Day(new \DateTime('2020-10-19'));
@ -105,9 +92,7 @@ class DayTest extends TestCase
self::assertSame(['day' => '2020-10-19'], $subject->getAsUrlArgument());
}
/**
* @test
*/
#[Test]
public function isNotActiveIfNoForeignDataWithInterfaceExists(): void
{
$subject = new Day(new \DateTime('2020-10-19'));
@ -117,9 +102,7 @@ class DayTest extends TestCase
self::assertFalse($subject->isActive());
}
/**
* @test
*/
#[Test]
public function isNotActiveIfForeignDataIsNotActive(): void
{
$subject = new Day(new \DateTime('2020-10-19'));
@ -133,9 +116,7 @@ class DayTest extends TestCase
self::assertFalse($subject->isActive());
}
/**
* @test
*/
#[Test]
public function initializesForeignDataViaFactory(): void
{
$subject = new Day(new \DateTime('2020-10-19'));

View file

@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
use WerkraumMedia\Calendar\Domain\Model\Month;
use WerkraumMedia\Calendar\Domain\Model\Week;
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
/**
* @covers WerkraumMedia\Calendar\Domain\Model\Month
* @testdox A month
*/
#[TestDox('A month')]
class MonthTest extends TestCase
{
use ForcePropertyTrait;
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new Month(1, 2020);
@ -44,9 +41,7 @@ class MonthTest extends TestCase
self::assertInstanceOf(Month::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsPreviousMonthForSameYear(): void
{
$subject = new Month(2, 2020);
@ -55,9 +50,7 @@ class MonthTest extends TestCase
self::assertSame('2020', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsPreviousMonthForPreviousYear(): void
{
$subject = new Month(1, 2020);
@ -66,9 +59,7 @@ class MonthTest extends TestCase
self::assertSame('2019', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextMonthForSameYear(): void
{
$subject = new Month(1, 2020);
@ -77,9 +68,7 @@ class MonthTest extends TestCase
self::assertSame('2020', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextMonthForNextYear(): void
{
$subject = new Month(12, 2020);
@ -88,9 +77,7 @@ class MonthTest extends TestCase
self::assertSame('2021', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsFiveWeeksForDecember2020(): void
{
$subject = new Month(12, 2020);
@ -101,9 +88,7 @@ class MonthTest extends TestCase
self::assertSame('2021-01-03', $weeks[4]->getDays()[6]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsSixWeeksForNovember2020(): void
{
$subject = new Month(11, 2020);
@ -114,9 +99,7 @@ class MonthTest extends TestCase
self::assertSame('2020-12-06', $weeks[5]->getDays()[6]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsSameWeeksOnSecondCall(): void
{
$subject = new Month(11, 2020);
@ -124,9 +107,7 @@ class MonthTest extends TestCase
self::assertSame($subject->getWeeks(), $subject->getWeeks());
}
/**
* @test
*/
#[Test]
public function returnsAllDaysOfTheFebruaryMonth2021(): void
{
$subject = new Month(02, 2021);
@ -138,9 +119,7 @@ class MonthTest extends TestCase
self::assertSame('2021-02-28', $result[27]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsWeeksIfLastDecemberWeekIsInNextYear(): void
{
$subject = new Month(12, 2024);
@ -160,9 +139,7 @@ class MonthTest extends TestCase
self::assertSame('2024-12-29', $days[6]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsAllDaysOfTheJuneMonth2021(): void
{
$subject = new Month(06, 2021);
@ -174,9 +151,7 @@ class MonthTest extends TestCase
self::assertSame('2021-06-30', $result[29]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsSameDaysOnSecondCall(): void
{
$subject = new Month(06, 2021);
@ -184,9 +159,7 @@ class MonthTest extends TestCase
self::assertSame($subject->getDays(), $subject->getDays());
}
/**
* @test
*/
#[Test]
public function providesDateTimeInstance(): void
{
$subject = new Month(02, 2018);
@ -194,9 +167,7 @@ class MonthTest extends TestCase
self::assertSame('2018-02-01', $subject->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsAsUrlArguments(): void
{
$subject = new Month(02, 2018);
@ -207,9 +178,7 @@ class MonthTest extends TestCase
], $subject->getAsUrlArgument());
}
/**
* @test
*/
#[Test]
public function returnsNotActiveIfAllWeeksAreInactive(): void
{
$subject = new Month(02, 2018);
@ -222,9 +191,7 @@ class MonthTest extends TestCase
self::assertFalse($subject->isActive());
}
/**
* @test
*/
#[Test]
public function returnsActiveIfASingleWeekIsActive(): void
{
$subject = new Month(02, 2018);

View file

@ -21,18 +21,14 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use WerkraumMedia\Calendar\Domain\Model\Day;
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
/**
* @covers WerkraumMedia\Calendar\Domain\Model\NullDataFactory
*/
class NullDataFactoryTest extends TestCase
{
/**
* @test
*/
#[Test]
public function returnsNull(): void
{
$subject = new NullDataFactory();

View file

@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
use WerkraumMedia\Calendar\Domain\Model\Day;
use WerkraumMedia\Calendar\Domain\Model\Week;
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
/**
* @covers WerkraumMedia\Calendar\Domain\Model\Week
* @testdox A week
*/
#[TestDox('A week')]
class WeekTest extends TestCase
{
use ForcePropertyTrait;
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new Week(1, 2020);
@ -44,9 +41,7 @@ class WeekTest extends TestCase
self::assertInstanceOf(Week::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsSevenDays(): void
{
$subject = new Week(1, 2020);
@ -54,9 +49,7 @@ class WeekTest extends TestCase
self::assertCount(7, $subject->getDays());
}
/**
* @test
*/
#[Test]
public function returnsSameDaysOnSecondCall(): void
{
$subject = new Week(1, 2020);
@ -64,9 +57,7 @@ class WeekTest extends TestCase
self::assertSame($subject->getDays(), $subject->getDays());
}
/**
* @test
*/
#[Test]
public function returnsDaysForWeek1(): void
{
$subject = new Week(1, 2020);
@ -81,9 +72,7 @@ class WeekTest extends TestCase
self::assertSame('2020-01-05', $days[6]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsDaysForWeek53(): void
{
$subject = new Week(53, 2020);
@ -98,9 +87,7 @@ class WeekTest extends TestCase
self::assertSame('2021-01-03', $days[6]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsPreviousWeekForSameYear(): void
{
$subject = new Week(2, 2020);
@ -109,9 +96,7 @@ class WeekTest extends TestCase
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsPreviousWeekForYearSwitchFrom2019To2018(): void
{
$subject = new Week(1, 2019);
@ -120,9 +105,7 @@ class WeekTest extends TestCase
self::assertSame('2018', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsPreviousWeekForYearSwitchFrom2018To2017(): void
{
$subject = new Week(1, 2018);
@ -131,9 +114,7 @@ class WeekTest extends TestCase
self::assertSame('2017', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsPreviousWeekForPreviousYear(): void
{
$subject = new Week(1, 2021);
@ -142,9 +123,7 @@ class WeekTest extends TestCase
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextWeekForSameYear(): void
{
$subject = new Week(1, 2020);
@ -153,9 +132,7 @@ class WeekTest extends TestCase
self::assertSame('2020', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextWeekForNextYear(): void
{
$subject = new Week(53, 2020);
@ -164,9 +141,7 @@ class WeekTest extends TestCase
self::assertSame('2021', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextWeekForNextYearFrom2018To2019(): void
{
$subject = new Week(52, 2018);
@ -175,9 +150,7 @@ class WeekTest extends TestCase
self::assertSame('2019', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function providesDateTimeInstance(): void
{
$subject = new Week(52, 2018);
@ -186,9 +159,7 @@ class WeekTest extends TestCase
self::assertSame('2018-12-27 Thursday', $subject->getDateTimeInstance()->format('Y-m-d l'));
}
/**
* @test
*/
#[Test]
public function providesItselfAsUrlArgument(): void
{
$subject = new Week(52, 2018);
@ -199,9 +170,7 @@ class WeekTest extends TestCase
], $subject->getAsUrlArgument());
}
/**
* @test
*/
#[Test]
public function returnsNotActiveIfAllDaysAreInactive(): void
{
$subject = new Week(02, 2018);
@ -214,9 +183,7 @@ class WeekTest extends TestCase
self::assertFalse($subject->isActive());
}
/**
* @test
*/
#[Test]
public function returnsActiveIfASingleDayActive(): void
{
$subject = new Week(02, 2018);

View file

@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
use WerkraumMedia\Calendar\Domain\Model\Month;
use WerkraumMedia\Calendar\Domain\Model\Year;
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
/**
* @covers WerkraumMedia\Calendar\Domain\Model\Year
* @testdox A year
*/
#[TestDox('A year')]
class YearTest extends TestCase
{
use ForcePropertyTrait;
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new Year(2020);
@ -44,9 +41,7 @@ class YearTest extends TestCase
self::assertInstanceOf(Year::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsPreviousYear(): void
{
$subject = new Year(2020);
@ -57,9 +52,7 @@ class YearTest extends TestCase
self::assertSame('2019', $result->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsNextYear(): void
{
$subject = new Year(2020);
@ -70,9 +63,7 @@ class YearTest extends TestCase
self::assertSame('2021', $result->getDateTimeInstance()->format('Y'));
}
/**
* @test
*/
#[Test]
public function returnsAsUrlArguments(): void
{
$subject = new Year(2020);
@ -82,9 +73,7 @@ class YearTest extends TestCase
], $subject->getAsUrlArgument());
}
/**
* @test
*/
#[Test]
public function returnsMonthsForYear2020(): void
{
$subject = new Year(2020);
@ -96,13 +85,11 @@ class YearTest extends TestCase
foreach ($result as $index => $month) {
self::assertInstanceOf(Month::class, $month);
$monthNumber = $index + 1;
self::assertSame((string) $monthNumber, $month->getDateTimeInstance()->format('n'));
self::assertSame((string)$monthNumber, $month->getDateTimeInstance()->format('n'));
}
}
/**
* @test
*/
#[Test]
public function returnsSameMonthsOnSecondCall(): void
{
$subject = new Year(2020);
@ -110,9 +97,7 @@ class YearTest extends TestCase
self::assertSame($subject->getMonths(), $subject->getMonths());
}
/**
* @test
*/
#[Test]
public function returnsAllDaysFor2020(): void
{
$subject = new Year(2020);
@ -124,9 +109,7 @@ class YearTest extends TestCase
self::assertSame('2020-12-31', $result[365]->getDateTimeInstance()->format('Y-m-d'));
}
/**
* @test
*/
#[Test]
public function returnsNotActiveIfAllMonthsAreInactive(): void
{
$subject = new Year(2020);
@ -139,9 +122,7 @@ class YearTest extends TestCase
self::assertFalse($subject->isActive());
}
/**
* @test
*/
#[Test]
public function returnsActiveIfASingleMonthIsActive(): void
{
$subject = new Year(2020);

View file

@ -21,17 +21,13 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Events;
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
/**
* @covers WerkraumMedia\Calendar\Events\AssignTemplateVariables
*/
class AssignTemplateVariablesTest extends TestCase
{
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$subject = new AssignTemplateVariables(
@ -42,9 +38,7 @@ class AssignTemplateVariablesTest extends TestCase
self::assertInstanceOf(AssignTemplateVariables::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsPluginName(): void
{
$subject = new AssignTemplateVariables(
@ -57,9 +51,7 @@ class AssignTemplateVariablesTest extends TestCase
self::assertSame('Example', $result);
}
/**
* @test
*/
#[Test]
public function returnsVariables(): void
{
$subject = new AssignTemplateVariables(
@ -76,9 +68,7 @@ class AssignTemplateVariablesTest extends TestCase
], $result);
}
/**
* @test
*/
#[Test]
public function newVariablesOverwriteExistingVariables(): void
{
$subject = new AssignTemplateVariables(

View file

@ -11,16 +11,21 @@
],
"config": {
"sort-packages": true,
"lock": false,
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.3.0 || ^7.4.0 || ^8.0.0 || ^8.1.0 || ^8.2.0",
"typo3/cms-core": "^10.4 || ^11.5",
"typo3/cms-extbase": "^10.4 || ^11.5",
"typo3/cms-frontend": "^10.4 || ^11.5"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"typo3/cms-backend": "^12.4",
"typo3/cms-core": "^12.4",
"typo3/cms-extbase": "^12.4",
"typo3/cms-fluid-styled-content": "^12.4",
"typo3/cms-frontend": "^12.4"
},
"autoload": {
"psr-4": {
@ -34,14 +39,16 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symplify/easy-coding-standard": "^9.2",
"typo3/cms-fluid-styled-content": "^10.4 || ^11.5",
"typo3/testing-framework": "^6.6"
"codappix/typo3-php-datasets": "^1.5",
"friendsofphp/php-cs-fixer": "^3.11",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.5 || ^11.3",
"saschaegerer/phpstan-typo3": "^1.10",
"typo3/testing-framework": "^8.2"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"extension-key": "calendar",
"web-dir": ".Build/web"
}

35
ecs.php
View file

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/Classes',
__DIR__ . '/Tests',
__DIR__ . '/ext_emconf.php',
__DIR__ . '/ecs.php',
]);
$parameters->set(Option::SETS, [
// run and fix, one by one
// SetList::SPACES,
// SetList::ARRAY,
// SetList::DOCBLOCK,
// SetList::NAMESPACES,
// SetList::CONTROL_STRUCTURES,
// SetList::CLEAN_CODE,
SetList::PSR_12,
]);
$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);
};

View file

@ -10,7 +10,7 @@ $EM_CONF['calendar'] = [
'state' => 'alpha',
'uploadfolder' => 0,
'clearCacheOnLoad' => 0,
'version' => '1.1.1',
'version' => '2.0.0',
'constraints' => [
'depends' => [
'typo3' => '*',

10
phpstan.neon Normal file
View file

@ -0,0 +1,10 @@
parameters:
level: 'max'
paths:
- 'Classes'
- 'Configuration'
- 'Tests'
reportUnmatchedIgnoredErrors: true
ignoreErrors:
-
identifier: 'missingType.iterableValue'

View file

@ -1,21 +1,25 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
requireCoverageMetadata="false"
>
<source>
<include>
<directory suffix=".php">Classes</directory>
</include>
</source>
<testsuites>
<testsuite name="unit">
@ -26,12 +30,6 @@
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">Classes</directory>
</include>
</coverage>
<php>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>

52
shell.nix Normal file
View file

@ -0,0 +1,52 @@
{ pkgs ? import <nixpkgs> { } }:
let
php = pkgs.php82.buildEnv {
extensions = { enabled, all }: enabled ++ (with all; [
xdebug
]);
extraConfig = ''
xdebug.mode = debug
memory_limit = 4G
'';
};
inherit (php.packages) composer;
projectInstall = pkgs.writeShellApplication {
name = "project-install";
runtimeInputs = [
php
composer
];
text = ''
rm -rf vendor/ .Build/
composer install --prefer-dist --no-progress --working-dir="$PROJECT_ROOT"
'';
};
projectValidateComposer = pkgs.writeShellApplication {
name = "project-validate-composer";
runtimeInputs = [
php
composer
];
text = ''
composer validate
'';
};
in pkgs.mkShell {
name = "TYPO3 Extension Watchlist";
buildInputs = [
projectInstall
projectValidateComposer
php
composer
];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
export typo3DatabaseDriver=pdo_sqlite
'';
}