-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMySQLTest.php
52 lines (41 loc) · 1.26 KB
/
MySQLTest.php
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
<?php
namespace Corley\Queue\MySQL;
use PDO;
use Corley\Queue\MySQL\MySQL;
class MySQLTest extends \PHPUnit_Framework_TestCase
{
private $pdo;
public function setUp()
{
$this->pdo = new PDO("mysql:dbname=test;host=127.0.0.1", "root", "root");
$this->pdo->query("DELETE FROM messages");
}
public function testSendMessage()
{
$adapter = new MySQL($this->pdo);
$adapter->send("testqueue", "test", []);
}
/**
* @expectedException RuntimeException
*/
public function testNotifyMissingQueue()
{
$adapter = new MySQL($this->pdo);
$adapter->send("not exists", "test", []);
}
public function testReceiveMessage()
{
$adapter = new MySQL($this->pdo);
$adapter->send("testqueue", "test", ['delay' => 0]);
list($receipt, $message) = $adapter->receive("testqueue", []);
$this->assertNotFalse($receipt);
$this->assertNotFalse($message);
}
public function testDeleteMessage()
{
$adapter = new MySQL($this->pdo);
$adapter->send("testqueue", "test", ['delay' => 0]);
list($receipt, $message) = $adapter->receive("testqueue", []);
$this->assertSame(1, $adapter->delete("testqueue", $receipt, []));
}
}