Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
tyx committed Oct 18, 2023
1 parent 87ab459 commit 1bf1c9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
}

if (null !== $messageGroupId || null !== $messageDeduplicationId) {
$envelope = $envelope->with(
new AmazonSqsFifoStamp(
$messageGroupId,
$messageDeduplicationId,
)
);
$envelope = $envelope->with(new AmazonSqsFifoStamp($messageGroupId, $messageDeduplicationId));
}

return $stack->next()->handle($envelope, $stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public function testAddStampWithGroupIdOnly()
$envelope = new Envelope(new WithMessageGroupIdMessage('groupId'));
$finalEnvelope = $middleware->handle($envelope, $this->getStackMock());
$stamp = $finalEnvelope->last(AmazonSqsFifoStamp::class);
$this->assertNotNull($stamp);
/* @var AmazonSqsFifoStamp $stamp */
$this->assertEquals('groupId', $stamp->getMessageGroupId());
$this->assertInstanceOf(AmazonSqsFifoStamp::class, $stamp);
$this->assertSame('groupId', $stamp->getMessageGroupId());
$this->assertNull($stamp->getMessageDeduplicationId());
}

Expand All @@ -38,9 +37,8 @@ public function testHandleWithDeduplicationIdOnly()
$envelope = new Envelope(new WithMessageDeduplicationIdMessage('deduplicationId'));
$finalEnvelope = $middleware->handle($envelope, $this->getStackMock());
$stamp = $finalEnvelope->last(AmazonSqsFifoStamp::class);
$this->assertNotNull($stamp);
/* @var AmazonSqsFifoStamp $stamp */
$this->assertEquals('deduplicationId', $stamp->getMessageDeduplicationId());
$this->assertInstanceOf(AmazonSqsFifoStamp::class, $stamp);
$this->assertSame('deduplicationId', $stamp->getMessageDeduplicationId());
$this->assertNull($stamp->getMessageGroupId());
}

Expand All @@ -50,10 +48,9 @@ public function testHandleWithGroupIdAndDeduplicationId()
$envelope = new Envelope(new WithMessageDeduplicationIdAndMessageGroupIdMessage('my_group', 'my_random_id'));
$finalEnvelope = $middleware->handle($envelope, $this->getStackMock());
$stamp = $finalEnvelope->last(AmazonSqsFifoStamp::class);
$this->assertNotNull($stamp);
/* @var AmazonSqsFifoStamp $stamp */
$this->assertEquals('my_random_id', $stamp->getMessageDeduplicationId());
$this->assertEquals('my_group', $stamp->getMessageGroupId());
$this->assertInstanceOf(AmazonSqsFifoStamp::class, $stamp);
$this->assertSame('my_random_id', $stamp->getMessageDeduplicationId());
$this->assertSame('my_group', $stamp->getMessageGroupId());
}

public function testHandleWithoutId()
Expand All @@ -62,7 +59,6 @@ public function testHandleWithoutId()
$envelope = new Envelope(new WithoutIdMessage());
$finalEnvelope = $middleware->handle($envelope, $this->getStackMock());
$stamp = $finalEnvelope->last(AmazonSqsFifoStamp::class);
/* @var AmazonSqsFifoStamp $stamp */
$this->assertNull($stamp);
}
}
Expand All @@ -71,7 +67,7 @@ class WithMessageDeduplicationIdAndMessageGroupIdMessage implements WithMessageD
{
public function __construct(
private string $messageGroupId,
private string $messageDeduplicationId
private string $messageDeduplicationId,
) {
}

Expand All @@ -89,7 +85,7 @@ public function messageGroupId(): string
class WithMessageDeduplicationIdMessage implements WithMessageDeduplicationId
{
public function __construct(
private string $messageDeduplicationId
private string $messageDeduplicationId,
) {
}

Expand All @@ -102,7 +98,7 @@ public function messageDeduplicationId(): string
class WithMessageGroupIdMessage implements WithMessageGroupId
{
public function __construct(
private string $messageGroupId
private string $messageGroupId,
) {
}

Expand Down

0 comments on commit 1bf1c9c

Please sign in to comment.