Skip to content

Commit fba28a4

Browse files
committed
upd specs rel to subscription consumer
1 parent 5b49367 commit fba28a4

8 files changed

+20
-303
lines changed

src/Amqp/BasicConsumeBreakOnFalseSpec.php

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/Amqp/BasicConsumeFromAllSubscribedQueuesSpec.php

Lines changed: 0 additions & 94 deletions
This file was deleted.

src/Amqp/BasicConsumeUntilUnsubscribedSpec.php

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/Amqp/BasicConsumeShouldAddConsumerTagOnSubscribeSpec.php renamed to src/Amqp/SubscriptionConsumerAddConsumerTagOnSubscribeSpec.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
namespace Interop\Queue\Spec\Amqp;
44

5-
use Interop\Amqp\AmqpConsumer;
65
use Interop\Amqp\AmqpContext;
7-
use Interop\Amqp\AmqpMessage;
86
use Interop\Amqp\AmqpQueue;
97
use PHPUnit\Framework\TestCase;
108

119
/**
1210
* @group functional
1311
*/
14-
abstract class BasicConsumeShouldAddConsumerTagOnSubscribeSpec extends TestCase
12+
abstract class SubscriptionConsumerAddConsumerTagOnSubscribeSpec extends TestCase
1513
{
1614
/**
1715
* @var AmqpContext
@@ -32,27 +30,23 @@ public function test()
3230
$this->context = $context = $this->createContext();
3331
$context->setQos(0, 5, false);
3432

35-
$queue = $this->createQueue($context, 'basic_consume_should_add_consumer_tag_on_subscribe_spec');
33+
$queue = $this->createQueue($context, 'amqp_subscription_consumer_add_consumer_tag_on_subscribe_spec');
3634

3735
$consumer = $context->createConsumer($queue);
3836

39-
$context->subscribe($consumer, function() {});
37+
//guard
38+
$this->assertNull($consumer->getConsumerTag());
39+
40+
$subscriptionConsumer = $context->createSubscriptionConsumer();
41+
42+
$subscriptionConsumer->subscribe($consumer, function() {});
4043

4144
$this->assertNotEmpty($consumer->getConsumerTag());
4245
}
4346

44-
/**
45-
* @return AmqpContext
46-
*/
47-
abstract protected function createContext();
47+
abstract protected function createContext(): AmqpContext;
4848

49-
/**
50-
* @param AmqpContext $context
51-
* @param string $queueName
52-
*
53-
* @return AmqpQueue
54-
*/
55-
protected function createQueue(AmqpContext $context, $queueName)
49+
protected function createQueue(AmqpContext $context, string $queueName): AmqpQueue
5650
{
5751
$queue = $context->createQueue($queueName);
5852
$context->declareQueue($queue);

src/Amqp/BasicConsumeShouldRemoveConsumerTagOnUnsubscribeSpec.php renamed to src/Amqp/SubscriptionConsumerRemoveConsumerTagOnUnsubscribeSpec.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
namespace Interop\Queue\Spec\Amqp;
44

5-
use Interop\Amqp\AmqpConsumer;
65
use Interop\Amqp\AmqpContext;
7-
use Interop\Amqp\AmqpMessage;
86
use Interop\Amqp\AmqpQueue;
97
use PHPUnit\Framework\TestCase;
108

119
/**
1210
* @group functional
1311
*/
14-
abstract class BasicConsumeShouldRemoveConsumerTagOnUnsubscribeSpec extends TestCase
12+
abstract class SubscriptionConsumerRemoveConsumerTagOnUnsubscribeSpec extends TestCase
1513
{
1614
/**
1715
* @var AmqpContext
@@ -36,29 +34,21 @@ public function test()
3634

3735
$consumer = $context->createConsumer($queue);
3836

39-
$context->subscribe($consumer, function() {});
40-
$context->consume(100);
37+
$subscriptionConsumer = $context->createSubscriptionConsumer();
38+
$subscriptionConsumer->subscribe($consumer, function() {});
39+
$subscriptionConsumer->consume(100);
4140

4241
// guard
4342
$this->assertNotEmpty($consumer->getConsumerTag());
4443

45-
$context->unsubscribe($consumer);
44+
$subscriptionConsumer->unsubscribe($consumer);
4645

4746
$this->assertEmpty($consumer->getConsumerTag());
4847
}
4948

50-
/**
51-
* @return AmqpContext
52-
*/
53-
abstract protected function createContext();
49+
abstract protected function createContext(): AmqpContext;
5450

55-
/**
56-
* @param AmqpContext $context
57-
* @param string $queueName
58-
*
59-
* @return AmqpQueue
60-
*/
61-
protected function createQueue(AmqpContext $context, $queueName)
51+
protected function createQueue(AmqpContext $context, string $queueName): AmqpQueue
6252
{
6353
$queue = $context->createQueue($queueName);
6454
$context->declareQueue($queue);

src/SubscriptionConsumerConsumeFromAllSubscribedQueuesSpec.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Interop\Queue\PsrContext;
77
use Interop\Queue\PsrMessage;
88
use Interop\Queue\PsrQueue;
9-
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
109
use PHPUnit\Framework\TestCase;
1110

1211
/**
@@ -72,7 +71,7 @@ public function test()
7271
}
7372

7473
/**
75-
* @return PsrContext|PsrSubscriptionConsumerAwareContext
74+
* @return PsrContext
7675
*/
7776
abstract protected function createContext();
7877

0 commit comments

Comments
 (0)