mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-25 01:46:09 +01:00
Adjust set highlight in Demand
This commit is contained in:
parent
9678884de4
commit
605ad9f9ae
2 changed files with 54 additions and 2 deletions
|
@ -115,7 +115,7 @@ class DateDemand
|
|||
}
|
||||
|
||||
if ($submittedValues['highlight'] ?? false) {
|
||||
$instance->setHighlight($settings['highlight'] ?? false);
|
||||
$instance->setHighlight(true);
|
||||
}
|
||||
|
||||
if (isset($submittedValues['start']) && $submittedValues['start'] !== '') {
|
||||
|
|
|
@ -266,7 +266,6 @@ class DateDemandTest extends TestCase
|
|||
*/
|
||||
public function returnsEndsOnSameDayIfBothAreOnDifferentDays(): void
|
||||
{
|
||||
|
||||
$result = DateDemand::createFromRequestValues(
|
||||
[
|
||||
'start' => '2022-07-12',
|
||||
|
@ -280,4 +279,57 @@ class DateDemandTest extends TestCase
|
|||
$result->getEndsOnSameDay()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider possibleSubmittedHighlights
|
||||
*
|
||||
* @param mixed $highlight
|
||||
*/
|
||||
public function returnsHighlightIfSet($highlight): void
|
||||
{
|
||||
$result = DateDemand::createFromRequestValues(
|
||||
[
|
||||
'highlight' => $highlight,
|
||||
],
|
||||
[
|
||||
]
|
||||
);
|
||||
|
||||
self::assertTrue($result->getHighlight());
|
||||
}
|
||||
|
||||
public function possibleSubmittedHighlights(): \Generator
|
||||
{
|
||||
yield 'true' => ['highlight' => true];
|
||||
yield '1 as integer' => ['highlight' => 1];
|
||||
yield '1 as string' => ['highlight' => '1'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider possibleSubmittedFalsyHighlights
|
||||
*
|
||||
* @param mixed $highlight
|
||||
*/
|
||||
public function returnsNoHighlightIfNotSet($highlight): void
|
||||
{
|
||||
$result = DateDemand::createFromRequestValues(
|
||||
[
|
||||
'highlight' => $highlight,
|
||||
],
|
||||
[
|
||||
]
|
||||
);
|
||||
|
||||
self::assertFalse($result->getHighlight());
|
||||
}
|
||||
|
||||
public function possibleSubmittedFalsyHighlights(): \Generator
|
||||
{
|
||||
yield 'false' => ['highlight' => false];
|
||||
yield '0 as integer' => ['highlight' => 0];
|
||||
yield '0 as string' => ['highlight' => '0'];
|
||||
yield 'empty string' => ['highlight' => ''];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue