-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathSnsConnectionFactoryTest.php
More file actions
85 lines (68 loc) · 2.44 KB
/
Copy pathSnsConnectionFactoryTest.php
File metadata and controls
85 lines (68 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Enqueue\Sns\Tests;
use Aws\Sns\SnsClient as AwsSnsClient;
use Enqueue\Sns\SnsClient;
use Enqueue\Sns\SnsConnectionFactory;
use Enqueue\Sns\SnsContext;
use Enqueue\Test\ClassExtensionTrait;
use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class SnsConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
$this->assertClassImplements(ConnectionFactory::class, SnsConnectionFactory::class);
}
public function testCouldBeConstructedWithEmptyConfiguration()
{
$factory = new SnsConnectionFactory([]);
$this->assertAttributeEquals([
'lazy' => true,
'key' => null,
'secret' => null,
'token' => null,
'region' => null,
'version' => '2010-03-31',
'endpoint' => null,
'topic_arns' => [],
'http' => [],
], 'config', $factory);
}
public function testCouldBeConstructedWithCustomConfiguration()
{
$factory = new SnsConnectionFactory(['key' => 'theKey']);
$this->assertAttributeEquals([
'lazy' => true,
'key' => 'theKey',
'secret' => null,
'token' => null,
'region' => null,
'version' => '2010-03-31',
'endpoint' => null,
'topic_arns' => [],
'http' => [],
], 'config', $factory);
}
public function testCouldBeConstructedWithClient()
{
$awsClient = $this->createMock(AwsSnsClient::class);
$factory = new SnsConnectionFactory($awsClient);
$context = $factory->createContext();
$this->assertInstanceOf(SnsContext::class, $context);
$client = $this->readAttribute($context, 'client');
$this->assertInstanceOf(SnsClient::class, $client);
$this->assertAttributeSame($awsClient, 'inputClient', $client);
}
public function testShouldCreateLazyContext()
{
$factory = new SnsConnectionFactory(['lazy' => true]);
$context = $factory->createContext();
$this->assertInstanceOf(SnsContext::class, $context);
$client = $this->readAttribute($context, 'client');
$this->assertInstanceOf(SnsClient::class, $client);
$this->assertAttributeInstanceOf(\Closure::class, 'inputClient', $client);
}
}