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

Appearance settings

Commit 94a627d

Browse filesBrowse files
committed
move some code to single line and remove single-use variables
1 parent 4770c53 commit 94a627d
Copy full SHA for 94a627d

File tree

2 files changed

+14
-78
lines changed
Filter options

2 files changed

+14
-78
lines changed

‎src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportFactoryTest.php
+4-34Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,28 @@ public function testCreateWithDsn(): void
2323
{
2424
$factory = new TelegramTransportFactory();
2525

26-
$token = 'testUser:testPassword';
2726
$host = 'testHost';
2827
$channel = 'testChannel';
2928

30-
$transport = $factory->create(Dsn::fromString(sprintf(
31-
'telegram://%s@%s/?channel=%s',
32-
$token,
33-
$host,
34-
$channel
35-
)));
29+
$transport = $factory->create(Dsn::fromString(sprintf('telegram://%s@%s/?channel=%s', 'testUser:testPassword', $host, $channel)));
3630

37-
$this->assertSame(sprintf(
38-
'telegram://%s?channel=%s',
39-
$host,
40-
$channel),
41-
(string) $transport
42-
);
31+
$this->assertSame(sprintf('telegram://%s?channel=%s', $host, $channel), (string) $transport);
4332
}
4433

4534
public function testCreateWithNoPasswordThrowsMalformed(): void
4635
{
4736
$factory = new TelegramTransportFactory();
4837

49-
$token = 'simpleToken';
50-
$host = 'testHost';
51-
$channel = 'testChannel';
52-
5338
$this->expectException(IncompleteDsnException::class);
54-
55-
$factory->create(Dsn::fromString(sprintf(
56-
'telegram://%s@%s/?channel=%s',
57-
$token,
58-
$host,
59-
$channel
60-
)));
39+
$factory->create(Dsn::fromString(sprintf('telegram://%s@%s/?channel=%s', 'simpleToken', 'testHost', 'testChannel')));
6140
}
6241

6342
public function testCreateWithNoTokenThrowsMalformed(): void
6443
{
6544
$factory = new TelegramTransportFactory();
6645

67-
$host = 'testHost';
68-
$channel = 'testChannel';
69-
7046
$this->expectException(IncompleteDsnException::class);
71-
72-
$factory->create(Dsn::fromString(sprintf(
73-
'telegram://%s/?channel=%s',
74-
$host,
75-
$channel
76-
)));
47+
$factory->create(Dsn::fromString(sprintf('telegram://%s/?channel=%s', 'testHost', 'testChannel')));
7748
}
7849

7950
public function testSupportsTelegramScheme(): void
@@ -89,7 +60,6 @@ public function testNonTelegramSchemeThrows(): void
8960
$factory = new TelegramTransportFactory();
9061

9162
$this->expectException(UnsupportedSchemeException::class);
92-
9363
$factory->create(Dsn::fromString('somethingElse://user:pwd@host/?channel=testChannel'));
9464
}
9565
}

‎src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php
+10-44Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,17 @@ final class TelegramTransportTest extends TestCase
2626
{
2727
public function testToStringContainsProperties(): void
2828
{
29-
$host = 'testHost';
3029
$channel = 'testChannel';
3130

32-
$transport = new TelegramTransport(
33-
'testToken',
34-
$channel,
35-
$this->createMock(HttpClientInterface::class)
36-
);
31+
$transport = new TelegramTransport('testToken', $channel, $this->createMock(HttpClientInterface::class));
3732
$transport->setHost('testHost');
3833

39-
$this->assertSame(
40-
sprintf('telegram://%s?channel=%s', $host, $channel),
41-
(string) $transport
42-
);
34+
$this->assertSame(sprintf('telegram://%s?channel=%s', 'testHost', $channel), (string) $transport);
4335
}
4436

4537
public function testSupportsChatMessage(): void
4638
{
47-
$transport = new TelegramTransport(
48-
'testToken',
49-
'testChannel',
50-
$this->createMock(HttpClientInterface::class)
51-
);
39+
$transport = new TelegramTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class));
5240

5341
$this->assertTrue($transport->supports(new ChatMessage('testChatMessage')));
5442
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
@@ -57,20 +45,13 @@ public function testSupportsChatMessage(): void
5745
public function testSendNonChatMessageThrows(): void
5846
{
5947
$this->expectException(LogicException::class);
60-
$transport = new TelegramTransport(
61-
'testToken',
62-
'testChannel',
63-
$this->createMock(HttpClientInterface::class)
64-
);
48+
$transport = new TelegramTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class));
6549

6650
$transport->send($this->createMock(MessageInterface::class));
6751
}
6852

6953
public function testSendWithErrorResponseThrows(): void
7054
{
71-
$description = 'testDescription';
72-
$errorCode = 'testErrorCode';
73-
7455
$this->expectException(TransportException::class);
7556
$this->expectExceptionMessageRegExp('/testDescription.+testErrorCode/');
7657

@@ -80,25 +61,20 @@ public function testSendWithErrorResponseThrows(): void
8061
->willReturn(400);
8162
$response->expects($this->once())
8263
->method('getContent')
83-
->willReturn(json_encode(['description' => $description, 'error_code' => $errorCode]));
64+
->willReturn(json_encode(['description' => 'testDescription', 'error_code' => 'testErrorCode']));
8465

8566
$client = new MockHttpClient(static function () use ($response): ResponseInterface {
8667
return $response;
8768
});
8869

89-
$transport = new TelegramTransport(
90-
'testToken',
91-
'testChannel',
92-
$client
93-
);
70+
$transport = new TelegramTransport('testToken', 'testChannel', $client);
9471

9572
$transport->send(new ChatMessage('testMessage'));
9673
}
9774

9875
public function testSendWithOptions(): void
9976
{
10077
$channel = 'testChannel';
101-
$message = 'testMessage';
10278

10379
$response = $this->createMock(ResponseInterface::class);
10480
$response->expects($this->exactly(2))
@@ -110,7 +86,7 @@ public function testSendWithOptions(): void
11086

11187
$expectedBody = [
11288
'chat_id' => $channel,
113-
'text' => $message,
89+
'text' => 'testMessage',
11490
'parse_mode' => 'Markdown',
11591
];
11692

@@ -120,20 +96,14 @@ public function testSendWithOptions(): void
12096
return $response;
12197
});
12298

123-
$transport = new TelegramTransport(
124-
'testToken',
125-
$channel,
126-
$client
127-
);
99+
$transport = new TelegramTransport('testToken', $channel, $client);
128100

129101
$transport->send(new ChatMessage('testMessage'));
130102
}
131103

132104
public function testSendWithChannelOverride(): void
133105
{
134-
$channel = 'defaultChannel';
135106
$channelOverride = 'channelOverride';
136-
$message = 'testMessage';
137107

138108
$response = $this->createMock(ResponseInterface::class);
139109
$response->expects($this->exactly(2))
@@ -145,7 +115,7 @@ public function testSendWithChannelOverride(): void
145115

146116
$expectedBody = [
147117
'chat_id' => $channelOverride,
148-
'text' => $message,
118+
'text' => 'testMessage',
149119
'parse_mode' => 'Markdown',
150120
];
151121

@@ -155,11 +125,7 @@ public function testSendWithChannelOverride(): void
155125
return $response;
156126
});
157127

158-
$transport = new TelegramTransport(
159-
'testToken',
160-
$channel,
161-
$client
162-
);
128+
$transport = new TelegramTransport('testToken', 'defaultChannel', $client);
163129

164130
$messageOptions = $this->createMock(MessageOptionsInterface::class);
165131
$messageOptions

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.