Expose settings via DateSearchVariables Event (#58)

This commit is contained in:
Daniel Siepmann 2024-06-27 10:09:26 +02:00 committed by GitHub
parent 15d233c834
commit 2168412ae5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 75 additions and 0 deletions

View file

@ -83,6 +83,7 @@ final class DateController extends AbstractController
}
$event = $this->eventDispatcher->dispatch(new DateSearchVariables(
$this->settings,
$search,
$demand,
$this->regionRepository->findAll(),

View file

@ -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,
@ -27,6 +28,11 @@ final class DateSearchVariables
) {
}
public function getSettings(): array
{
return $this->settings;
}
public function getSearch(): array
{
return $this->search;

View file

@ -0,0 +1,27 @@
3.8.0
=====
Breaking
--------
Nothing
Features
--------
* Expose settings via `DateSearchVariables` Event.
Fixes
-----
Nothing
Tasks
-----
Nothing
Deprecation
-----------
Nothing

View file

@ -16,6 +16,8 @@ class DateSearchVariablesTest extends TestCase
public function canBeCreated(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
@ -30,10 +32,35 @@ class DateSearchVariablesTest extends TestCase
);
}
#[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',
],
@ -56,6 +83,8 @@ class DateSearchVariablesTest extends TestCase
{
$demand = new DateDemand();
$subject = new DateSearchVariables(
[
],
[
],
$demand,
@ -75,6 +104,8 @@ class DateSearchVariablesTest extends TestCase
{
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
@ -93,6 +124,8 @@ class DateSearchVariablesTest extends TestCase
public function returnsInitialCategories(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
@ -115,6 +148,8 @@ class DateSearchVariablesTest extends TestCase
public function returnsInitialFeatures(): void
{
$subject = new DateSearchVariables(
[
],
[
],
new DateDemand(),
@ -140,6 +175,8 @@ class DateSearchVariablesTest extends TestCase
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
@ -177,6 +214,8 @@ class DateSearchVariablesTest extends TestCase
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],
@ -219,6 +258,8 @@ class DateSearchVariablesTest extends TestCase
$demand = new DateDemand();
$regions = $this->createStub(QueryResult::class);
$subject = new DateSearchVariables(
[
],
[
'executed' => '1',
],