Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose settings via DateSearchVariables Event #58

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading