forked from CoderKungfu/php-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazonSQSV2Test.php
More file actions
67 lines (61 loc) · 1.83 KB
/
Copy pathAmazonSQSV2Test.php
File metadata and controls
67 lines (61 loc) · 1.83 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
<?php
namespace PHPQueue\Backend;
class AmazonSQSV2Test extends \PHPUnit_Framework_TestCase
{
private $object;
public function setUp()
{
parent::setUp();
if (!class_exists('\Aws\Sqs\SqsClient')) {
$this->markTestSkipped('Amazon PHP SDK 2 not installed');
} else {
$options = array(
'region' => 'ap-southeast-1',
'queue' => 'https://sqs.ap-southeast-1.amazonaws.com/524787626913/testqueue',
'sqs_options' => array(
'key' => 'your_sqs_key',
'secret' => 'your_sqs_secret'
),
'receiving_options' => array(
'VisibilityTimeout' => 0
)
);
$this->object = new AmazonSQS();
$this->object->setBackend(new Aws\AmazonSQSV2($options));
}
}
public function testAdd()
{
$data = array('1','Willy','Wonka');
$result = $this->object->add($data);
$this->assertTrue($result);
}
/**
* @depends testAdd
*/
public function testGet()
{
$result = $this->object->get();
$this->assertNotEmpty($result);
$this->assertEquals(array('1','Willy','Wonka'), $result);
$this->object->release($this->object->last_job_id);
}
/**
* @depends testAdd
*/
public function testClear()
{
try {
$jobId = 'xxx';
$this->object->clear($jobId);
$this->fail("Should not be able to delete.");
} catch (\Exception $ex) {
$this->assertTrue(true);
}
$result = $this->object->get();
$this->assertNotEmpty($result);
$jobId = $this->object->last_job_id;
$result = $this->object->clear($jobId);
$this->assertTrue($result);
}
}