|
1
|
|
|
<?php |
|
2
|
|
|
namespace Da\Mailer\Test\Queue\Backend\Sqs; |
|
3
|
|
|
|
|
4
|
|
|
use Aws\Sqs\SqsClient; |
|
5
|
|
|
use Da\Mailer\Queue\Backend\Sqs\SqsQueueStoreConnection; |
|
6
|
|
|
use PHPUnit_Framework_TestCase; |
|
7
|
|
|
use ReflectionClass; |
|
8
|
|
|
|
|
9
|
|
|
class SqsQueueStoreConnectionTest extends PHPUnit_Framework_TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
public function testGetConfigurationValue() |
|
12
|
|
|
{ |
|
13
|
|
|
$class = new ReflectionClass(SqsQueueStoreConnection::class); |
|
14
|
|
|
|
|
15
|
|
|
$method = $class->getMethod('getConfigurationValue'); |
|
16
|
|
|
$method->setAccessible(true); |
|
17
|
|
|
|
|
18
|
|
|
$key = 'AKIAxxxxxxxxxxxxxxxZ'; |
|
19
|
|
|
$secret = 'AxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ'; |
|
20
|
|
|
$region = 'eu-north-99'; |
|
21
|
|
|
|
|
22
|
|
|
$connection = new SqsQueueStoreConnection([ |
|
23
|
|
|
'key' => $key, |
|
24
|
|
|
'secret' => $secret, |
|
25
|
|
|
'region' => $region, |
|
26
|
|
|
]); |
|
27
|
|
|
|
|
28
|
|
|
$this->assertEquals($key, $method->invoke($connection, 'key')); |
|
29
|
|
|
$this->assertEquals($secret, $method->invoke($connection, 'secret')); |
|
30
|
|
|
$this->assertEquals($region, $method->invoke($connection, 'region')); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testConnect() |
|
34
|
|
|
{ |
|
35
|
|
|
$connection = new SqsQueueStoreConnection([ |
|
36
|
|
|
'key' => 'AKIAxxxxxxxxxxxxxxxZ', |
|
37
|
|
|
'secret' => 'AxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ', |
|
38
|
|
|
'region' => 'eu-north-99', |
|
39
|
|
|
]); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertTrue($connection->getInstance() instanceof SqsClient); |
|
42
|
|
|
$this->assertSame($connection, $connection->connect()); |
|
43
|
|
|
$this->assertTrue($connection->getInstance() instanceof SqsClient); |
|
44
|
|
|
$this->assertSame($connection, $connection->connect()); |
|
45
|
|
|
$this->assertTrue($connection->getInstance() instanceof SqsClient); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|