2022-07-11 08:59:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\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;
|
|
|
|
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\DateSearchVariables;
|
2022-07-11 08:59:32 +02:00
|
|
|
|
|
|
|
class DateSearchVariablesTest 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 DateSearchVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
2022-07-11 08:59:32 +02:00
|
|
|
[],
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertInstanceOf(
|
|
|
|
DateSearchVariables::class,
|
|
|
|
$subject
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitializeSearch(): void
|
|
|
|
{
|
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::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 returnsInitializeDemand(): void
|
|
|
|
{
|
|
|
|
$demand = new DateDemand();
|
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
$demand,
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::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 returnsInitialRegions(): void
|
|
|
|
{
|
2023-11-27 10:04:42 +01:00
|
|
|
$regions = $this->createStub(QueryResult::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
|
|
|
$regions,
|
|
|
|
[],
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$regions,
|
|
|
|
$subject->getRegions()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialCategories(): void
|
|
|
|
{
|
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
2022-07-11 08:59:32 +02:00
|
|
|
[
|
|
|
|
['example category'],
|
|
|
|
],
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
['example category'],
|
|
|
|
],
|
|
|
|
$subject->getCategories()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Test]
|
2022-07-11 08:59:32 +02:00
|
|
|
public function returnsInitialFeatures(): void
|
|
|
|
{
|
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
],
|
|
|
|
new DateDemand(),
|
2023-11-27 10:04:42 +01:00
|
|
|
$this->createStub(QueryResult::class),
|
2022-07-11 08:59:32 +02:00
|
|
|
[
|
|
|
|
],
|
|
|
|
[
|
|
|
|
['example feature category'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
['example feature category'],
|
|
|
|
],
|
|
|
|
$subject->getFeatures()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
$regions = $this->createStub(QueryResult::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
|
|
|
$regions,
|
|
|
|
[
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
['example feature category'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'regions' => $regions,
|
|
|
|
'categories' => [
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
'features' => [
|
|
|
|
['example feature category'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
$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
|
|
|
$regions = $this->createStub(QueryResult::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
|
|
|
$regions,
|
|
|
|
[
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
['example feature category'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$subject->addVariable('variable 1', 'Value 1');
|
|
|
|
$subject->addVariable('variable 2', 'Value 2');
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'regions' => $regions,
|
|
|
|
'categories' => [
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
'features' => [
|
|
|
|
['example feature category'],
|
|
|
|
],
|
|
|
|
'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
|
|
|
$regions = $this->createStub(QueryResult::class);
|
2022-07-11 08:59:32 +02:00
|
|
|
$subject = new DateSearchVariables(
|
|
|
|
[
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
$demand,
|
|
|
|
$regions,
|
|
|
|
[
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
['example feature category'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$subject->addVariable('variable 1', 'Value 1');
|
|
|
|
$subject->addVariable('variable 1', 'Value 2');
|
|
|
|
$subject->addVariable('features', 'Value 2');
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'search' => [
|
|
|
|
'executed' => '1',
|
|
|
|
],
|
|
|
|
'demand' => $demand,
|
|
|
|
'regions' => $regions,
|
|
|
|
'categories' => [
|
|
|
|
['example category category'],
|
|
|
|
],
|
|
|
|
'features' => 'Value 2',
|
|
|
|
'variable 1' => 'Value 2',
|
|
|
|
],
|
|
|
|
$subject->getVariablesForView()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|