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

Commit07c6c43

Browse files
minor#39736 [Notifier] Use abstract test cases in 5.2 (OskarStark)
This PR was squashed before being merged into the 5.2 branch.Discussion----------[Notifier] Use abstract test cases in 5.2| Q | A| ------------- | ---| Branch? | 5.2| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | Follows#39495| License | MIT| Doc PR | ---Same as#39495, but for `5.2`cc@derrabusCommits-------8f6b08c [Notifier] Use abstract test cases in 5.2
2 parents18002e2 +8f6b08c commit07c6c43

File tree

34 files changed

+510
-646
lines changed

34 files changed

+510
-646
lines changed

‎src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php‎

Lines changed: 22 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,74 +11,43 @@
1111

1212
namespaceSymfony\Component\Notifier\Bridge\Discord\Tests;
1313

14-
usePHPUnit\Framework\TestCase;
1514
useSymfony\Component\Notifier\Bridge\Discord\DiscordTransportFactory;
16-
useSymfony\Component\Notifier\Exception\IncompleteDsnException;
17-
useSymfony\Component\Notifier\Exception\UnsupportedSchemeException;
18-
useSymfony\Component\Notifier\Transport\Dsn;
15+
useSymfony\Component\Notifier\Tests\TransportFactoryTestCase;
16+
useSymfony\Component\Notifier\Transport\TransportFactoryInterface;
1917

20-
finalclass DiscordTransportFactoryTestextendsTestCase
18+
finalclass DiscordTransportFactoryTestextendsTransportFactoryTestCase
2119
{
22-
publicfunctiontestCreateWithDsn()
20+
/**
21+
* @return DiscordTransportFactory
22+
*/
23+
publicfunctioncreateFactory():TransportFactoryInterface
2324
{
24-
$factory =$this->createFactory();
25-
26-
$transport =$factory->create(Dsn::fromString('discord://token@host.test?webhook_id=testWebhookId'));
27-
28-
$this->assertSame('discord://host.test?webhook_id=testWebhookId', (string)$transport);
29-
}
30-
31-
publicfunctiontestCreateWithMissingOptionWebhookIdThrowsIncompleteDsnException()
32-
{
33-
$factory =$this->createFactory();
34-
35-
$this->expectException(IncompleteDsnException::class);
36-
37-
$factory->create(Dsn::fromString('discord://token@host'));
38-
}
39-
40-
publicfunctiontestCreateWithNoTokenThrowsIncompleteDsnException()
41-
{
42-
$factory =$this->createFactory();
43-
44-
$this->expectException(IncompleteDsnException::class);
45-
$factory->create(Dsn::fromString('discord://host.test?webhook_id=testWebhookId'));
46-
}
47-
48-
publicfunctiontestSupportsReturnsTrueWithSupportedScheme()
49-
{
50-
$factory =$this->createFactory();
51-
52-
$this->assertTrue($factory->supports(Dsn::fromString('discord://host?webhook_id=testWebhookId')));
25+
returnnewDiscordTransportFactory();
5326
}
5427

55-
publicfunctiontestSupportsReturnsFalseWithUnsupportedScheme()
28+
publicfunctioncreateProvider():iterable
5629
{
57-
$factory =$this->createFactory();
58-
59-
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://host?webhook_id=testWebhookId')));
30+
yield [
31+
'discord://host.test?webhook_id=testWebhookId',
32+
'discord://token@host.test?webhook_id=testWebhookId',
33+
];
6034
}
6135

62-
publicfunctiontestUnsupportedSchemeThrowsUnsupportedSchemeException()
36+
publicfunctionsupportsProvider():iterable
6337
{
64-
$factory =$this->createFactory();
65-
66-
$this->expectException(UnsupportedSchemeException::class);
67-
$factory->create(Dsn::fromString('somethingElse://token@host?webhook_id=testWebhookId'));
38+
yield [true,'discord://host?webhook_id=testWebhookId'];
39+
yield [false,'somethingElse://host?webhook_id=testWebhookId'];
6840
}
6941

70-
publicfunctiontestUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing()
42+
publicfunctionincompleteDsnProvider():iterable
7143
{
72-
$factory =$this->createFactory();
73-
74-
$this->expectException(UnsupportedSchemeException::class);
75-
76-
// unsupported scheme and missing "webhook_id" option
77-
$factory->create(Dsn::fromString('somethingElse://token@host'));
44+
yield'missing token' => ['discord://host.test?webhook_id=testWebhookId'];
45+
yield'missing option: webhook_id' => ['discord://token@host'];
7846
}
7947

80-
privatefunctioncreateFactory():DiscordTransportFactory
48+
publicfunctionunsupportedSchemeProvider():iterable
8149
{
82-
returnnewDiscordTransportFactory();
50+
yield ['somethingElse://token@host?webhook_id=testWebhookId'];
51+
yield ['somethingElse://token@host'];// missing "webhook_id" option
8352
}
8453
}

‎src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,42 @@
1111

1212
namespaceSymfony\Component\Notifier\Bridge\Discord\Tests;
1313

14-
usePHPUnit\Framework\TestCase;
1514
useSymfony\Component\HttpClient\MockHttpClient;
1615
useSymfony\Component\Notifier\Bridge\Discord\DiscordTransport;
1716
useSymfony\Component\Notifier\Exception\LogicException;
1817
useSymfony\Component\Notifier\Exception\TransportException;
1918
useSymfony\Component\Notifier\Message\ChatMessage;
2019
useSymfony\Component\Notifier\Message\MessageInterface;
20+
useSymfony\Component\Notifier\Message\SmsMessage;
21+
useSymfony\Component\Notifier\Tests\TransportTestCase;
22+
useSymfony\Component\Notifier\Transport\TransportInterface;
2123
useSymfony\Contracts\HttpClient\HttpClientInterface;
2224
useSymfony\Contracts\HttpClient\ResponseInterface;
2325

24-
finalclass DiscordTransportTestextendsTestCase
26+
finalclass DiscordTransportTestextendsTransportTestCase
2527
{
26-
publicfunctiontestToStringContainsProperties()
28+
/**
29+
* @return DiscordTransport
30+
*/
31+
publicfunctioncreateTransport(?HttpClientInterface$client =null):TransportInterface
2732
{
28-
$transport =$this->createTransport();
29-
30-
$this->assertSame('discord://host.test?webhook_id=testWebhookId', (string)$transport);
33+
return (newDiscordTransport('testToken','testWebhookId',$client ?:$this->createMock(HttpClientInterface::class)))->setHost('host.test');
3134
}
3235

33-
publicfunctiontestSupportsChatMessage()
36+
publicfunctiontoStringProvider():iterable
3437
{
35-
$transport =$this->createTransport();
36-
37-
$this->assertTrue($transport->supports(newChatMessage('testChatMessage')));
38-
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
38+
yield ['discord://host.test?webhook_id=testWebhookId',$this->createTransport()];
3939
}
4040

41-
publicfunctiontestSendNonChatMessageThrowsLogicException()
41+
publicfunctionsupportedMessagesProvider():iterable
4242
{
43-
$transport =$this->createTransport();
44-
45-
$this->expectException(LogicException::class);
43+
yield [newChatMessage('Hello!')];
44+
}
4645

47-
$transport->send($this->createMock(MessageInterface::class));
46+
publicfunctionunsupportedMessagesProvider():iterable
47+
{
48+
yield [newSmsMessage('0611223344','Hello!')];
49+
yield [$this->createMock(MessageInterface::class)];
4850
}
4951

5052
publicfunctiontestSendChatMessageWithMoreThan2000CharsThrowsLogicException()
@@ -78,9 +80,4 @@ public function testSendWithErrorResponseThrows()
7880

7981
$transport->send(newChatMessage('testMessage'));
8082
}
81-
82-
privatefunctioncreateTransport(?HttpClientInterface$client =null):DiscordTransport
83-
{
84-
return (newDiscordTransport('testToken','testWebhookId',$client ??$this->createMock(HttpClientInterface::class)))->setHost('host.test');
85-
}
8683
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php":">=7.2.5",
2020
"symfony/http-client":"^4.3|^5.0",
21-
"symfony/notifier":"~5.2.0",
21+
"symfony/notifier":"~5.2.2",
2222
"symfony/polyfill-mbstring":"^1.0"
2323
},
2424
"require-dev": {

‎src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(string $token, string $accountReference, string $fro
4444

4545
publicfunction__toString():string
4646
{
47-
returnsprintf('esendex://%s',$this->getEndpoint());
47+
returnsprintf('esendex://%s?accountreference=%s&from=%s',$this->getEndpoint(),$this->accountReference,$this->from);
4848
}
4949

5050
publicfunctionsupports(MessageInterface$message):bool

‎src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php‎

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,75 +11,43 @@
1111

1212
namespaceSymfony\Component\Notifier\Bridge\Esendex\Tests;
1313

14-
usePHPUnit\Framework\TestCase;
1514
useSymfony\Component\Notifier\Bridge\Esendex\EsendexTransportFactory;
16-
useSymfony\Component\Notifier\Exception\IncompleteDsnException;
17-
useSymfony\Component\Notifier\Exception\UnsupportedSchemeException;
18-
useSymfony\Component\Notifier\Transport\Dsn;
15+
useSymfony\Component\Notifier\Tests\TransportFactoryTestCase;
16+
useSymfony\Component\Notifier\Transport\TransportFactoryInterface;
1917

20-
finalclass EsendexTransportFactoryTestextendsTestCase
18+
finalclass EsendexTransportFactoryTestextendsTransportFactoryTestCase
2119
{
22-
publicfunctiontestCreateWithDsn()
20+
/**
21+
* @return EsendexTransportFactory
22+
*/
23+
publicfunctioncreateFactory():TransportFactoryInterface
2324
{
24-
$factory =$this->createFactory();
25-
26-
$transport =$factory->create(Dsn::fromString('esendex://email:password@host.test?accountreference=testAccountreference&from=testFrom'));
27-
28-
$this->assertSame('esendex://host.test', (string)$transport);
29-
}
30-
31-
publicfunctiontestCreateWithMissingOptionAccountreferenceThrowsIncompleteDsnException()
32-
{
33-
$factory =$this->createFactory();
34-
35-
$this->expectException(IncompleteDsnException::class);
36-
37-
$factory->create(Dsn::fromString('esendex://email:password@host?from=FROM'));
38-
}
39-
40-
publicfunctiontestCreateWithMissingOptionFromThrowsIncompleteDsnException()
41-
{
42-
$factory =$this->createFactory();
43-
44-
$this->expectException(IncompleteDsnException::class);
45-
46-
$factory->create(Dsn::fromString('esendex://email:password@host?accountreference=ACCOUNTREFERENCE'));
25+
returnnewEsendexTransportFactory();
4726
}
4827

49-
publicfunctiontestSupportsReturnsTrueWithSupportedScheme()
28+
publicfunctioncreateProvider():iterable
5029
{
51-
$factory =$this->createFactory();
52-
53-
$this->assertTrue($factory->supports(Dsn::fromString('esendex://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM')));
30+
yield [
31+
'esendex://host.test?accountreference=ACCOUNTREFERENCE&from=FROM',
32+
'esendex://email:password@host.test?accountreference=ACCOUNTREFERENCE&from=FROM',
33+
];
5434
}
5535

56-
publicfunctiontestSupportsReturnsFalseWithUnsupportedScheme()
36+
publicfunctionsupportsProvider():iterable
5737
{
58-
$factory =$this->createFactory();
59-
60-
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM')));
38+
yield [true,'esendex://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM'];
39+
yield [false,'somethingElse://email:password@default'];
6140
}
6241

63-
publicfunctiontestUnsupportedSchemeThrowsUnsupportedSchemeException()
42+
publicfunctionincompleteDsnProvider():iterable
6443
{
65-
$factory =$this->createFactory();
66-
67-
$this->expectException(UnsupportedSchemeException::class);
68-
$factory->create(Dsn::fromString('somethingElse://email:password@host?accountreference=REFERENCE&from=FROM'));
44+
yield'missing option: from' => ['esendex://email:password@host?accountreference=ACCOUNTREFERENCE'];
45+
yield'missing option: accountreference' => ['esendex://email:password@host?from=FROM'];
6946
}
7047

71-
publicfunctiontestUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing()
48+
publicfunctionunsupportedSchemeProvider():iterable
7249
{
73-
$factory =$this->createFactory();
74-
75-
$this->expectException(UnsupportedSchemeException::class);
76-
77-
// unsupported scheme and missing "from" option
78-
$factory->create(Dsn::fromString('somethingElse://email:password@host?accountreference=REFERENCE'));
79-
}
80-
81-
privatefunctioncreateFactory():EsendexTransportFactory
82-
{
83-
returnnewEsendexTransportFactory();
50+
yield ['somethingElse://email:password@default?accountreference=ACCOUNTREFERENCE&from=FROM'];
51+
yield ['somethingElse://email:password@host?accountreference=ACCOUNTREFERENCE'];// missing "from" option
8452
}
8553
}

‎src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php‎

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,44 @@
1111

1212
namespaceSymfony\Component\Notifier\Bridge\Esendex\Tests;
1313

14-
usePHPUnit\Framework\TestCase;
1514
useSymfony\Component\HttpClient\MockHttpClient;
1615
useSymfony\Component\Notifier\Bridge\Esendex\EsendexTransport;
17-
useSymfony\Component\Notifier\Exception\LogicException;
1816
useSymfony\Component\Notifier\Exception\TransportException;
17+
useSymfony\Component\Notifier\Message\ChatMessage;
1918
useSymfony\Component\Notifier\Message\MessageInterface;
2019
useSymfony\Component\Notifier\Message\SmsMessage;
20+
useSymfony\Component\Notifier\Tests\TransportTestCase;
21+
useSymfony\Component\Notifier\Transport\TransportInterface;
2122
useSymfony\Contracts\HttpClient\HttpClientInterface;
2223
useSymfony\Contracts\HttpClient\ResponseInterface;
2324

24-
finalclass EsendexTransportTestextendsTestCase
25+
finalclass EsendexTransportTestextendsTransportTestCase
2526
{
26-
publicfunctiontestToString()
27+
/**
28+
* @return EsendexTransport
29+
*/
30+
publicfunctioncreateTransport(?HttpClientInterface$client =null):TransportInterface
2731
{
28-
$transport =$this->createTransport();
29-
30-
$this->assertSame('esendex://host.test', (string)$transport);
32+
return (newEsendexTransport('testToken','testAccountReference','testFrom',$client ?:$this->createMock(HttpClientInterface::class)))->setHost('host.test');
3133
}
3234

33-
publicfunctiontestSupportsSmsMessage()
35+
publicfunctiontoStringProvider():iterable
3436
{
35-
$transport =$this->createTransport();
36-
37-
$this->assertTrue($transport->supports(newSmsMessage('phone','testSmsMessage')));
38-
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
37+
yield ['esendex://host.test?accountreference=testAccountReference&from=testFrom',$this->createTransport()];
3938
}
4039

41-
publicfunctiontestSendNonSmsMessageThrowsLogicException()
40+
publicfunctionsupportedMessagesProvider():iterable
4241
{
43-
$transport =$this->createTransport();
42+
yield [newSmsMessage('0611223344','Hello!')];
43+
}
4444

45-
$this->expectException(LogicException::class);
46-
$transport->send($this->createMock(MessageInterface::class));
45+
publicfunctionunsupportedMessagesProvider():iterable
46+
{
47+
yield [newChatMessage('Hello!')];
48+
yield [$this->createMock(MessageInterface::class)];
4749
}
4850

49-
publicfunctiontestSendWithErrorResponseThrows()
51+
publicfunctiontestSendWithErrorResponseThrowsTransportException()
5052
{
5153
$response =$this->createMock(ResponseInterface::class);
5254
$response->expects($this->exactly(2))
@@ -65,7 +67,7 @@ public function testSendWithErrorResponseThrows()
6567
$transport->send(newSmsMessage('phone','testMessage'));
6668
}
6769

68-
publicfunctiontestSendWithErrorResponseContainingDetailsThrows()
70+
publicfunctiontestSendWithErrorResponseContainingDetailsThrowsTransportException()
6971
{
7072
$response =$this->createMock(ResponseInterface::class);
7173
$response->expects($this->exactly(2))
@@ -86,9 +88,4 @@ public function testSendWithErrorResponseContainingDetailsThrows()
8688

8789
$transport->send(newSmsMessage('phone','testMessage'));
8890
}
89-
90-
privatefunctioncreateTransport(?HttpClientInterface$client =null):EsendexTransport
91-
{
92-
return (newEsendexTransport('testToken','testAccountReference','testFrom',$client ?:$this->createMock(HttpClientInterface::class)))->setHost('host.test');
93-
}
9491
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php":">=7.2.5",
2020
"symfony/http-client":"^4.4|^5.0",
21-
"symfony/notifier":"~5.2.0"
21+
"symfony/notifier":"~5.2.2"
2222
},
2323
"autoload": {
2424
"psr-4": {"Symfony\\Component\\Notifier\\Bridge\\Esendex\\":"" },

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where:
1414
-`ACCESS_KEY` is your Google Chat access key
1515
-`ACCESS_TOKEN` is your Google Chat access token
1616
-`SPACE` is the Google Chat space
17-
-`THREAD_KEY` is thetheGoogle Chat message thread to group messages into a single thread (optional)
17+
-`THREAD_KEY` is the Google Chat message thread to group messages into a single thread (optional)
1818

1919
Resources
2020
---------

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatOptionsTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
usePHPUnit\Framework\TestCase;
1515
useSymfony\Component\Notifier\Bridge\GoogleChat\GoogleChatOptions;
1616

17-
class GoogleChatOptionsTestextends TestCase
17+
finalclass GoogleChatOptionsTestextends TestCase
1818
{
1919
publicfunctiontestToArray()
2020
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp