-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathResultTest.php
91 lines (70 loc) · 2.96 KB
/
ResultTest.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
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
86
87
88
89
90
91
<?php
namespace Enqueue\Tests\Consumption;
use Enqueue\Consumption\Result;
use Enqueue\NoEffect\NullMessage;
use PHPUnit\Framework\TestCase;
class ResultTest extends TestCase
{
public function testCouldBeConstructedWithExpectedArguments()
{
$result = new Result('theStatus');
$this->assertSame('theStatus', $result->getStatus());
$this->assertSame('', $result->getReason());
$this->assertNull($result->getReply());
$result = new Result('theStatus', 'theReason');
$this->assertSame('theStatus', $result->getStatus());
$this->assertSame('theReason', $result->getReason());
$this->assertNull($result->getReply());
}
public function testCouldConstructedWithAckFactoryMethod()
{
$result = Result::ack('theReason');
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::ACK, $result->getStatus());
$this->assertSame('theReason', $result->getReason());
$this->assertNull($result->getReply());
}
public function testCouldConstructedWithRejectFactoryMethod()
{
$result = Result::reject('theReason');
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::REJECT, $result->getStatus());
$this->assertSame('theReason', $result->getReason());
$this->assertNull($result->getReply());
}
public function testCouldConstructedWithRequeueFactoryMethod()
{
$result = Result::requeue('theReason');
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::REQUEUE, $result->getStatus());
$this->assertSame('theReason', $result->getReason());
$this->assertNull($result->getReply());
}
public function testCouldConstructedWithReplyFactoryMethodAndAckStatusByDefault()
{
$reply = new NullMessage();
$result = Result::reply($reply);
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::ACK, $result->getStatus());
$this->assertSame('', $result->getReason());
$this->assertSame($reply, $result->getReply());
}
public function testCouldConstructedWithReplyFactoryMethodAndRejectStatusExplicitly()
{
$reply = new NullMessage();
$result = Result::reply($reply, Result::REJECT);
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::REJECT, $result->getStatus());
$this->assertSame('', $result->getReason());
$this->assertSame($reply, $result->getReply());
}
public function testCouldConstructedWithReplyFactoryMethodAndReasonSet()
{
$reply = new NullMessage();
$result = Result::reply($reply, null, 'theReason');
$this->assertInstanceOf(Result::class, $result);
$this->assertSame(Result::ACK, $result->getStatus());
$this->assertSame('theReason', $result->getReason());
$this->assertSame($reply, $result->getReply());
}
}