Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ee32aa

Browse files
committed
[Notifier] Add tests for AbstractChannel and ChannelPolicy
1 parentf4332cb commit9ee32aa

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespaceSymfony\Component\Notifier\Tests\Channel;
6+
7+
usePHPUnit\Framework\TestCase;
8+
useSymfony\Component\Notifier\Channel\AbstractChannel;
9+
useSymfony\Component\Notifier\Exception\LogicException;
10+
useSymfony\Component\Notifier\Notification\Notification;
11+
useSymfony\Component\Notifier\Recipient\Recipient;
12+
13+
/**
14+
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
15+
*/
16+
class AbstractChannelTestextends TestCase
17+
{
18+
publicfunctiontest_a_channel_cannot_be_constructed_without_transport_and_bus():void
19+
{
20+
$this->expectException(LogicException::class);
21+
22+
newDummyChannel();
23+
}
24+
}
25+
26+
class DummyChannelextends AbstractChannel
27+
{
28+
publicfunctionnotify(Notification$notification,Recipient$recipient,string$transportName =null):void
29+
{
30+
return;
31+
}
32+
33+
publicfunctionsupports(Notification$notification,Recipient$recipient):bool
34+
{
35+
returnfalse;
36+
}
37+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespaceSymfony\Component\Notifier\Tests\Channel;
6+
7+
usePHPUnit\Framework\TestCase;
8+
useSymfony\Component\Notifier\Channel\ChannelPolicy;
9+
useSymfony\Component\Notifier\Exception\InvalidArgumentException;
10+
11+
/**
12+
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
13+
*/
14+
class ChannelPolicyTestextends TestCase
15+
{
16+
publicfunctiontest_cannot_retrieve_channels_using_unavailable_importance():void
17+
{
18+
$this->expectException(InvalidArgumentException::class);
19+
20+
$channelPolicy =newChannelPolicy(['urgent' => ['chat']]);
21+
$channelPolicy->getChannels('low');
22+
}
23+
24+
/**
25+
* @dataProvider provideValidPolicies
26+
*/
27+
publicfunctiontest_can_retrieve_channels(array$policy,string$importance,array$expectedChannels):void
28+
{
29+
$channelPolicy =newChannelPolicy($policy);
30+
$channels =$channelPolicy->getChannels($importance);
31+
32+
$this->assertSame($expectedChannels,$channels);
33+
}
34+
35+
publicfunctionprovideValidPolicies():\Generator
36+
{
37+
yield [['urgent' => ['chat']],'urgent', ['chat']];
38+
yield [['urgent' => ['chat','sms']],'urgent', ['chat','sms']];
39+
yield [['urgent' => ['chat','chat/slack','sms']],'urgent', ['chat','chat/slack','sms']];
40+
}
41+
}

‎src/Symfony/Component/Notifier/composer.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"require": {
1919
"php":"^7.2.5"
2020
},
21+
"require-dev": {
22+
"symfony/messenger":"^4.4|^5.0"
23+
},
2124
"conflict": {
2225
"symfony/http-kernel":"<4.4"
2326
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp