8000 bug #30798 [Messenger] Updating SyncTransport for recent changes + te… · symfony/symfony@177a0d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 177a0d9

Browse files
committed
bug #30798 [Messenger] Updating SyncTransport for recent changes + tests (weaverryan)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Messenger] Updating SyncTransport for recent changes + tests | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | not needed When making the `SyncTransport`, I neglected having at least one test in each of these classes, which allowed the test suite to pass, even after some interface changes made these classes fail. Fixed all of that :) Commits ------- 2df023b Updating SyncTransport for recent changes + tests
2 parents 3abca64 + 2df023b commit 177a0d9

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
16+
use Symfony\Component\Messenger\Transport\Sync\SyncTransport;
17+
use Symfony\Component\Messenger\Transport\Sync\SyncTransportFactory;
18+
19+
class SyncTransportFactoryTest extends TestCase
20+
{
21+
public function testCreateTransport()
22+
{
23+
$serializer = $this->createMock(SerializerInterface::class);
24+
$factory = new SyncTransportFactory();
25+
$transport = $factory->createTransport('sync://', [], $serializer);
26+
$this->assertInstanceOf(SyncTransport::class, $transport);
27+
}
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Messenger\Envelope;
16+
use Symfony\Component\Messenger\Stamp\ForceCallHandlersStamp;
17+
use Symfony\Component\Messenger\Transport\Sync\SyncTransport;
18+
19+
class SyncTransportTest extends TestCase
20+
{
21+
public function testSend()
22+
{
23+
$message = new \stdClass();
24+
$envelope = new Envelope($message);
25+
$transport = new SyncTransport();
26+
$envelope = $transport->send($envelope);
27+
$this->assertSame($message, $envelope->getMessage());
28+
$this->assertNotNull($envelope->last(ForceCallHandlersStamp::class));
29+
}
30+
}

src/Symfony/Component/Messenger/Transport/Sync/SyncTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class SyncTransport implements TransportInterface
2727
{
28-
public function receive(callable $handler): void
28+
public function get(): iterable
2929
{
3030
throw new InvalidArgumentException('You cannot receive messages from the SyncTransport.');
3131
}

src/Symfony/Component/Messenger/Transport/Sync/SyncTransportFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Messenger\Transport\Sync;
1313

14+
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
1415
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
1516
use Symfony\Component\Messenger\Transport\TransportInterface;
1617

@@ -21,7 +22,7 @@
2122
*/
2223
class SyncTransportFactory implements TransportFactoryInterface
2324
{
24-
public function createTransport(string $dsn, array $options): TransportInterface
25+
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
2526
{
2627
return new SyncTransport();
2728
}

0 commit comments

Comments
 (0)
0