Skip to content

Commit ef433fe

Browse files
authored
Merge pull request #908 from uro/hotfix/sns-missing-throw-issue-fix
[SNS] Fix: Missing throw issue
2 parents c32c4d1 + 648001d commit ef433fe

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

pkg/sns/SnsProducer.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function send(Destination $destination, Message $message): void
8787
}
8888

8989
/**
90+
* @throws DeliveryDelayNotSupportedException
91+
*
9092
* @return SnsProducer
9193
*/
9294
public function setDeliveryDelay(int $deliveryDelay = null): Producer
@@ -95,7 +97,7 @@ public function setDeliveryDelay(int $deliveryDelay = null): Producer
9597
return $this;
9698
}
9799

98-
DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
100+
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
99101
}
100102

101103
public function getDeliveryDelay(): ?int
@@ -104,6 +106,8 @@ public function getDeliveryDelay(): ?int
104106
}
105107

106108
/**
109+
* @throws PriorityNotSupportedException
110+
*
107111
* @return SnsProducer
108112
*/
109113
public function setPriority(int $priority = null): Producer
@@ -121,6 +125,8 @@ public function getPriority(): ?int
121125
}
122126

123127
/**
128+
* @throws TimeToLiveNotSupportedException
129+
*
124130
* @return SnsProducer
125131
*/
126132
public function setTimeToLive(int $timeToLive = null): Producer

pkg/sns/Tests/SnsProducerTest.php

+45
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
use Enqueue\Sns\SnsProducer;
1111
use Enqueue\Test\ClassExtensionTrait;
1212
use Interop\Queue\Destination;
13+
use Interop\Queue\Exception\DeliveryDelayNotSupportedException;
1314
use Interop\Queue\Exception\InvalidDestinationException;
1415
use Interop\Queue\Exception\InvalidMessageException;
16+
use Interop\Queue\Exception\PriorityNotSupportedException;
17+
use Interop\Queue\Exception\TimeToLiveNotSupportedException;
1518
use Interop\Queue\Producer;
1619
use PHPUnit\Framework\TestCase;
1720

@@ -84,6 +87,48 @@ public function testShouldThrowIfPublishFailed()
8487
$producer->send($destination, $message);
8588
}
8689

90+
public function testShouldThrowIfsetTimeToLiveIsNotNull()
91+
{
92+
$this->expectException(TimeToLiveNotSupportedException::class);
93+
94+
$producer = new SnsProducer($this->createSnsContextMock());
95+
$result = $producer->setTimeToLive();
96+
97+
$this->assertInstanceOf(SnsProducer::class, $result);
98+
99+
$this->expectExceptionMessage('The provider does not support time to live feature');
100+
101+
$producer->setTimeToLive(200);
102+
}
103+
104+
public function testShouldThrowIfsetPriorityIsNotNull()
105+
{
106+
$this->expectException(PriorityNotSupportedException::class);
107+
108+
$producer = new SnsProducer($this->createSnsContextMock());
109+
$result = $producer->setPriority();
110+
111+
$this->assertInstanceOf(SnsProducer::class, $result);
112+
113+
$this->expectExceptionMessage('The provider does not support priority feature');
114+
115+
$producer->setPriority(200);
116+
}
117+
118+
public function testShouldThrowIfsetDeliveryDelayIsNotNull()
119+
{
120+
$this->expectException(DeliveryDelayNotSupportedException::class);
121+
122+
$producer = new SnsProducer($this->createSnsContextMock());
123+
$result = $producer->setDeliveryDelay();
124+
125+
$this->assertInstanceOf(SnsProducer::class, $result);
126+
127+
$this->expectExceptionMessage('The provider does not support delivery delay feature');
128+
129+
$producer->setDeliveryDelay(200);
130+
}
131+
87132
public function testShouldPublish()
88133
{
89134
$destination = new SnsDestination('queue-name');

0 commit comments

Comments
 (0)