Skip to content

Commit

Permalink
Expose settings via DateSearchVariables Event
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSiepmann committed Jun 27, 2024
1 parent 15d233c commit 32c3328
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions Classes/Controller/DateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function searchAction(array $search = []): ResponseInterface
}

$event = $this->eventDispatcher->dispatch(new DateSearchVariables(
$this->settings,
$search,
$demand,
$this->regionRepository->findAll(),
Expand Down
6 changes: 6 additions & 0 deletions Classes/Events/Controller/DateSearchVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class DateSearchVariables
* @param array<Category> $features
*/
public function __construct(
private readonly array $settings,
private readonly array $search,
private readonly DateDemand $demand,
private readonly QueryResultInterface $regions,
Expand All @@ -27,6 +28,11 @@ public function __construct(
) {
}

public function getSettings(): array
{
return $this->settings;
}

public function getSearch(): array
{
return $this->search;
Expand Down
27 changes: 27 additions & 0 deletions Documentation/Changelog/3.8.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
3.8.0
=====

Breaking
--------

Nothing

Features
--------

* Expose settings via `DateSearchVariables` Event.

Fixes
-----

Nothing

Tasks
-----

Nothing

Deprecation
-----------

Nothing
41 changes: 41 additions & 0 deletions Tests/Unit/Events/Controller/DateSearchVariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class DateSearchVariablesTest extends TestCase
public function canBeCreated(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
Expand All @@ -30,10 +32,35 @@ public function canBeCreated(): void
);
}

#[Test]
public function returnsInitializeSettings(): void
{
$subject = new DateSearchVariables(
[
'someCustomKey' => 'someCustomValue',
],
[
],
new DateDemand(),
$this->createStub(QueryResult::class),
[],
[]
);

self::assertSame(
[
'someCustomKey' => 'someCustomValue',
],
$subject->getSettings()
);
}

#[Test]
public function returnsInitializeSearch(): void
{
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
Expand All @@ -56,6 +83,8 @@ public function returnsInitializeDemand(): void
{
$demand = new DateDemand();
$subject = new DateSearchVariables(
[
],
[
],
$demand,
Expand All @@ -75,6 +104,8 @@ public function returnsInitialRegions(): void
{
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
Expand All @@ -93,6 +124,8 @@ public function returnsInitialRegions(): void
public function returnsInitialCategories(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
Expand All @@ -115,6 +148,8 @@ public function returnsInitialCategories(): void
public function returnsInitialFeatures(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
Expand All @@ -140,6 +175,8 @@ public function returnsInitialVariablesForView(): void
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
Expand Down Expand Up @@ -177,6 +214,8 @@ public function returnsVariablesForViewWithAddedVariables(): void
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
Expand Down Expand Up @@ -219,6 +258,8 @@ public function returnsVariablesForViewWithOverwrittenVariables(): void
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
Expand Down

0 comments on commit 32c3328

Please sign in to comment.