-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathEnvelopeTest.php
More file actions
46 lines (34 loc) · 1.38 KB
/
Copy pathEnvelopeTest.php
File metadata and controls
46 lines (34 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Unit;
use PHPUnit\Framework\TestCase;
use Yiisoft\Queue\Message\EnvelopeInterface;
use Yiisoft\Queue\Message\IdEnvelope;
use Yiisoft\Queue\Message\Message;
final class EnvelopeTest extends TestCase
{
public function testEnvelopeStack(): void
{
$message = new Message('handler', 'test');
$message = new IdEnvelope($message, 'test-id');
$this->assertEquals('test', $message->getMessage()->getData());
$stack = $message->getMetadata()[EnvelopeInterface::ENVELOPE_STACK_KEY];
$this->assertIsArray($stack);
$this->assertEquals([
IdEnvelope::class,
], $stack);
$this->assertEquals('test-id', $message->getMetadata()[IdEnvelope::MESSAGE_ID_KEY]);
}
public function testEnvelopeDuplicates(): void
{
$message = new Message('handler', 'test');
$message = new IdEnvelope($message, 'test-id-1');
$message = new IdEnvelope($message, 'test-id-2');
$message = new IdEnvelope($message, 'test-id-3');
$this->assertEquals('test', $message->getMessage()->getData());
$stack = $message->getMetadata()[EnvelopeInterface::ENVELOPE_STACK_KEY];
$this->assertIsArray($stack);
$this->assertEquals([IdEnvelope::class], $stack);
$this->assertEquals('test-id-3', $message->getMetadata()[IdEnvelope::MESSAGE_ID_KEY]);
}
}