Skip to content

Commit 3a03b73

Browse files
committed
delay strategy
1 parent 7ddc44e commit 3a03b73

3 files changed

Lines changed: 72 additions & 12 deletions

File tree

‎pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Enqueue\Sqs\SqsConnectionFactory;
66
use Enqueue\Sqs\SqsContext;
7+
use Enqueue\Sqs\SqsDestination;
78
use Enqueue\Test\RetryTrait;
89
use Interop\Queue\PsrContext;
910
use Interop\Queue\Spec\SendAndReceiveDelayedMessageFromQueueSpec;
@@ -16,6 +17,16 @@ class SqsSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelayed
1617
{
1718
use RetryTrait;
1819

20+
/**
21+
* @var SqsContext
22+
*/
23+
private $context;
24+
25+
/**
26+
* @var SqsDestination
27+
*/
28+
private $queue;
29+
1930
/**
2031
* {@inheritdoc}
2132
*/
@@ -27,7 +38,7 @@ protected function createContext()
2738
'region' => getenv('AWS__SQS__REGION'),
2839
]);
2940

30-
return $factory->createContext();
41+
return $this->context = $factory->createContext();
3142
}
3243

3344
/**
@@ -39,9 +50,18 @@ protected function createQueue(PsrContext $context, $queueName)
3950
{
4051
$queueName = $queueName.time();
4152

42-
$queue = $context->createQueue($queueName);
43-
$context->declareQueue($queue);
53+
$this->queue = $context->createQueue($queueName);
54+
$context->declareQueue($this->queue);
55+
56+
return $this->queue;
57+
}
58+
59+
protected function tearDown()
60+
{
61+
parent::tearDown();
4462

45-
return $queue;
63+
if ($this->context && $this->queue) {
64+
$this->context->deleteQueue($this->queue);
65+
}
4666
}
4767
}

‎pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Enqueue\Sqs\SqsConnectionFactory;
66
use Enqueue\Sqs\SqsContext;
7+
use Enqueue\Sqs\SqsDestination;
78
use Interop\Queue\PsrContext;
89
use Interop\Queue\Spec\SendToAndReceiveFromQueueSpec;
910

@@ -12,6 +13,16 @@
1213
*/
1314
class SqsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
1415
{
16+
/**
17+
* @var SqsContext
18+
*/
19+
private $context;
20+
21+
/**
22+
* @var SqsDestination
23+
*/
24+
private $queue;
25+
1526
/**
1627
* {@inheritdoc}
1728
*/
@@ -23,7 +34,7 @@ protected function createContext()
2334
'region' => getenv('AWS__SQS__REGION'),
2435
]);
2536

26-
return $factory->createContext();
37+
return $this->context = $factory->createContext();
2738
}
2839

2940
/**
@@ -35,9 +46,18 @@ protected function createQueue(PsrContext $context, $queueName)
3546
{
3647
$queueName = $queueName.time();
3748

38-
$queue = $context->createQueue($queueName);
39-
$context->declareQueue($queue);
49+
$this->queue = $context->createQueue($queueName);
50+
$context->declareQueue($this->queue);
51+
52+
return $this->queue;
53+
}
54+
55+
protected function tearDown()
56+
{
57+
parent::tearDown();
4058

41-
return $queue;
59+
if ($this->context && $this->queue) {
60+
$this->context->deleteQueue($this->queue);
61+
}
4262
}
4363
}

‎pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Enqueue\Sqs\SqsConnectionFactory;
66
use Enqueue\Sqs\SqsContext;
7+
use Enqueue\Sqs\SqsDestination;
78
use Interop\Queue\PsrContext;
89
use Interop\Queue\Spec\SendToAndReceiveFromTopicSpec;
910

@@ -12,6 +13,16 @@
1213
*/
1314
class SqsSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
1415
{
16+
/**
17+
* @var SqsContext
18+
*/
19+
private $context;
20+
21+
/**
22+
* @var SqsDestination
23+
*/
24+
private $queue;
25+
1526
/**
1627
* {@inheritdoc}
1728
*/
@@ -23,7 +34,7 @@ protected function createContext()
2334
'region' => getenv('AWS__SQS__REGION'),
2435
]);
2536

26-
return $factory->createContext();
37+
return $this->context = $factory->createContext();
2738
}
2839

2940
/**
@@ -35,9 +46,18 @@ protected function createTopic(PsrContext $context, $topicName)
3546
{
3647
$topicName = $topicName.time();
3748

38-
$topic = $context->createTopic($topicName);
39-
$context->declareQueue($topic);
49+
$this->queue = $context->createTopic($topicName);
50+
$context->declareQueue($this->queue);
51+
52+
return $this->queue;
53+
}
54+
55+
protected function tearDown()
56+
{
57+
parent::tearDown();
4058

41-
return $topic;
59+
if ($this->context && $this->queue) {
60+
$this->context->deleteQueue($this->queue);
61+
}
4262
}
4363
}

0 commit comments

Comments
 (0)