1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of graze/queue. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @license https://github.com/graze/queue/blob/master/LICENSE MIT |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/graze/queue |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Graze\Queue\Adapter\Exception; |
17
|
|
|
|
18
|
|
|
use Exception; |
19
|
|
|
use Graze\Queue\Adapter\AdapterInterface; |
20
|
|
|
use Graze\Queue\Adapter\NamedInterface; |
21
|
|
|
use Graze\Queue\Message\MessageInterface; |
22
|
|
|
use Graze\Queue\Test\TestCase; |
23
|
|
|
use Mockery as m; |
24
|
|
|
use Mockery\MockInterface; |
25
|
|
|
|
26
|
|
|
class AdapterExceptionTest extends TestCase |
27
|
|
|
{ |
28
|
|
|
/** @var string */ |
29
|
|
|
private $queueName; |
30
|
|
|
/** @var array */ |
31
|
|
|
private $debug; |
32
|
|
|
/** @var AdapterInterface|NamedInterface|MockInterface */ |
33
|
|
|
private $adapter; |
34
|
|
|
/** @var MessageInterface[]|MockInterface[] */ |
35
|
|
|
private $messages; |
36
|
|
|
/** @var Exception */ |
37
|
|
|
private $previous; |
38
|
|
|
/** @var AdapterException */ |
39
|
|
|
private $exception; |
40
|
|
|
|
41
|
|
|
public function setUp() |
42
|
|
|
{ |
43
|
|
|
$this->queueName = 'foobar'; |
44
|
|
|
$this->debug = ['foo' => 'bar']; |
45
|
|
|
|
46
|
|
|
$this->adapter = m::mock(AdapterInterface::class, NamedInterface::class); |
47
|
|
|
$this->adapter->shouldReceive('getQueueName')->andReturn($this->queueName); |
48
|
|
|
|
49
|
|
|
$a = m::mock('Graze\Queue\Message\MessageInterface'); |
50
|
|
|
$b = m::mock('Graze\Queue\Message\MessageInterface'); |
51
|
|
|
$c = m::mock('Graze\Queue\Message\MessageInterface'); |
52
|
|
|
$this->messages = [$a, $b, $c]; |
53
|
|
|
|
54
|
|
|
$this->previous = new Exception(); |
55
|
|
|
|
56
|
|
|
$this->exception = new AdapterException('foo', $this->adapter, $this->messages, $this->debug, $this->previous); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testInterface() |
60
|
|
|
{ |
61
|
|
|
assertThat($this->exception, is(anInstanceOf('RuntimeException'))); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testGetAdapter() |
65
|
|
|
{ |
66
|
|
|
assertThat($this->exception->getAdapter(), is(identicalTo($this->adapter))); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testGetDebug() |
70
|
|
|
{ |
71
|
|
|
assertThat($this->exception->getDebug(), is(identicalTo($this->debug))); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testGetMessages() |
75
|
|
|
{ |
76
|
|
|
assertThat($this->exception->getMessages(), is(identicalTo($this->messages))); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testGetPrevious() |
80
|
|
|
{ |
81
|
|
|
assertThat($this->exception->getPrevious(), is(identicalTo($this->previous))); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function testGetQueueName() |
85
|
|
|
{ |
86
|
|
|
assertThat($this->exception->getQueueName(), is(identicalTo($this->queueName))); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|