-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?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); | ||
} | ||
|
||
public function testEnvelopeDuplicates(): void | ||
{ | ||
$message = new Message('handler', 'test'); | ||
$message = new IdEnvelope($message, 'test-id'); | ||
$message = new IdEnvelope($message, 'test-id'); | ||
$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, | ||
IdEnvelope::class, | ||
IdEnvelope::class, | ||
], $stack); | ||
} | ||
} |