Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31f0f16

Browse files
committed
Fix tests
1 parent 192a725 commit 31f0f16

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Messenger/DefaultSchedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\Messenger\Attribute\AsSchedule;
66

7-
#[AsSchedule('custom')]
7+
#[AsSchedule('default')]
88
class DefaultSchedule implements \IteratorAggregate
99
{
1010
public static array|\Traversable $schedule = [];

src/Symfony/Component/Messenger/Tests/Transport/Schedule/ScheduleTransportFactoryTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Container\ContainerInterface;
16+
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
1617
use Symfony\Component\Messenger\Transport\Schedule\ScheduleTransport;
1718
use Symfony\Component\Messenger\Transport\Schedule\ScheduleTransportFactory;
1819
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
1920

2021
class ScheduleTransportFactoryTest extends TestCase
2122
{
22-
public function testOne()
23+
public function testCreateTransport()
2324
{
2425
$serializer = $this->createMock(SerializerInterface::class);
2526
$container = new class() extends \ArrayObject implements ContainerInterface {
@@ -47,6 +48,24 @@ public function has(string $id): bool
4748
$this->assertEquals($custom, $factory->createTransport('schedule://custom', [], $serializer));
4849
}
4950

51+
public function testInvalidDsn()
52+
{
53+
$this->expectException(InvalidArgumentException::class);
54+
$this->expectExceptionMessage('The given Schedule DSN "schedule://#wrong" is invalid.');
55+
56+
$factory = new ScheduleTransportFactory($this->createMock(ContainerInterface::class));
57+
$factory->createTransport('schedule://#wrong', [], $this->createMock(SerializerInterface::class));
58+
}
59+
60+
public function testNotFound()
61+
{
62+
$this->expectException(InvalidArgumentException::class);
63+
$this->expectExceptionMessage('The schedule "not-exists" is not found.');
64+
65+
$factory = new ScheduleTransportFactory($this->createMock(ContainerInterface::class));
66+
$factory->createTransport('schedule://not-exists', [], $this->createMock(SerializerInterface::class));
67+
}
68+
5069
public function testSupports()
5170
{
5271
$factory = new ScheduleTransportFactory($this->createMock(ContainerInterface::class));

src/Symfony/Component/Messenger/Transport/Schedule/ScheduleTransportFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ public function createTransport(string $dsn, array $options, SerializerInterface
2626
{
2727
$parsedUrl = [];
2828
if ('schedule://' !== $dsn && false === $parsedUrl = parse_url($dsn)) {
29-
// fixme better error message
30-
throw new InvalidArgumentException(sprintf('The given DSN "%s" is invalid.', $dsn));
29+
throw new InvalidArgumentException(sprintf('The given Schedule DSN "%s" is invalid.', $dsn));
3130
}
3231

3332
$scheduleName = $options['name'] ?? $parsedUrl['host'] ?? 'default';
3433
if (!$this->schedulesLocator->has($scheduleName)) {
35-
// fixme better error message
3634
throw new InvalidArgumentException(sprintf('The schedule "%s" is not found.', $scheduleName));
3735
}
3836

0 commit comments

Comments
 (0)