Skip to content

Commit

Permalink
Merge pull request php-enqueue#908 from uro/hotfix/sns-missing-throw-…
Browse files Browse the repository at this point in the history
…issue-fix

[SNS] Fix: Missing throw issue
  • Loading branch information
makasim authored Jun 25, 2019
2 parents c32c4d1 + 648001d commit ef433fe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
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

0 comments on commit ef433fe

Please sign in to comment.