Skip to content

Commit 759a908

Browse files
committed
fix tests
1 parent 0034d79 commit 759a908

1 file changed

Lines changed: 11 additions & 32 deletions

File tree

‎pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueWithBasicConsumeMethodTest.php‎

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Interop\Amqp\AmqpTopic;
88
use Interop\Amqp\Impl\AmqpBind;
99
use Interop\Queue\PsrContext;
10-
use Interop\Queue\PsrMessage;
1110
use Interop\Queue\Spec\SendToTopicAndReceiveFromQueueSpec;
1211

1312
/**
@@ -27,37 +26,6 @@ protected function createContext()
2726
return $factory->createContext();
2827
}
2928

30-
public function test()
31-
{
32-
$context = $this->createContext();
33-
34-
$topic = $context->createTopic('send_to_topic_and_receive_from_queue_spec_basic_consume3');
35-
$topic->setType(AmqpTopic::TYPE_FANOUT);
36-
$topic->addFlag(AmqpTopic::FLAG_DURABLE);
37-
$context->declareTopic($topic);
38-
39-
$queue = $context->createQueue('send_to_topic_and_receive_from_queue_spec_basic_consume3');
40-
$context->declareQueue($queue);
41-
$context->purgeQueue($queue);
42-
43-
$context->bind(new AmqpBind($topic, $queue));
44-
45-
$consumer = $context->createConsumer($queue);
46-
47-
$expectedBody = __CLASS__.time();
48-
49-
$context->createProducer()->send($topic, $context->createMessage($expectedBody));
50-
51-
$message = $consumer->receive(2000); // 2 sec
52-
53-
var_dump($message);
54-
55-
$this->assertInstanceOf(PsrMessage::class, $message);
56-
$consumer->acknowledge($message);
57-
58-
$this->assertSame($expectedBody, $message->getBody());
59-
}
60-
6129
/**
6230
* {@inheritdoc}
6331
*
@@ -68,7 +36,13 @@ protected function createQueue(PsrContext $context, $queueName)
6836
$queueName .= '_basic_consume';
6937

7038
$queue = $context->createQueue($queueName);
39+
40+
try {
41+
$context->deleteQueue($queue);
42+
} catch (\Exception $e) {}
43+
7144
$context->declareQueue($queue);
45+
$context->purgeQueue($queue);
7246

7347
$context->bind(new AmqpBind($this->topic, $queue));
7448

@@ -87,6 +61,11 @@ protected function createTopic(PsrContext $context, $topicName)
8761
$topic = $context->createTopic($topicName);
8862
$topic->setType(AmqpTopic::TYPE_FANOUT);
8963
$topic->addFlag(AmqpTopic::FLAG_DURABLE);
64+
65+
try {
66+
$context->deleteQueue($topic);
67+
} catch (\Exception $e) {}
68+
9069
$context->declareTopic($topic);
9170

9271
return $this->topic = $topic;

0 commit comments

Comments
 (0)