Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
use Doctrine\DBAL\Connection as DbalConnection;
use Doctrine\DBAL\Schema\Schema;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
class DoctrineTransportTest extends TestCase
{
public function testItIsATransport()
{
$transport = $this->getTransport();
$this->assertInstanceOf(TransportInterface::class, $transport);
}
public function testReceivesMessages()
{
$transport = $this->getTransport(
$serializer = $this->createMock(SerializerInterface::class),
$connection = $this->createMock(Connection::class)
);
$decodedMessage = new DummyMessage('Decoded.');
$doctrineEnvelope = [
'id' => '5',
'body' => 'body',
'headers' => ['my' => 'header'],
];
$serializer->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
$connection->method('get')->willReturn($doctrineEnvelope);
$envelopes = $transport->get();
$this->assertSame($decodedMessage, $envelopes[0]->getMessage());
}
public function testConfigureSchema()
{
$transport = $this->getTransport(
null,
$connection = $this->createMock(Connection::class)
);
$schema = new Schema();
$dbalConnection = $this->createMock(DbalConnection::class);
$connection->expects($this->once())
->method('configureSchema')
->with($schema, $dbalConnection, static fn () => true);
$transport->configureSchema($schema, $dbalConnection, static fn () => true);
}
private function getTransport(?SerializerInterface $serializer = null, ?Connection $connection = null): DoctrineTransport
{
$serializer ??= $this->createMock(SerializerInterface::class);
$connection ??= $this->createMock(Connection::class);
return new DoctrineTransport($connection, $serializer);
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
use Doctrine\DBAL\Connection as DbalConnection;
use Doctrine\DBAL\Schema\Schema;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
class DoctrineTransportTest extends TestCase
{
public function testItIsATransport()
{
$transport = $this->getTransport();
$this->assertInstanceOf(TransportInterface::class, $transport);
}
public function testReceivesMessages()
{
$transport = $this->getTransport(
$serializer = $this->createMock(SerializerInterface::class),
$connection = $this->createMock(Connection::class)
);
$decodedMessage = new DummyMessage('Decoded.');
$doctrineEnvelope = [
'id' => '5',
'body' => 'body',
'headers' => ['my' => 'header'],
];
$serializer->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
$connection->method('get')->willReturn($doctrineEnvelope);
$envelopes = $transport->get();
$this->assertSame($decodedMessage, $envelopes[0]->getMessage());
}
public function testConfigureSchema()
{
$transport = $this->getTransport(
null,
$connection = $this->createMock(Connection::class)
);
$schema = new Schema();
$dbalConnection = $this->createMock(DbalConnection::class);
$connection->expects($this->once())
->method('configureSchema')
->with($schema, $dbalConnection, static fn () => true);
$transport->configureSchema($schema, $dbalConnection, static fn () => true);
}
private function getTransport(?SerializerInterface $serializer = null, ?Connection $connection = null): DoctrineTransport
{
$serializer ??= $this->createMock(SerializerInterface::class);
$connection ??= $this->createMock(Connection::class);
return new DoctrineTransport($connection, $serializer);
}
}
Function Calls
None |
Stats
MD5 | d6c707ca32db7e2c9660ac1bf1ed8f23 |
Eval Count | 0 |
Decode Time | 101 ms |