|
15 | 15 | use Symfony\Component\Messenger\Envelope; |
16 | 16 | use Symfony\Component\Messenger\Stamp\DelayStamp; |
17 | 17 | use Symfony\Component\Messenger\Stamp\ReceivedStamp; |
| 18 | +use Symfony\Component\Messenger\Stamp\StampInterface; |
18 | 19 | use Symfony\Component\Messenger\Stamp\ValidationStamp; |
19 | 20 | use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage; |
20 | 21 |
|
@@ -50,6 +51,30 @@ public function testWithoutAll() |
50 | 51 | $this->assertCount(1, $envelope->all(DelayStamp::class)); |
51 | 52 | } |
52 | 53 |
|
| 54 | + public function testWithoutStampsOfType() |
| 55 | + { |
| 56 | + $envelope = new Envelope(new DummyMessage('dummy'), [ |
| 57 | + new ReceivedStamp('transport1'), |
| 58 | + new DelayStamp(5000), |
| 59 | + new DummyExtendsDelayStamp(5000), |
| 60 | + new DummyImplementsFooBarStampInterface(), |
| 61 | + ]); |
| 62 | + |
| 63 | + $envelope2 = $envelope->withoutStampsOfType(DummyNothingImplementsMeStampInterface::class); |
| 64 | + $this->assertEquals($envelope, $envelope2); |
| 65 | + |
| 66 | + $envelope3 = $envelope2->withoutStampsOfType(ReceivedStamp::class); |
| 67 | + $this->assertEmpty($envelope3->all(ReceivedStamp::class)); |
| 68 | + |
| 69 | + $envelope4 = $envelope3->withoutStampsOfType(DelayStamp::class); |
| 70 | + $this->assertEmpty($envelope4->all(DelayStamp::class)); |
| 71 | + $this->assertEmpty($envelope4->all(DummyExtendsDelayStamp::class)); |
| 72 | + |
| 73 | + $envelope5 = $envelope4->withoutStampsOfType(DummyFooBarStampInterface::class); |
| 74 | + $this->assertEmpty($envelope5->all(DummyImplementsFooBarStampInterface::class)); |
| 75 | + $this->assertEmpty($envelope5->all()); |
| 76 | + } |
| 77 | + |
53 | 78 | public function testLast() |
54 | 79 | { |
55 | 80 | $receivedStamp = new ReceivedStamp('transport'); |
@@ -92,3 +117,16 @@ public function testWrapWithEnvelope() |
92 | 117 | $this->assertCount(1, $envelope->all(ReceivedStamp::class)); |
93 | 118 | } |
94 | 119 | } |
| 120 | + |
| 121 | +class DummyExtendsDelayStamp extends DelayStamp |
| 122 | +{ |
| 123 | +} |
| 124 | +interface DummyFooBarStampInterface extends StampInterface |
| 125 | +{ |
| 126 | +} |
| 127 | +interface DummyNothingImplementsMeStampInterface extends StampInterface |
| 128 | +{ |
| 129 | +} |
| 130 | +class DummyImplementsFooBarStampInterface implements DummyFooBarStampInterface |
| 131 | +{ |
| 132 | +} |
0 commit comments