Skip to content

Commit 7721dd9

Browse files
committed
Add test for temperature helper
1 parent a95bc96 commit 7721dd9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/php/de/thekid/dialog/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function helpers() {
2323
yield 'range' => function($node, $context, $options) {
2424
$from= date($options['format'], strtotime($options[0]));
2525
$until= date($options['format'], strtotime($options[1]));
26-
return $from === $until ? $from : $from.' - '.$until;
26+
return $from === $until ? $from : $from.' '.$until;
2727
};
2828
yield 'range-rel' => function($node, $context, $options) {
2929
$from= strtotime($options[0]);

src/test/php/de/thekid/dialog/unittest/HelpersTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class HelpersTest {
77
private $helpers= [...new Helpers()->helpers()];
88

99
#[Test, Values([
10-
[['2022-11-29', '2022-12-01', 'format' => 'd.m.Y'], '29.11.2022 - 01.12.2022'],
10+
[['2022-11-29', '2022-12-01', 'format' => 'd.m.Y'], '29.11.2022 01.12.2022'],
1111
[['2022-11-29', '2022-11-29', 'format' => 'd.m.Y'], '29.11.2022'],
12-
[['2022-11-29', '2022-12-01', 'format' => 'M Y'], 'Nov 2022 - Dec 2022'],
12+
[['2022-11-29', '2022-12-01', 'format' => 'M Y'], 'Nov 2022 Dec 2022'],
1313
[['2022-11-29', '2022-11-30', 'format' => 'M Y'], 'Nov 2022'],
1414
])]
1515
public function range($options, $expected) {
@@ -27,6 +27,17 @@ public function range_rel($options, $expected) {
2727
Assert::equals($expected, $this->helpers['range-rel'](null, null, $options));
2828
}
2929

30+
#[Test, Values([
31+
[[25.0, 25.0], '25.0'],
32+
[[25.0, 25.4], '25.2'],
33+
[[25.2, 25.4, 'tolerance' => 0], '25.2 — 25.4'],
34+
[[25.4, 27.2], '25.4 — 27.2'],
35+
[[-1.5, 1.5], '-1.5 — 1.5'],
36+
])]
37+
public function temperature($options, $expected) {
38+
Assert::equals($expected, $this->helpers['temperature'](null, null, $options));
39+
}
40+
3041
#[Test, Values([
3142
[['slug' => 'test', 'is' => ['journey' => true]], 'journey/test'],
3243
[['slug' => 'test', 'is' => ['content' => true]], 'content/test'],

0 commit comments

Comments
 (0)