|
| 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; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\Messenger\Envelope; |
| 16 | +use Symfony\Component\Messenger\Transport\InMemoryTransport; |
| 17 | + |
| 18 | +/** |
| 19 | + * @internal |
| 20 | + * |
| 21 | + * @author Gary PEGEOT <garypegeot@gmail.com> |
| 22 | + */ |
| 23 | +class InMemoryTransportTest extends TestCase |
| 24 | +{ |
| 25 | + /** |
| 26 | + * @var InMemoryTransport |
| 27 | + */ |
| 28 | + private $transport; |
| 29 | + |
| 30 | + protected function setUp() |
| 31 | + { |
| 32 | + $this->transport = new InMemoryTransport(); |
| 33 | + } |
| 34 | + |
| 35 | + public function testSend() |
| 36 | + { |
| 37 | + $envelope = new Envelope(new \stdClass()); |
| 38 | + $this->transport->send($envelope); |
| 39 | + $this->assertSame([$envelope], $this->transport->get()); |
| 40 | + } |
| 41 | + |
| 42 | + public function testAck() |
| 43 | + { |
| 44 | + $envelope = new Envelope(new \stdClass()); |
| 45 | + $this->transport->ack($envelope); |
| 46 | + $this->assertSame([$envelope], $this->transport->getAcknowledged()); |
| 47 | + } |
| 48 | + |
| 49 | + public function testReject() |
| 50 | + { |
| 51 | + $envelope = new Envelope(new \stdClass()); |
| 52 | + $this->transport->reject($envelope); |
| 53 | + $this->assertSame([$envelope], $this->transport->getRejected()); |
| 54 | + } |
| 55 | + |
| 56 | + public function testReset() |
| 57 | + { |
| 58 | + $envelope = new Envelope(new \stdClass()); |
| 59 | + $this->transport->send($envelope); |
| 60 | + $this->transport->ack($envelope); |
| 61 | + $this->transport->reject($envelope); |
| 62 | + |
| 63 | + $this->transport->reset(); |
| 64 | + |
| 65 | + $this->assertEmpty($this->transport->get(), 'Should be empty after reset'); |
| 66 | + $this->assertEmpty($this->transport->getAcknowledged(), 'Should be empty after reset'); |
| 67 | + $this->assertEmpty($this->transport->getRejected(), 'Should be empty after reset'); |
| 68 | + } |
| 69 | +} |
0 commit comments