public function testExecute()
 {
     $application = new Application($this->httpClient->getKernel());
     $application->add(new InitKillQueueCommand());
     /** @var InitKillQueueCommand $command */
     $command = $application->find('syrup:queue:kill-init');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertEquals(0, $commandTester->getStatusCode());
     /** @var QueueFactory $queueFactory */
     $queueFactory = $this->httpClient->getContainer()->get('syrup.queue_factory');
     $queueId = 'syrup_kill_' . str_replace('.keboola.com', '', gethostname());
     $queueService = $queueFactory->get($queueId);
     $this->assertInstanceOf('Keboola\\Syrup\\Service\\Queue\\QueueService', $queueService);
     $snsConfig = $this->httpClient->getContainer()->getParameter('sns');
     $snsClient = new SnsClient(['credentials' => ['key' => $snsConfig['key'], 'secret' => $snsConfig['secret']], 'region' => isset($snsConfig['region']) ? $snsConfig['region'] : 'us-east-1', 'version' => '2010-03-31']);
     $subscriptions = $snsClient->listSubscriptionsByTopic(['TopicArn' => $snsConfig['topic_arn']]);
     $ssArr = $subscriptions->get('Subscriptions');
     $ourSS = null;
     foreach ($ssArr as $ss) {
         if (false !== strstr($ss['Endpoint'], $queueId)) {
             $ourSS = $ss;
             break;
         }
     }
     $this->assertNotNull($ourSS);
     $this->assertEquals('sqs', $ourSS['Protocol']);
     $this->assertEquals($snsConfig['topic_arn'], $ourSS['TopicArn']);
 }
Exemplo n.º 2
0
 /**
  * Get a list of Subscriptions for the specified SNS Topic
  *
  * @param string $topicArn The SNS Topic Arn
  *
  * @return array
  */
 public function getTopicSubscriptions($topicArn)
 {
     $result = $this->sns->listSubscriptionsByTopic(['TopicArn' => $topicArn]);
     return $result->get('Subscriptions');
 }
<?php

session_start();
require 'vendor/autoload.php';
use Aws\Sns\SnsClient;
//Create topic and subscribe to it
$email = $_POST['email'];
$sns = new Aws\Sns\SnsClient(array('version' => 'latest', 'region' => 'us-east-1'));
$ArnArray = $sns->createTopic(['Name' => 'mp2-jgl-pict']);
$Arn = $ArnArray['TopicArn'];
$settopicAttributes = $sns->setTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict'));
$topicAttributes = $sns->getTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict'));
$listSubscriptions = $sns->listSubscriptionsByTopic(array('TopicArn' => $Arn));
$subscribe = $sns->subscribe(array('TopicArn' => $Arn, 'Protocol' => 'email', 'Endpoint' => $email));
?>

<html>
<body style="background-color:LemonChiffon">
<center> 
<h1 style=> Subscription confirmed</h1>
<h2> 
		<?php 
echo $email;
?>
</h2>
<h3>           <?php 
echo "\r\n";
echo "You will receive an email you must confirm";
?>
</h3><a href="/index.php">Index page</a></center>