Passed
Push — master ( 645444...70cdd5 )
by
unknown
05:22 queued 10s
created

FortySixElksChannelTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace NotificationChannels\FortySixElks\Test;
4
5
use Mockery;
6
7
use Illuminate\Events\Dispatcher;
8
use Illuminate\Notifications\Notifiable;
9
use Illuminate\Notifications\Notification;
10
11
use NotificationChannels\FortySixElks\FortySixElksChannel;
12
use NotificationChannels\FortySixElks\FortySixElksSMS;
13
14
class FortySixElksChannelTest extends \PHPUnit_Framework_TestCase
15
{
16
    protected $dispatcher;
17
18
    protected $channel;
19
20
    protected $notifiable;
21
22
    protected $notification;
23
24
    protected $smsMessage;
25
26
    public function setUp()
27
    {
28
        parent::setUp();
29
        $this->dispatcher = new \Illuminate\Events\Dispatcher();
30
31
        $this->channel = new FortySixElksChannel($this->dispatcher);
32
33
		$this->smsMessage = Mockery::mock(FortySixElksSMS::class);
34
35
        $this->notifiable = new TestNotifiable();
36
37
        $this->notification = new TestNotification($this->smsMessage);
38
    }
39
40
    public function testItCanBeInstantiatedTest()
41
    {
42
        $this->assertInstanceOf(FortySixElksChannel::class, $this->channel);
43
    }
44
45
    public function testCanSendNotification(){
46
47
48
49
		$this->smsMessage->shouldReceive('send')
50
			->once()
51
			->andReturn($this->smsMessage);
52
53
	    $this->notification->to46Elks($this->notifiable);
54
		$response = $this->channel->send($this->notifiable, $this->notification);
55
56
		$this->assertInstanceOf(FortySixElksSMS::class, $response);
57
58
59
    }
60
}
61
62
class TestNotifiable
63
{
64
	use Notifiable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by NotificationChannels\For...lks\Test\TestNotifiable.
Loading history...
65
}
66
67
class TestNotification extends Notification
68
{
69
70
	public function __construct($message) {
71
		$this->message =  $message;
0 ignored issues
show
Bug Best Practice introduced by
The property message does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
72
	}
73
74
	public function to46Elks($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
	public function to46Elks(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
	{
76
		return $this->message;
77
	}
78
}
79