mirror of
https://github.com/werkraum-media/calendar.git
synced 2024-11-23 10:16:09 +01:00
TYPO3 v12 (#11)
This commit is contained in:
parent
b087098793
commit
891871a8ef
30 changed files with 453 additions and 453 deletions
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal 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
|
53
.github/workflows/ci.yaml
vendored
53
.github/workflows/ci.yaml
vendored
|
@ -20,11 +20,9 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-version:
|
php-version:
|
||||||
- 7.3
|
|
||||||
- 7.4
|
|
||||||
- 8.0
|
|
||||||
- 8.1
|
- 8.1
|
||||||
- 8.2
|
- 8.2
|
||||||
|
- 8.3
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -78,31 +76,27 @@ jobs:
|
||||||
with:
|
with:
|
||||||
coverage: none
|
coverage: none
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
php-version: "8.2"
|
php-version: "8.3"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer install --prefer-dist --no-progress --no-suggest
|
run: composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
- name: Coding Guideline
|
- name: Coding Guideline
|
||||||
run: ./vendor/bin/ecs
|
run: ./vendor/bin/php-cs-fixer fix --dry-run
|
||||||
|
|
||||||
tests:
|
phpstan:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- xml-linting
|
- xml-linting
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
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'
|
- php-version: '8.1'
|
||||||
typo3-version: '^11.5'
|
typo3-version: '^12.4'
|
||||||
- php-version: '8.2'
|
- php-version: '8.2'
|
||||||
typo3-version: '^11.5'
|
typo3-version: '^12.4'
|
||||||
|
- php-version: '8.3'
|
||||||
|
typo3-version: '^12.4'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -114,7 +108,36 @@ jobs:
|
||||||
php-version: "${{ matrix.php-version }}"
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
|
||||||
- name: Install dependencies
|
- 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
|
- name: PHPUnit Tests
|
||||||
run: ./vendor/bin/phpunit --testdox
|
run: ./vendor/bin/phpunit --testdox
|
||||||
|
|
63
.php-cs-fixer.dist.php
Normal file
63
.php-cs-fixer.dist.php
Normal 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);
|
|
@ -21,11 +21,14 @@ namespace WerkraumMedia\Calendar\Controller\Frontend;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use RuntimeException;
|
||||||
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
|
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
|
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
|
||||||
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Context;
|
use WerkraumMedia\Calendar\Domain\Model\Context;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\ContextSpecificFactory;
|
use WerkraumMedia\Calendar\Domain\Model\ContextSpecificFactory;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Day;
|
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\Domain\Model\Year;
|
||||||
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
|
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
|
||||||
|
|
||||||
class CalendarController extends ActionController
|
final class CalendarController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ForeignDataFactory
|
* @var ForeignDataFactory
|
||||||
|
@ -55,19 +58,19 @@ class CalendarController extends ActionController
|
||||||
$this->typoScriptService = $typoScriptService;
|
$this->typoScriptService = $typoScriptService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeAction()
|
public function initializeAction(): void
|
||||||
{
|
{
|
||||||
if ($this->foreignDataFactory instanceof ContextSpecificFactory) {
|
if ($this->foreignDataFactory instanceof ContextSpecificFactory) {
|
||||||
$this->foreignDataFactory->setContext(
|
$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) {
|
if ($this->request->hasArgument('year') === false) {
|
||||||
$this->request->setArguments([
|
$this->request = $this->request->withArguments([
|
||||||
'year' => [
|
'year' => [
|
||||||
'year' => $this->getDefaultArgumentValue('year'),
|
'year' => $this->getDefaultArgumentValue('year'),
|
||||||
],
|
],
|
||||||
|
@ -82,17 +85,19 @@ class CalendarController extends ActionController
|
||||||
/**
|
/**
|
||||||
* @Extbase\IgnoreValidation("year")
|
* @Extbase\IgnoreValidation("year")
|
||||||
*/
|
*/
|
||||||
public function yearAction(Year $year)
|
public function yearAction(Year $year): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->assignVariables([
|
$this->assignVariables([
|
||||||
'year' => $year,
|
'year' => $year,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $this->htmlResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeMonthAction()
|
public function initializeMonthAction(): void
|
||||||
{
|
{
|
||||||
if ($this->request->hasArgument('month') === false) {
|
if ($this->request->hasArgument('month') === false) {
|
||||||
$this->request->setArguments([
|
$this->request = $this->request->withArguments([
|
||||||
'month' => [
|
'month' => [
|
||||||
'month' => $this->getDefaultArgumentValue('month'),
|
'month' => $this->getDefaultArgumentValue('month'),
|
||||||
'year' => $this->getDefaultArgumentValue('year'),
|
'year' => $this->getDefaultArgumentValue('year'),
|
||||||
|
@ -108,17 +113,19 @@ class CalendarController extends ActionController
|
||||||
/**
|
/**
|
||||||
* @Extbase\IgnoreValidation("month")
|
* @Extbase\IgnoreValidation("month")
|
||||||
*/
|
*/
|
||||||
public function monthAction(Month $month)
|
public function monthAction(Month $month): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->assignVariables([
|
$this->assignVariables([
|
||||||
'month' => $month,
|
'month' => $month,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $this->htmlResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeWeekAction()
|
public function initializeWeekAction(): void
|
||||||
{
|
{
|
||||||
if ($this->request->hasArgument('week') === false) {
|
if ($this->request->hasArgument('week') === false) {
|
||||||
$this->request->setArguments([
|
$this->request = $this->request->withArguments([
|
||||||
'week' => [
|
'week' => [
|
||||||
'week' => $this->getDefaultArgumentValue('week'),
|
'week' => $this->getDefaultArgumentValue('week'),
|
||||||
'year' => $this->getDefaultArgumentValue('year'),
|
'year' => $this->getDefaultArgumentValue('year'),
|
||||||
|
@ -134,17 +141,19 @@ class CalendarController extends ActionController
|
||||||
/**
|
/**
|
||||||
* @Extbase\IgnoreValidation("week")
|
* @Extbase\IgnoreValidation("week")
|
||||||
*/
|
*/
|
||||||
public function weekAction(Week $week)
|
public function weekAction(Week $week): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->assignVariables([
|
$this->assignVariables([
|
||||||
'week' => $week,
|
'week' => $week,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $this->htmlResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initializeDayAction()
|
public function initializeDayAction(): void
|
||||||
{
|
{
|
||||||
if ($this->request->hasArgument('day') === false) {
|
if ($this->request->hasArgument('day') === false) {
|
||||||
$this->request->setArguments([
|
$this->request = $this->request->withArguments([
|
||||||
'day' => [
|
'day' => [
|
||||||
'day' => $this->getDefaultArgumentValue('day'),
|
'day' => $this->getDefaultArgumentValue('day'),
|
||||||
],
|
],
|
||||||
|
@ -167,11 +176,13 @@ class CalendarController extends ActionController
|
||||||
/**
|
/**
|
||||||
* @Extbase\IgnoreValidation("day")
|
* @Extbase\IgnoreValidation("day")
|
||||||
*/
|
*/
|
||||||
public function dayAction(Day $day)
|
public function dayAction(Day $day): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->assignVariables([
|
$this->assignVariables([
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $this->htmlResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assignVariables(array $variables): void
|
private function assignVariables(array $variables): void
|
||||||
|
@ -202,12 +213,23 @@ class CalendarController extends ActionController
|
||||||
'day' => date('Y-m-d'),
|
'day' => date('Y-m-d'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$value = $this->configurationManager->getContentObject()->stdWrapValue(
|
$value = $this->getContentObjectRenderer()->stdWrapValue(
|
||||||
$argumentName,
|
$argumentName,
|
||||||
$arguments,
|
$arguments,
|
||||||
$fallbackValues[$argumentName]
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
||||||
|
|
||||||
class Day
|
class Day
|
||||||
{
|
{
|
||||||
|
@ -44,7 +43,6 @@ class Day
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\DateTime $day
|
\DateTime $day
|
||||||
) {
|
) {
|
||||||
$this->periods = new ObjectStorage();
|
|
||||||
$this->day = \DateTimeImmutable::createFromMutable($day)->modify('midnight');
|
$this->day = \DateTimeImmutable::createFromMutable($day)->modify('midnight');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ class Day
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getForeignData()
|
public function getForeignData(): mixed
|
||||||
{
|
{
|
||||||
$this->initializeForeignData();
|
$this->initializeForeignData();
|
||||||
|
|
||||||
|
|
|
@ -27,5 +27,5 @@ interface ForeignDataFactory
|
||||||
* Receives a specific day and may return arbirtrary data.
|
* Receives a specific day and may return arbirtrary data.
|
||||||
* This data is attached to the day and available through getter.
|
* This data is attached to the day and available through getter.
|
||||||
*/
|
*/
|
||||||
public function getData(Day $day);
|
public function getData(Day $day): mixed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
||||||
|
|
||||||
class Month
|
class Month
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace WerkraumMedia\Calendar\Domain\Model;
|
||||||
|
|
||||||
class NullDataFactory implements ForeignDataFactory
|
class NullDataFactory implements ForeignDataFactory
|
||||||
{
|
{
|
||||||
public function getData(Day $day)
|
public function getData(Day $day): mixed
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ namespace WerkraumMedia\Calendar\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
||||||
|
|
||||||
class Year
|
class Year
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
36
Documentation/Changelog/2.0.0.rst
Normal file
36
Documentation/Changelog/2.0.0.rst
Normal 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
|
||||||
|
|
29
Tests/Fixtures/BasicDatabase.php
Normal file
29
Tests/Fixtures/BasicDatabase.php
Normal 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">
|
||||||
|
',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
|
@ -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>
|
|
|
@ -40,7 +40,7 @@ class ExampleDataFactory implements ForeignDataFactory, ContextSpecificFactory
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getData(Day $day)
|
public function getData(Day $day): mixed
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'exampleKey' => 'exampleValue',
|
'exampleKey' => 'exampleValue',
|
||||||
|
|
|
@ -11,7 +11,7 @@ page {
|
||||||
10 =< tt_content.calendar_example.20
|
10 =< tt_content.calendar_example.20
|
||||||
}
|
}
|
||||||
|
|
||||||
[request.getQueryParams()['typoScriptDefaults'] == 1]
|
[traverse(request.getQueryParams(), 'typoScriptDefaults') == 1]
|
||||||
plugin.tx_calendar_example {
|
plugin.tx_calendar_example {
|
||||||
settings {
|
settings {
|
||||||
arguments {
|
arguments {
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace WerkraumMedia\Calendar\Tests;
|
||||||
|
|
||||||
trait ForcePropertyTrait
|
trait ForcePropertyTrait
|
||||||
{
|
{
|
||||||
protected function forceProperty($subject, string $name, $value)
|
protected function forceProperty(object $subject, string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
$objectReflection = new \ReflectionObject($subject);
|
$objectReflection = new \ReflectionObject($subject);
|
||||||
$property = $objectReflection->getProperty($name);
|
$property = $objectReflection->getProperty($name);
|
||||||
|
|
|
@ -23,30 +23,32 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WerkraumMedia\Calendar\Tests\Functional;
|
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\Framework\Frontend\InternalRequest;
|
||||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||||
use WerkraumMedia\Calendar\Controller\Frontend\CalendarController;
|
|
||||||
|
|
||||||
/**
|
#[TestDox('Calendar controller renders with')]
|
||||||
* @coversNothing
|
|
||||||
* @testdox Calendar controller renders with
|
|
||||||
*/
|
|
||||||
class CalendarControllerTest extends FunctionalTestCase
|
class CalendarControllerTest extends FunctionalTestCase
|
||||||
{
|
{
|
||||||
protected $coreExtensionsToLoad = [
|
use TestingFramework;
|
||||||
|
|
||||||
|
protected array $coreExtensionsToLoad = [
|
||||||
'fluid_styled_content',
|
'fluid_styled_content',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $testExtensionsToLoad = [
|
protected array $testExtensionsToLoad = [
|
||||||
'typo3conf/ext/calendar',
|
'typo3conf/ext/calendar',
|
||||||
'typo3conf/ext/calendar/Tests/Fixtures/calendar_example',
|
'typo3conf/ext/calendar/Tests/Fixtures/calendar_example',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $pathsToLinkInTestInstance = [
|
protected array $pathsToLinkInTestInstance = [
|
||||||
'typo3conf/ext/calendar/Tests/Fixtures/Sites' => 'typo3conf/sites',
|
'typo3conf/ext/calendar/Tests/Fixtures/Sites' => 'typo3conf/sites',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $configurationToUseInTestInstance = [
|
protected array $configurationToUseInTestInstance = [
|
||||||
'FE' => [
|
'FE' => [
|
||||||
'cacheHash' => [
|
'cacheHash' => [
|
||||||
'excludedParameters' => [
|
'excludedParameters' => [
|
||||||
|
@ -61,45 +63,39 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->importDataSet(__DIR__ . '/../Fixtures/BasicDatabase.xml');
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/BasicDatabase.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function modifiedVariablesForCurrentDay(): void
|
public function modifiedVariablesForCurrentDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('modifiedVariable', $html);
|
self::assertStringContainsString('modifiedVariable', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function pluginNameForCurrentDay(): void
|
public function pluginNameForCurrentDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('PluginName: Example', $html);
|
self::assertStringContainsString('PluginName: Example', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function contextForCurrentDay(): void
|
public function contextForCurrentDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -107,14 +103,12 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('Title: Page Title', $html);
|
self::assertStringContainsString('Title: Page Title', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function customDataForCurrentDay(): void
|
public function customDataForCurrentDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -122,75 +116,65 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('exampleValue', $html);
|
self::assertStringContainsString('exampleValue', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function configuredDay(): void
|
public function configuredDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('03.11.1988', $html);
|
self::assertStringContainsString('03.11.1988', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedDay(): void
|
public function providedDay(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[day][day]', '2020-11-03');
|
$request = $request->withQueryParameter('tx_calendar_example[day][day]', '2020-11-03');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('03.11.2020', $html);
|
self::assertStringContainsString('03.11.2020', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function modifiedVariablesForCurrentWeek(): void
|
public function modifiedVariablesForCurrentWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('modifiedVariable', $html);
|
self::assertStringContainsString('modifiedVariable', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function pluginNameForCurrentWeek(): void
|
public function pluginNameForCurrentWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('PluginName: Example', $html);
|
self::assertStringContainsString('PluginName: Example', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function contextForCurrentWeek(): void
|
public function contextForCurrentWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -198,15 +182,13 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('Title: Page Title', $html);
|
self::assertStringContainsString('Title: Page Title', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function customDataForCurrentWeek(): void
|
public function customDataForCurrentWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -214,25 +196,21 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('exampleValue', $html);
|
self::assertStringContainsString('exampleValue', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function configuredWeek(): void
|
public function configuredWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'week');
|
||||||
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('12 1988', $html);
|
self::assertStringContainsString('12 1988', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedWeek(): void
|
public function providedWeek(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$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[action]', 'week');
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[week][week]', '02');
|
$request = $request->withQueryParameter('tx_calendar_example[week][week]', '02');
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[week][year]', '2020');
|
$request = $request->withQueryParameter('tx_calendar_example[week][year]', '2020');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('02 2020', $html);
|
self::assertStringContainsString('02 2020', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function modifiedVariablesForCurrentMonth(): void
|
public function modifiedVariablesForCurrentMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('modifiedVariable', $html);
|
self::assertStringContainsString('modifiedVariable', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function pluginNameForCurrentMonth(): void
|
public function pluginNameForCurrentMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('PluginName: Example', $html);
|
self::assertStringContainsString('PluginName: Example', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function contextForCurrentMonth(): void
|
public function contextForCurrentMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -293,41 +265,35 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('Title: Page Title', $html);
|
self::assertStringContainsString('Title: Page Title', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function customDataForCurrentMonth(): void
|
public function customDataForCurrentMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$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);
|
self::assertStringContainsString('exampleValue', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function configuredMonth(): void
|
public function configuredMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'month');
|
||||||
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('November 1988', $html);
|
self::assertStringContainsString('November 1988', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedMonth(): void
|
public function providedMonth(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$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[action]', 'month');
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[month][month]', '11');
|
$request = $request->withQueryParameter('tx_calendar_example[month][month]', '11');
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[month][year]', '2020');
|
$request = $request->withQueryParameter('tx_calendar_example[month][year]', '2020');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -343,45 +309,39 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('exampleValue', $html);
|
self::assertStringContainsString('exampleValue', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function modifiedVariablesForCurrentYear(): void
|
public function modifiedVariablesForCurrentYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('modifiedVariable', $html);
|
self::assertStringContainsString('modifiedVariable', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function pluginNameForCurrentYear(): void
|
public function pluginNameForCurrentYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('PluginName: Example', $html);
|
self::assertStringContainsString('PluginName: Example', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function contextForCurrentYear(): void
|
public function contextForCurrentYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -389,15 +349,13 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('Title: Page Title', $html);
|
self::assertStringContainsString('Title: Page Title', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function customDataForCurrentYear(): void
|
public function customDataForCurrentYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
@ -405,32 +363,28 @@ class CalendarControllerTest extends FunctionalTestCase
|
||||||
self::assertStringContainsString('exampleValue', $html);
|
self::assertStringContainsString('exampleValue', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function configuredYear(): void
|
public function configuredYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
$request = $request->withQueryParameter('typoScriptDefaults', '1');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
self::assertStringContainsString('1988', $html);
|
self::assertStringContainsString('1988', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedYear(): void
|
public function providedYear(): void
|
||||||
{
|
{
|
||||||
$request = new InternalRequest();
|
$request = new InternalRequest();
|
||||||
$request = $request->withPageId(1);
|
$request = $request->withPageId(1);
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
$request = $request->withQueryParameter('tx_calendar_example[action]', 'year');
|
||||||
$request = $request->withQueryParameter('tx_calendar_example[year][year]', '2020');
|
$request = $request->withQueryParameter('tx_calendar_example[year][year]', '2020');
|
||||||
$result = $this->executeFrontendRequest($request);
|
$result = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
self::assertSame(200, $result->getStatusCode());
|
self::assertSame(200, $result->getStatusCode());
|
||||||
$html = $result->getBody()->__toString();
|
$html = $result->getBody()->__toString();
|
||||||
|
|
|
@ -23,32 +23,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Context;
|
use WerkraumMedia\Calendar\Domain\Model\Context;
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \WerkraumMedia\Calendar\Domain\Model\Context
|
|
||||||
*/
|
|
||||||
class ContextTest extends TestCase
|
class ContextTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[Test]
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
public function canBeCreatedFromContentObjectRenderer(): void
|
public function canBeCreatedFromContentObjectRenderer(): void
|
||||||
{
|
{
|
||||||
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
||||||
|
@ -57,9 +39,7 @@ class ContextTest extends TestCase
|
||||||
self::assertInstanceOf(Context::class, $subject);
|
self::assertInstanceOf(Context::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesTableNameInheritedFromContentObjectRenderer(): void
|
public function providesTableNameInheritedFromContentObjectRenderer(): void
|
||||||
{
|
{
|
||||||
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
||||||
|
@ -69,9 +49,7 @@ class ContextTest extends TestCase
|
||||||
self::assertSame('tx_calendar_example_table', $subject->getTableName());
|
self::assertSame('tx_calendar_example_table', $subject->getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesDatabaseRowInheritedFromContentObjectRenderer(): void
|
public function providesDatabaseRowInheritedFromContentObjectRenderer(): void
|
||||||
{
|
{
|
||||||
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
$contentObjectRenderer = $this->createStub(ContentObjectRenderer::class);
|
||||||
|
|
|
@ -21,19 +21,16 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use PHPUnit\Framework\Attributes\TestDox;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Day;
|
use WerkraumMedia\Calendar\Domain\Model\Day;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\ForeignDataFactory;
|
use WerkraumMedia\Calendar\Domain\Model\ForeignDataFactory;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\IsDayActive;
|
use WerkraumMedia\Calendar\Domain\Model\IsDayActive;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
|
|
||||||
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[TestDox('A day')]
|
||||||
* @covers WerkraumMedia\Calendar\Domain\Model\Day
|
|
||||||
* @testdox A day
|
|
||||||
*/
|
|
||||||
class DayTest extends TestCase
|
class DayTest extends TestCase
|
||||||
{
|
{
|
||||||
use ForcePropertyTrait;
|
use ForcePropertyTrait;
|
||||||
|
@ -44,9 +41,7 @@ class DayTest extends TestCase
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function canBeCreated(): void
|
public function canBeCreated(): void
|
||||||
{
|
{
|
||||||
$subject = new Day(
|
$subject = new Day(
|
||||||
|
@ -56,9 +51,7 @@ class DayTest extends TestCase
|
||||||
self::assertInstanceOf(Day::class, $subject);
|
self::assertInstanceOf(Day::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesDateTimeInstance(): void
|
public function providesDateTimeInstance(): void
|
||||||
{
|
{
|
||||||
$dateTimeInstance = new \DateTime();
|
$dateTimeInstance = new \DateTime();
|
||||||
|
@ -69,9 +62,7 @@ class DayTest extends TestCase
|
||||||
self::assertInstanceOf(\DateTimeImmutable::class, $subject->getDateTimeInstance());
|
self::assertInstanceOf(\DateTimeImmutable::class, $subject->getDateTimeInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedDateTimeInstanceHasExpectedDay(): void
|
public function providedDateTimeInstanceHasExpectedDay(): void
|
||||||
{
|
{
|
||||||
$dateTimeInstance = new \DateTime();
|
$dateTimeInstance = new \DateTime();
|
||||||
|
@ -82,9 +73,7 @@ class DayTest extends TestCase
|
||||||
self::assertSame($dateTimeInstance->format('d.m.Y'), $subject->getDateTimeInstance()->format('d.m.Y'));
|
self::assertSame($dateTimeInstance->format('d.m.Y'), $subject->getDateTimeInstance()->format('d.m.Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providedDateTimeInstanceHasMidnight(): void
|
public function providedDateTimeInstanceHasMidnight(): void
|
||||||
{
|
{
|
||||||
$dateTimeInstance = new \DateTime();
|
$dateTimeInstance = new \DateTime();
|
||||||
|
@ -95,9 +84,7 @@ class DayTest extends TestCase
|
||||||
self::assertSame('00:00:00', $subject->getDateTimeInstance()->format('H:i:s'));
|
self::assertSame('00:00:00', $subject->getDateTimeInstance()->format('H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesItselfAsUrlArgument(): void
|
public function providesItselfAsUrlArgument(): void
|
||||||
{
|
{
|
||||||
$subject = new Day(new \DateTime('2020-10-19'));
|
$subject = new Day(new \DateTime('2020-10-19'));
|
||||||
|
@ -105,9 +92,7 @@ class DayTest extends TestCase
|
||||||
self::assertSame(['day' => '2020-10-19'], $subject->getAsUrlArgument());
|
self::assertSame(['day' => '2020-10-19'], $subject->getAsUrlArgument());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function isNotActiveIfNoForeignDataWithInterfaceExists(): void
|
public function isNotActiveIfNoForeignDataWithInterfaceExists(): void
|
||||||
{
|
{
|
||||||
$subject = new Day(new \DateTime('2020-10-19'));
|
$subject = new Day(new \DateTime('2020-10-19'));
|
||||||
|
@ -117,9 +102,7 @@ class DayTest extends TestCase
|
||||||
self::assertFalse($subject->isActive());
|
self::assertFalse($subject->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function isNotActiveIfForeignDataIsNotActive(): void
|
public function isNotActiveIfForeignDataIsNotActive(): void
|
||||||
{
|
{
|
||||||
$subject = new Day(new \DateTime('2020-10-19'));
|
$subject = new Day(new \DateTime('2020-10-19'));
|
||||||
|
@ -133,9 +116,7 @@ class DayTest extends TestCase
|
||||||
self::assertFalse($subject->isActive());
|
self::assertFalse($subject->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function initializesForeignDataViaFactory(): void
|
public function initializesForeignDataViaFactory(): void
|
||||||
{
|
{
|
||||||
$subject = new Day(new \DateTime('2020-10-19'));
|
$subject = new Day(new \DateTime('2020-10-19'));
|
||||||
|
|
|
@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use PHPUnit\Framework\Attributes\TestDox;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Month;
|
use WerkraumMedia\Calendar\Domain\Model\Month;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Week;
|
use WerkraumMedia\Calendar\Domain\Model\Week;
|
||||||
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[TestDox('A month')]
|
||||||
* @covers WerkraumMedia\Calendar\Domain\Model\Month
|
|
||||||
* @testdox A month
|
|
||||||
*/
|
|
||||||
class MonthTest extends TestCase
|
class MonthTest extends TestCase
|
||||||
{
|
{
|
||||||
use ForcePropertyTrait;
|
use ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function canBeCreated(): void
|
public function canBeCreated(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(1, 2020);
|
$subject = new Month(1, 2020);
|
||||||
|
@ -44,9 +41,7 @@ class MonthTest extends TestCase
|
||||||
self::assertInstanceOf(Month::class, $subject);
|
self::assertInstanceOf(Month::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousMonthForSameYear(): void
|
public function returnsPreviousMonthForSameYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(2, 2020);
|
$subject = new Month(2, 2020);
|
||||||
|
@ -55,9 +50,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame('2020', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2020', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousMonthForPreviousYear(): void
|
public function returnsPreviousMonthForPreviousYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(1, 2020);
|
$subject = new Month(1, 2020);
|
||||||
|
@ -66,9 +59,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame('2019', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2019', $subject->getPreviousMonth()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextMonthForSameYear(): void
|
public function returnsNextMonthForSameYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(1, 2020);
|
$subject = new Month(1, 2020);
|
||||||
|
@ -77,9 +68,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame('2020', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2020', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextMonthForNextYear(): void
|
public function returnsNextMonthForNextYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(12, 2020);
|
$subject = new Month(12, 2020);
|
||||||
|
@ -88,9 +77,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame('2021', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2021', $subject->getNextMonth()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsFiveWeeksForDecember2020(): void
|
public function returnsFiveWeeksForDecember2020(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(12, 2020);
|
$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'));
|
self::assertSame('2021-01-03', $weeks[4]->getDays()[6]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSixWeeksForNovember2020(): void
|
public function returnsSixWeeksForNovember2020(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(11, 2020);
|
$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'));
|
self::assertSame('2020-12-06', $weeks[5]->getDays()[6]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSameWeeksOnSecondCall(): void
|
public function returnsSameWeeksOnSecondCall(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(11, 2020);
|
$subject = new Month(11, 2020);
|
||||||
|
@ -124,9 +107,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame($subject->getWeeks(), $subject->getWeeks());
|
self::assertSame($subject->getWeeks(), $subject->getWeeks());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsAllDaysOfTheFebruaryMonth2021(): void
|
public function returnsAllDaysOfTheFebruaryMonth2021(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(02, 2021);
|
$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'));
|
self::assertSame('2021-02-28', $result[27]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsWeeksIfLastDecemberWeekIsInNextYear(): void
|
public function returnsWeeksIfLastDecemberWeekIsInNextYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(12, 2024);
|
$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'));
|
self::assertSame('2024-12-29', $days[6]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsAllDaysOfTheJuneMonth2021(): void
|
public function returnsAllDaysOfTheJuneMonth2021(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(06, 2021);
|
$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'));
|
self::assertSame('2021-06-30', $result[29]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSameDaysOnSecondCall(): void
|
public function returnsSameDaysOnSecondCall(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(06, 2021);
|
$subject = new Month(06, 2021);
|
||||||
|
@ -184,9 +159,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame($subject->getDays(), $subject->getDays());
|
self::assertSame($subject->getDays(), $subject->getDays());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesDateTimeInstance(): void
|
public function providesDateTimeInstance(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(02, 2018);
|
$subject = new Month(02, 2018);
|
||||||
|
@ -194,9 +167,7 @@ class MonthTest extends TestCase
|
||||||
self::assertSame('2018-02-01', $subject->getDateTimeInstance()->format('Y-m-d'));
|
self::assertSame('2018-02-01', $subject->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsAsUrlArguments(): void
|
public function returnsAsUrlArguments(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(02, 2018);
|
$subject = new Month(02, 2018);
|
||||||
|
@ -207,9 +178,7 @@ class MonthTest extends TestCase
|
||||||
], $subject->getAsUrlArgument());
|
], $subject->getAsUrlArgument());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNotActiveIfAllWeeksAreInactive(): void
|
public function returnsNotActiveIfAllWeeksAreInactive(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(02, 2018);
|
$subject = new Month(02, 2018);
|
||||||
|
@ -222,9 +191,7 @@ class MonthTest extends TestCase
|
||||||
self::assertFalse($subject->isActive());
|
self::assertFalse($subject->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsActiveIfASingleWeekIsActive(): void
|
public function returnsActiveIfASingleWeekIsActive(): void
|
||||||
{
|
{
|
||||||
$subject = new Month(02, 2018);
|
$subject = new Month(02, 2018);
|
||||||
|
|
|
@ -21,18 +21,14 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Day;
|
use WerkraumMedia\Calendar\Domain\Model\Day;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
|
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WerkraumMedia\Calendar\Domain\Model\NullDataFactory
|
|
||||||
*/
|
|
||||||
class NullDataFactoryTest extends TestCase
|
class NullDataFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNull(): void
|
public function returnsNull(): void
|
||||||
{
|
{
|
||||||
$subject = new NullDataFactory();
|
$subject = new NullDataFactory();
|
||||||
|
|
|
@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use PHPUnit\Framework\Attributes\TestDox;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Day;
|
use WerkraumMedia\Calendar\Domain\Model\Day;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Week;
|
use WerkraumMedia\Calendar\Domain\Model\Week;
|
||||||
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[TestDox('A week')]
|
||||||
* @covers WerkraumMedia\Calendar\Domain\Model\Week
|
|
||||||
* @testdox A week
|
|
||||||
*/
|
|
||||||
class WeekTest extends TestCase
|
class WeekTest extends TestCase
|
||||||
{
|
{
|
||||||
use ForcePropertyTrait;
|
use ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function canBeCreated(): void
|
public function canBeCreated(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2020);
|
$subject = new Week(1, 2020);
|
||||||
|
@ -44,9 +41,7 @@ class WeekTest extends TestCase
|
||||||
self::assertInstanceOf(Week::class, $subject);
|
self::assertInstanceOf(Week::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSevenDays(): void
|
public function returnsSevenDays(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2020);
|
$subject = new Week(1, 2020);
|
||||||
|
@ -54,9 +49,7 @@ class WeekTest extends TestCase
|
||||||
self::assertCount(7, $subject->getDays());
|
self::assertCount(7, $subject->getDays());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSameDaysOnSecondCall(): void
|
public function returnsSameDaysOnSecondCall(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2020);
|
$subject = new Week(1, 2020);
|
||||||
|
@ -64,9 +57,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame($subject->getDays(), $subject->getDays());
|
self::assertSame($subject->getDays(), $subject->getDays());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsDaysForWeek1(): void
|
public function returnsDaysForWeek1(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2020);
|
$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'));
|
self::assertSame('2020-01-05', $days[6]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsDaysForWeek53(): void
|
public function returnsDaysForWeek53(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(53, 2020);
|
$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'));
|
self::assertSame('2021-01-03', $days[6]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousWeekForSameYear(): void
|
public function returnsPreviousWeekForSameYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(2, 2020);
|
$subject = new Week(2, 2020);
|
||||||
|
@ -109,9 +96,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousWeekForYearSwitchFrom2019To2018(): void
|
public function returnsPreviousWeekForYearSwitchFrom2019To2018(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2019);
|
$subject = new Week(1, 2019);
|
||||||
|
@ -120,9 +105,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2018', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2018', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousWeekForYearSwitchFrom2018To2017(): void
|
public function returnsPreviousWeekForYearSwitchFrom2018To2017(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2018);
|
$subject = new Week(1, 2018);
|
||||||
|
@ -131,9 +114,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2017', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2017', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousWeekForPreviousYear(): void
|
public function returnsPreviousWeekForPreviousYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2021);
|
$subject = new Week(1, 2021);
|
||||||
|
@ -142,9 +123,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2020', $subject->getPreviousWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextWeekForSameYear(): void
|
public function returnsNextWeekForSameYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(1, 2020);
|
$subject = new Week(1, 2020);
|
||||||
|
@ -153,9 +132,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2020', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2020', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextWeekForNextYear(): void
|
public function returnsNextWeekForNextYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(53, 2020);
|
$subject = new Week(53, 2020);
|
||||||
|
@ -164,9 +141,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2021', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2021', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextWeekForNextYearFrom2018To2019(): void
|
public function returnsNextWeekForNextYearFrom2018To2019(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(52, 2018);
|
$subject = new Week(52, 2018);
|
||||||
|
@ -175,9 +150,7 @@ class WeekTest extends TestCase
|
||||||
self::assertSame('2019', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
self::assertSame('2019', $subject->getNextWeek()->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesDateTimeInstance(): void
|
public function providesDateTimeInstance(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(52, 2018);
|
$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'));
|
self::assertSame('2018-12-27 Thursday', $subject->getDateTimeInstance()->format('Y-m-d l'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function providesItselfAsUrlArgument(): void
|
public function providesItselfAsUrlArgument(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(52, 2018);
|
$subject = new Week(52, 2018);
|
||||||
|
@ -199,9 +170,7 @@ class WeekTest extends TestCase
|
||||||
], $subject->getAsUrlArgument());
|
], $subject->getAsUrlArgument());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNotActiveIfAllDaysAreInactive(): void
|
public function returnsNotActiveIfAllDaysAreInactive(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(02, 2018);
|
$subject = new Week(02, 2018);
|
||||||
|
@ -214,9 +183,7 @@ class WeekTest extends TestCase
|
||||||
self::assertFalse($subject->isActive());
|
self::assertFalse($subject->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsActiveIfASingleDayActive(): void
|
public function returnsActiveIfASingleDayActive(): void
|
||||||
{
|
{
|
||||||
$subject = new Week(02, 2018);
|
$subject = new Week(02, 2018);
|
||||||
|
|
|
@ -21,22 +21,19 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use PHPUnit\Framework\Attributes\TestDox;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Month;
|
use WerkraumMedia\Calendar\Domain\Model\Month;
|
||||||
use WerkraumMedia\Calendar\Domain\Model\Year;
|
use WerkraumMedia\Calendar\Domain\Model\Year;
|
||||||
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
use WerkraumMedia\Calendar\Tests\ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[TestDox('A year')]
|
||||||
* @covers WerkraumMedia\Calendar\Domain\Model\Year
|
|
||||||
* @testdox A year
|
|
||||||
*/
|
|
||||||
class YearTest extends TestCase
|
class YearTest extends TestCase
|
||||||
{
|
{
|
||||||
use ForcePropertyTrait;
|
use ForcePropertyTrait;
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function canBeCreated(): void
|
public function canBeCreated(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -44,9 +41,7 @@ class YearTest extends TestCase
|
||||||
self::assertInstanceOf(Year::class, $subject);
|
self::assertInstanceOf(Year::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPreviousYear(): void
|
public function returnsPreviousYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -57,9 +52,7 @@ class YearTest extends TestCase
|
||||||
self::assertSame('2019', $result->getDateTimeInstance()->format('Y'));
|
self::assertSame('2019', $result->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNextYear(): void
|
public function returnsNextYear(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -70,9 +63,7 @@ class YearTest extends TestCase
|
||||||
self::assertSame('2021', $result->getDateTimeInstance()->format('Y'));
|
self::assertSame('2021', $result->getDateTimeInstance()->format('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsAsUrlArguments(): void
|
public function returnsAsUrlArguments(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -82,9 +73,7 @@ class YearTest extends TestCase
|
||||||
], $subject->getAsUrlArgument());
|
], $subject->getAsUrlArgument());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsMonthsForYear2020(): void
|
public function returnsMonthsForYear2020(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -100,9 +89,7 @@ class YearTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsSameMonthsOnSecondCall(): void
|
public function returnsSameMonthsOnSecondCall(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -110,9 +97,7 @@ class YearTest extends TestCase
|
||||||
self::assertSame($subject->getMonths(), $subject->getMonths());
|
self::assertSame($subject->getMonths(), $subject->getMonths());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsAllDaysFor2020(): void
|
public function returnsAllDaysFor2020(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -124,9 +109,7 @@ class YearTest extends TestCase
|
||||||
self::assertSame('2020-12-31', $result[365]->getDateTimeInstance()->format('Y-m-d'));
|
self::assertSame('2020-12-31', $result[365]->getDateTimeInstance()->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsNotActiveIfAllMonthsAreInactive(): void
|
public function returnsNotActiveIfAllMonthsAreInactive(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
@ -139,9 +122,7 @@ class YearTest extends TestCase
|
||||||
self::assertFalse($subject->isActive());
|
self::assertFalse($subject->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsActiveIfASingleMonthIsActive(): void
|
public function returnsActiveIfASingleMonthIsActive(): void
|
||||||
{
|
{
|
||||||
$subject = new Year(2020);
|
$subject = new Year(2020);
|
||||||
|
|
|
@ -21,17 +21,13 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Events;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
|
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers WerkraumMedia\Calendar\Events\AssignTemplateVariables
|
|
||||||
*/
|
|
||||||
class AssignTemplateVariablesTest extends TestCase
|
class AssignTemplateVariablesTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function canBeCreated(): void
|
public function canBeCreated(): void
|
||||||
{
|
{
|
||||||
$subject = new AssignTemplateVariables(
|
$subject = new AssignTemplateVariables(
|
||||||
|
@ -42,9 +38,7 @@ class AssignTemplateVariablesTest extends TestCase
|
||||||
self::assertInstanceOf(AssignTemplateVariables::class, $subject);
|
self::assertInstanceOf(AssignTemplateVariables::class, $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsPluginName(): void
|
public function returnsPluginName(): void
|
||||||
{
|
{
|
||||||
$subject = new AssignTemplateVariables(
|
$subject = new AssignTemplateVariables(
|
||||||
|
@ -57,9 +51,7 @@ class AssignTemplateVariablesTest extends TestCase
|
||||||
self::assertSame('Example', $result);
|
self::assertSame('Example', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function returnsVariables(): void
|
public function returnsVariables(): void
|
||||||
{
|
{
|
||||||
$subject = new AssignTemplateVariables(
|
$subject = new AssignTemplateVariables(
|
||||||
|
@ -76,9 +68,7 @@ class AssignTemplateVariablesTest extends TestCase
|
||||||
], $result);
|
], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function newVariablesOverwriteExistingVariables(): void
|
public function newVariablesOverwriteExistingVariables(): void
|
||||||
{
|
{
|
||||||
$subject = new AssignTemplateVariables(
|
$subject = new AssignTemplateVariables(
|
||||||
|
|
|
@ -11,16 +11,21 @@
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
|
"lock": false,
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
"typo3/class-alias-loader": true,
|
"typo3/class-alias-loader": true,
|
||||||
"typo3/cms-composer-installers": true
|
"typo3/cms-composer-installers": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3.0 || ^7.4.0 || ^8.0.0 || ^8.1.0 || ^8.2.0",
|
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
|
||||||
"typo3/cms-core": "^10.4 || ^11.5",
|
"typo3/cms-backend": "^12.4",
|
||||||
"typo3/cms-extbase": "^10.4 || ^11.5",
|
"typo3/cms-core": "^12.4",
|
||||||
"typo3/cms-frontend": "^10.4 || ^11.5"
|
"typo3/cms-extbase": "^12.4",
|
||||||
|
"typo3/cms-fluid-styled-content": "^12.4",
|
||||||
|
"typo3/cms-frontend": "^12.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -34,14 +39,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.5",
|
"codappix/typo3-php-datasets": "^1.5",
|
||||||
"symplify/easy-coding-standard": "^9.2",
|
"friendsofphp/php-cs-fixer": "^3.11",
|
||||||
"typo3/cms-fluid-styled-content": "^10.4 || ^11.5",
|
"phpstan/phpstan": "^1.12",
|
||||||
"typo3/testing-framework": "^6.6"
|
"phpstan/phpstan-phpunit": "^1.0",
|
||||||
|
"phpunit/phpunit": "^10.5 || ^11.3",
|
||||||
|
"saschaegerer/phpstan-typo3": "^1.10",
|
||||||
|
"typo3/testing-framework": "^8.2"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"typo3/cms": {
|
"typo3/cms": {
|
||||||
"cms-package-dir": "{$vendor-dir}/typo3/cms",
|
|
||||||
"extension-key": "calendar",
|
"extension-key": "calendar",
|
||||||
"web-dir": ".Build/web"
|
"web-dir": ".Build/web"
|
||||||
}
|
}
|
||||||
|
|
35
ecs.php
35
ecs.php
|
@ -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',
|
|
||||||
]]);
|
|
||||||
};
|
|
|
@ -10,7 +10,7 @@ $EM_CONF['calendar'] = [
|
||||||
'state' => 'alpha',
|
'state' => 'alpha',
|
||||||
'uploadfolder' => 0,
|
'uploadfolder' => 0,
|
||||||
'clearCacheOnLoad' => 0,
|
'clearCacheOnLoad' => 0,
|
||||||
'version' => '1.1.1',
|
'version' => '2.0.0',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
'depends' => [
|
'depends' => [
|
||||||
'typo3' => '*',
|
'typo3' => '*',
|
||||||
|
|
10
phpstan.neon
Normal file
10
phpstan.neon
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
parameters:
|
||||||
|
level: 'max'
|
||||||
|
paths:
|
||||||
|
- 'Classes'
|
||||||
|
- 'Configuration'
|
||||||
|
- 'Tests'
|
||||||
|
reportUnmatchedIgnoredErrors: true
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
identifier: 'missingType.iterableValue'
|
|
@ -1,22 +1,26 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<phpunit
|
<phpunit
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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"
|
backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
|
||||||
bootstrap="vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
|
bootstrap="vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
forceCoversAnnotation="false"
|
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnError="false"
|
stopOnError="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
stopOnIncomplete="false"
|
stopOnIncomplete="false"
|
||||||
stopOnSkipped="false"
|
stopOnSkipped="false"
|
||||||
verbose="false"
|
cacheDirectory=".phpunit.cache"
|
||||||
|
backupStaticProperties="false"
|
||||||
|
requireCoverageMetadata="false"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">Classes</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="unit">
|
<testsuite name="unit">
|
||||||
<directory>Tests/Unit/</directory>
|
<directory>Tests/Unit/</directory>
|
||||||
|
@ -26,12 +30,6 @@
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<coverage>
|
|
||||||
<include>
|
|
||||||
<directory suffix=".php">Classes</directory>
|
|
||||||
</include>
|
|
||||||
</coverage>
|
|
||||||
|
|
||||||
<php>
|
<php>
|
||||||
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
|
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
|
||||||
</php>
|
</php>
|
||||||
|
|
52
shell.nix
Normal file
52
shell.nix
Normal 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
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue