2022-07-11 08:59:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Tests\Unit\Events\Controller;
|
2022-07-11 08:59:32 +02:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2022-07-11 08:59:32 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-08-02 17:15:47 +02:00
|
|
|
use TYPO3\CMS\Core\Pagination\PaginationInterface;
|
2022-07-11 08:59:32 +02:00
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\Model\Dto\DateDemand;
|
|
|
|
use WerkraumMedia\Events\Events\Controller\DateListVariables;
|
2022-07-11 08:59:32 +02:00
|
|
|
|
|
|
|
class DateListVariablesTest extends TestCase
|
|
|
|
{
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function canBeCreated(): void
|
|
|
|
{
|
|
|
|
$subject = new DateListVariables(
|
|
|
|
[],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
|
|
|
$this->createStub(PaginationInterface::class)
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
self::assertInstanceOf(
|
|
|
|
DateListVariables::class,
|
|
|
|
$subject
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialSearch(): void
|
|
|
|
{
|
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
|
|
|
$this->createStub(PaginationInterface::class)
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$subject->getSearch()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialDemand(): void
|
|
|
|
{
|
|
|
|
$demand = new DateDemand();
|
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
$demand,
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
|
|
|
$this->createStub(PaginationInterface::class)
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$demand,
|
|
|
|
$subject->getDemand()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialDates(): void
|
|
|
|
{
|
2023-11-27 10:04:42 +01:00
|
|
|
$dates = $this->createStub(QueryResult::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2022-08-02 17:15:47 +02:00
|
|
|
$dates,
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(PaginationInterface::class)
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$dates,
|
|
|
|
$subject->getDates()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialVariablesForView(): void
|
|
|
|
{
|
|
|
|
$demand = new DateDemand();
|
2023-11-27 10:04:42 +01:00
|
|
|
$dates = $this->createStub(QueryResult::class);
|
|
|
|
$pagination = $this->createStub(PaginationInterface::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
2022-08-02 17:15:47 +02:00
|
|
|
$dates,
|
|
|
|
$pagination
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'dates' => $dates,
|
2022-08-02 17:15:47 +02:00
|
|
|
'pagination' => $pagination,
|
2022-07-11 08:59:32 +02:00
|
|
|
],
|
|
|
|
$subject->getVariablesForView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsVariablesForViewWithAddedVariables(): void
|
|
|
|
{
|
|
|
|
$demand = new DateDemand();
|
2023-11-27 10:04:42 +01:00
|
|
|
$dates = $this->createStub(QueryResult::class);
|
|
|
|
$pagination = $this->createStub(PaginationInterface::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
2022-08-02 17:15:47 +02:00
|
|
|
$dates,
|
|
|
|
$pagination
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$subject->addVariable('variable 1', 'Value 1');
|
|
|
|
$subject->addVariable('variable 2', 'Value 2');
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'dates' => $dates,
|
2022-08-02 17:15:47 +02:00
|
|
|
'pagination' => $pagination,
|
2022-07-11 08:59:32 +02:00
|
|
|
'variable 1' => 'Value 1',
|
|
|
|
'variable 2' => 'Value 2',
|
|
|
|
],
|
|
|
|
$subject->getVariablesForView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsVariablesForViewWithOverwrittenVariables(): void
|
|
|
|
{
|
|
|
|
$demand = new DateDemand();
|
2023-11-27 10:04:42 +01:00
|
|
|
$dates = $this->createStub(QueryResult::class);
|
|
|
|
$pagination = $this->createStub(PaginationInterface::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateListVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
2022-08-02 17:15:47 +02:00
|
|
|
$dates,
|
|
|
|
$pagination
|
2022-07-11 08:59:32 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$subject->addVariable('variable 1', 'Value 1');
|
|
|
|
$subject->addVariable('variable 1', 'Value 2');
|
|
|
|
$subject->addVariable('dates', 'Value 2');
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'dates' => 'Value 2',
|
2022-08-02 17:15:47 +02:00
|
|
|
'pagination' => $pagination,
|
2022-07-11 08:59:32 +02:00
|
|
|
'variable 1' => 'Value 2',
|
|
|
|
],
|
|
|
|
$subject->getVariablesForView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|