Skip to content

Commit 06b464e

Browse files
OskarStarkfabpot
authored andcommitted
[Notifier] [DX] Dsn::getRequiredOption()
1 parent 32c6865 commit 06b464e

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Tests/ZulipTransportFactoryTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
1616
use Symfony\Component\Notifier\Exception\IncompleteDsnException;
17+
use Symfony\Component\Notifier\Exception\MissingRequiredOptionException;
1718
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1819
use Symfony\Component\Notifier\Transport\Dsn;
1920

@@ -28,11 +29,11 @@ public function testCreateWithDsn()
2829
$this->assertSame('zulip://host.test?channel=testChannel', (string) $transport);
2930
}
3031

31-
public function testCreateWithMissingOptionChannelThrowsIncompleteDsnException()
32+
public function testCreateWithMissingOptionChannelThrowsMissingRequiredOptionException()
3233
{
3334
$factory = $this->createFactory();
3435

35-
$this->expectException(IncompleteDsnException::class);
36+
$this->expectException(MissingRequiredOptionException::class);
3637

3738
$factory->create(Dsn::fromString('zulip://email:token@host'));
3839
}

ZulipTransportFactory.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Zulip;
1313

14-
use Symfony\Component\Notifier\Exception\IncompleteDsnException;
1514
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1615
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1716
use Symfony\Component\Notifier\Transport\Dsn;
@@ -35,12 +34,7 @@ public function create(Dsn $dsn): TransportInterface
3534

3635
$email = $this->getUser($dsn);
3736
$token = $this->getPassword($dsn);
38-
$channel = $dsn->getOption('channel');
39-
40-
if (!$channel) {
41-
throw new IncompleteDsnException('Missing channel.', $dsn->getOriginalDsn());
42-
}
43-
37+
$channel = $dsn->getRequiredOption('channel');
4438
$host = $dsn->getHost();
4539
$port = $dsn->getPort();
4640

0 commit comments

Comments
 (0)