-
Notifications
You must be signed in to change notification settings - Fork 31
/
PushoverMessageTest.php
193 lines (146 loc) · 5.01 KB
/
PushoverMessageTest.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
namespace NotificationChannels\Pushover\Test;
use Carbon\Carbon;
use NotificationChannels\Pushover\Exceptions\EmergencyNotificationRequiresRetryAndExpire;
use NotificationChannels\Pushover\PushoverMessage;
use Orchestra\Testbench\TestCase;
class PushoverMessageTest extends TestCase
{
/** @var PushoverMessage */
protected $message;
public function setUp(): void
{
parent::setUp();
$this->message = new PushoverMessage();
}
/** @test */
public function it_can_accept_a_message_when_constructing_a_message(): void
{
$message = new PushoverMessage('message text');
$this->assertEquals('message text', $message->content);
}
/** @test */
public function it_can_create_a_message(): void
{
$message = PushoverMessage::create();
$this->assertInstanceOf(PushoverMessage::class, $message);
}
/** @test */
public function it_can_accept_a_message_when_creating_a_message(): void
{
$message = PushoverMessage::create('message text');
$this->assertEquals('message text', $message->content);
}
/** @test */
public function it_can_set_content(): void
{
$this->message->content('message text');
$this->assertEquals('message text', $this->message->content);
}
/** @test */
public function it_can_set_the_message_format_to_plain(): void
{
$this->message->plain();
$this->assertEquals(PushoverMessage::FORMAT_PLAIN, $this->message->format);
}
/** @test */
public function it_can_set_the_message_format_to_html(): void
{
$this->message->html();
$this->assertEquals(PushoverMessage::FORMAT_HTML, $this->message->format);
}
/** @test */
public function it_can_set_the_message_format_to_monospace(): void
{
$this->message->monospace();
$this->assertEquals(PushoverMessage::FORMAT_MONOSPACE, $this->message->format);
}
/** @test */
public function it_can_set_a_title(): void
{
$this->message->title('message title');
$this->assertEquals('message title', $this->message->title);
}
/** @test */
public function it_can_set_a_time(): void
{
$this->message->time(123456789);
$this->assertEquals(123456789, $this->message->timestamp);
}
/** @test */
public function it_can_set_a_time_from_a_carbon_object(): void
{
$carbon = Carbon::now();
$this->message->time($carbon);
$this->assertEquals($carbon->timestamp, $this->message->timestamp);
}
/** @test */
public function it_can_set_an_url(): void
{
$this->message->url('http://example.com');
$this->assertEquals('http://example.com', $this->message->url);
}
/** @test */
public function it_can_set_an_url_with_a_title(): void
{
$this->message->url('http://example.com', 'Go to example website');
$this->assertEquals('http://example.com', $this->message->url);
$this->assertEquals('Go to example website', $this->message->urlTitle);
}
/** @test */
public function it_can_set_a_sound(): void
{
$this->message->sound('boing');
$this->assertEquals('boing', $this->message->sound);
}
/** @test */
public function it_can_set_a_priority(): void
{
$this->message->priority(PushoverMessage::NORMAL_PRIORITY);
$this->assertEquals(0, $this->message->priority);
}
/** @test */
public function it_can_set_a_priority_with_retry_and_expire(): void
{
$this->message->priority(PushoverMessage::EMERGENCY_PRIORITY, 60, 600);
$this->assertEquals(2, $this->message->priority);
$this->assertEquals(60, $this->message->retry);
$this->assertEquals(600, $this->message->expire);
}
/** @test */
public function it_cannot_set_priority_to_emergency_when_not_providing_a_retry_and_expiry_time(): void
{
$this->expectException(EmergencyNotificationRequiresRetryAndExpire::class);
$this->message->priority(PushoverMessage::EMERGENCY_PRIORITY);
}
/** @test */
public function it_can_set_the_priority_to_the_lowest(): void
{
$this->message->lowestPriority();
$this->assertEquals(-2, $this->message->priority);
}
/** @test */
public function it_can_set_the_priority_to_low(): void
{
$this->message->lowPriority();
$this->assertEquals(-1, $this->message->priority);
}
/** @test */
public function it_can_set_the_priority_to_normal(): void
{
$this->message->normalPriority();
$this->assertEquals(0, $this->message->priority);
}
/** @test */
public function it_can_set_the_priority_to_high(): void
{
$this->message->highPriority();
$this->assertEquals(1, $this->message->priority);
}
/** @test */
public function it_can_set_the_priority_to_emergency(): void
{
$this->message->emergencyPriority(60, 600);
$this->assertEquals(2, $this->message->priority);
}
}