|
2 | 2 |
|
3 | 3 | namespace Enqueue\Sns\Tests\Spec;
|
4 | 4 |
|
| 5 | +use Aws\Result; |
5 | 6 | use Enqueue\Sns\SnsClient;
|
6 | 7 | use Enqueue\Sns\SnsContext;
|
| 8 | +use Enqueue\Sns\SnsDestination; |
| 9 | +use Enqueue\Sns\SnsSubscribe; |
7 | 10 | use Interop\Queue\Spec\ContextSpec;
|
8 | 11 |
|
9 | 12 | class SnsContextTest extends ContextSpec
|
10 | 13 | {
|
11 |
| - public function testShouldCreateConsumerOnCreateConsumerMethodCall() |
| 14 | + public function testShouldCreateConsumerOnCreateConsumerMethodCall(): void |
12 | 15 | {
|
13 | 16 | $this->expectException(\LogicException::class);
|
14 | 17 | $this->expectExceptionMessage('SNS transport does not support consumption. You should consider using SQS instead.');
|
15 | 18 |
|
16 | 19 | parent::testShouldCreateConsumerOnCreateConsumerMethodCall();
|
17 | 20 | }
|
18 | 21 |
|
| 22 | + public function testSetsSubscriptionAttributes(): void |
| 23 | + { |
| 24 | + $client = $this->createMock(SnsClient::class); |
| 25 | + $client->expects($this->once()) |
| 26 | + ->method('listSubscriptionsByTopic') |
| 27 | + ->willReturn(new Result(['Subscriptions' => [ |
| 28 | + ['SubscriptionArn' => 'arn1'], |
| 29 | + ['SubscriptionArn' => 'arn2'], |
| 30 | + ]])); |
| 31 | + $client->expects($this->exactly(2)) |
| 32 | + ->method('setSubscriptionAttributes') |
| 33 | + ->withConsecutive( |
| 34 | + [$this->equalTo(['attr1' => 'value1', 'SubscriptionArn' => 'arn1'])], |
| 35 | + [$this->equalTo(['attr1' => 'value1', 'SubscriptionArn' => 'arn2'])], |
| 36 | + ); |
| 37 | + |
| 38 | + $context = new SnsContext($client, ['topic_arns' => ['topic1' => 'topicArn1']]); |
| 39 | + $context->setSubscriptionAttributes(new SnsSubscribe( |
| 40 | + new SnsDestination('topic1'), |
| 41 | + 'endpoint1', |
| 42 | + 'protocol1', |
| 43 | + false, |
| 44 | + ['attr1' => 'value1'], |
| 45 | + )); |
| 46 | + } |
| 47 | + |
19 | 48 | protected function createContext()
|
20 | 49 | {
|
21 | 50 | $client = $this->createMock(SnsClient::class);
|
|
0 commit comments