Updating SyncTransport for recent changes + tests
This commit is contained in:
parent
88042a317a
commit
2df023be46
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
use Symfony\Component\Messenger\Transport\Sync\SyncTransport;
|
||||
use Symfony\Component\Messenger\Transport\Sync\SyncTransportFactory;
|
||||
|
||||
class SyncTransportFactoryTest extends TestCase
|
||||
{
|
||||
public function testCreateTransport()
|
||||
{
|
||||
$serializer = $this->createMock(SerializerInterface::class);
|
||||
$factory = new SyncTransportFactory();
|
||||
$transport = $factory->createTransport('sync://', [], $serializer);
|
||||
$this->assertInstanceOf(SyncTransport::class, $transport);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\Stamp\ForceCallHandlersStamp;
|
||||
use Symfony\Component\Messenger\Transport\Sync\SyncTransport;
|
||||
|
||||
class SyncTransportTest extends TestCase
|
||||
{
|
||||
public function testSend()
|
||||
{
|
||||
$message = new \stdClass();
|
||||
$envelope = new Envelope($message);
|
||||
$transport = new SyncTransport();
|
||||
$envelope = $transport->send($envelope);
|
||||
$this->assertSame($message, $envelope->getMessage());
|
||||
$this->assertNotNull($envelope->last(ForceCallHandlersStamp::class));
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
*/
|
||||
class SyncTransport implements TransportInterface
|
||||
{
|
||||
public function receive(callable $handler): void
|
||||
public function get(): iterable
|
||||
{
|
||||
throw new InvalidArgumentException('You cannot receive messages from the SyncTransport.');
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Messenger\Transport\Sync;
|
||||
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
|
||||
use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
|
||||
@ -21,7 +22,7 @@ use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||
*/
|
||||
class SyncTransportFactory implements TransportFactoryInterface
|
||||
{
|
||||
public function createTransport(string $dsn, array $options): TransportInterface
|
||||
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
|
||||
{
|
||||
return new SyncTransport();
|
||||
}
|
||||
|
Reference in New Issue
Block a user