Skip to content

[SNS] Fix: Missing throw issue #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/sns/SnsProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public function send(Destination $destination, Message $message): void
}

/**
* @throws DeliveryDelayNotSupportedException
*
* @return SnsProducer
*/
public function setDeliveryDelay(int $deliveryDelay = null): Producer
Expand All @@ -95,7 +97,7 @@ public function setDeliveryDelay(int $deliveryDelay = null): Producer
return $this;
}

DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
}

public function getDeliveryDelay(): ?int
Expand All @@ -104,6 +106,8 @@ public function getDeliveryDelay(): ?int
}

/**
* @throws PriorityNotSupportedException
*
* @return SnsProducer
*/
public function setPriority(int $priority = null): Producer
Expand All @@ -121,6 +125,8 @@ public function getPriority(): ?int
}

/**
* @throws TimeToLiveNotSupportedException
*
* @return SnsProducer
*/
public function setTimeToLive(int $timeToLive = null): Producer
Expand Down
45 changes: 45 additions & 0 deletions pkg/sns/Tests/SnsProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
use Enqueue\Sns\SnsProducer;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Destination;
use Interop\Queue\Exception\DeliveryDelayNotSupportedException;
use Interop\Queue\Exception\InvalidDestinationException;
use Interop\Queue\Exception\InvalidMessageException;
use Interop\Queue\Exception\PriorityNotSupportedException;
use Interop\Queue\Exception\TimeToLiveNotSupportedException;
use Interop\Queue\Producer;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -84,6 +87,48 @@ public function testShouldThrowIfPublishFailed()
$producer->send($destination, $message);
}

public function testShouldThrowIfsetTimeToLiveIsNotNull()
{
$this->expectException(TimeToLiveNotSupportedException::class);

$producer = new SnsProducer($this->createSnsContextMock());
$result = $producer->setTimeToLive();

$this->assertInstanceOf(SnsProducer::class, $result);

$this->expectExceptionMessage('The provider does not support time to live feature');

$producer->setTimeToLive(200);
}

public function testShouldThrowIfsetPriorityIsNotNull()
{
$this->expectException(PriorityNotSupportedException::class);

$producer = new SnsProducer($this->createSnsContextMock());
$result = $producer->setPriority();

$this->assertInstanceOf(SnsProducer::class, $result);

$this->expectExceptionMessage('The provider does not support priority feature');

$producer->setPriority(200);
}

public function testShouldThrowIfsetDeliveryDelayIsNotNull()
{
$this->expectException(DeliveryDelayNotSupportedException::class);

$producer = new SnsProducer($this->createSnsContextMock());
$result = $producer->setDeliveryDelay();

$this->assertInstanceOf(SnsProducer::class, $result);

$this->expectExceptionMessage('The provider does not support delivery delay feature');

$producer->setDeliveryDelay(200);
}

public function testShouldPublish()
{
$destination = new SnsDestination('queue-name');
Expand Down