8000 [Notifier] Extended TelegramOptionsTest to make sure cache time is pr… · symfony/symfony@901abe4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 901abe4

Browse files
committed
[Notifier] Extended TelegramOptionsTest to make sure cache time is provided when valid number is provided
1 parent 4e4674d commit 901abe4

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramOptionsTest.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,56 @@
1818

1919
final class TelegramOptionsTest extends TestCase
2020
{
21-
public function testAnswerCallbackQuery()
21+
/**
22+
* @dataProvider validCacheTimeDataProvider
23+
*/
24+
public function testAnswerCallbackQueryWithCacheTime(int $cacheTime)
2225
{
2326
$options = new TelegramOptions();
2427

25-
$returnedOptions = $options->answerCallbackQuery('123', true, 1);
28+
$returnedOptions = $options->answerCallbackQuery('123', true, $cacheTime);
2629

2730
$this->assertSame($options, $returnedOptions);
2831
$this->assertEquals(
2932
[
3033
'callback_query_id' => '123',
3134
'show_alert' => true,
32-
'cache_time' => 1,
35+
'cache_time' => $cacheTime,
3336
],
3437
$options->toArray(),
3538
);
3639
}
40+
41+
public function validCacheTimeDataProvider(): iterable
42+
{
43+
yield 'cache time equals 1' => [1];
44+
yield 'cache time equals 2' => [2];
45+
yield 'cache time equals 10' => [10];
46+
}
47+
48+
/**
49+
* @dataProvider invalidCacheTimeDataProvider
50+
*/
51+
public function testAnswerCallbackQuery(int $cacheTime)
52+
{
53+
$options = new TelegramOptions();
54+
55+
$returnedOptions = $options->answerCallbackQuery('123', true, $cacheTime);
56+
57+
$this->assertSame($options, $returnedOptions);
58+
$this->assertEquals(
59+
[
60+
'callback_query_id' => '123',
61+
'show_alert' => true,
62+
],
63+
$options->toArray(),
64+
);
65+
}
66+
67+
public function invalidCacheTimeDataProvider(): iterable
68+
{
69+
yield 'cache time equals 0' => [0];
70+
yield 'cache time equals -1' => [-1];
71+
yield 'cache time equals -10' => [-10];
72+
}
3773
}

0 commit comments

Comments
 (0)
0