-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathSlackTest.php
More file actions
53 lines (42 loc) · 1.25 KB
/
SlackTest.php
File metadata and controls
53 lines (42 loc) · 1.25 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
<?php
namespace Codecasts\Support\Notifications;
use Maknz\Slack\Client as SlackClient;
use Mockery as m;
/**
* Class SlackTest.
*/
class SlackTest extends \TestCase
{
public function test_send_notifications()
{
$slackClient = m::mock(SlackClient::class)
->shouldReceive('send')
->with('foo')
->getMock();
$this->app->instance('maknz.slack', $slackClient);
$slack = new Slack();
$slack->notify('foo');
}
public function test_send_notifications_with_attached_fields()
{
$clientAttachMock = m::mock(SlackClient::class)
->shouldReceive('send')
->once()
->with('foo')->getMock();
$slackClient = m::mock(SlackClient::class)
->shouldReceive('attach')
->with(['fields' => [
['title' => 'field1', 'value' => 'value1'],
['title' => 'field2', 'value' => 'value2'],
]])
->once()
->andReturn($clientAttachMock)
->getMock();
$this->app->instance('maknz.slack', $slackClient);
$slack = new Slack();
$slack->notify('foo', [
'field1' => 'value1',
'field2' => 'value2',
]);
}
}