TestNotification   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 10
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A to46Elks() 0 3 1
1
<?php
2
3
namespace NotificationChannels\FortySixElks\Test;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Notifications\Notification;
7
use Mockery;
8
use NotificationChannels\FortySixElks\FortySixElksChannel;
9
use NotificationChannels\FortySixElks\FortySixElksSMS;
10
11
class FortySixElksChannelTest extends \PHPUnit_Framework_TestCase
12
{
13
    protected $dispatcher;
14
15
    protected $channel;
16
17
    protected $notifiable;
18
19
    protected $notification;
20
21
    protected $smsMessage;
22
23
    public function setUp()
24
    {
25
        parent::setUp();
26
        $this->dispatcher = new \Illuminate\Events\Dispatcher();
27
28
        $this->channel = new FortySixElksChannel($this->dispatcher);
29
30
        $this->smsMessage = Mockery::mock(FortySixElksSMS::class);
31
32
        $this->notifiable = new TestNotifiable();
33
34
        $this->notification = new TestNotification($this->smsMessage);
35
    }
36
37
    public function testItCanBeInstantiatedTest()
38
    {
39
        $this->assertInstanceOf(FortySixElksChannel::class, $this->channel);
40
    }
41
42
    public function testCanSendNotification()
43
    {
44
        $this->smsMessage->shouldReceive('send')
45
            ->once()
46
            ->andReturn($this->smsMessage);
47
48
        $this->notification->to46Elks($this->notifiable);
49
        $response = $this->channel->send($this->notifiable, $this->notification);
50
51
        $this->assertInstanceOf(FortySixElksSMS::class, $response);
52
    }
53
}
54
55
class TestNotifiable
56
{
57
    use Notifiable;
0 ignored issues
show
introduced by
The trait Illuminate\Notifications\Notifiable requires some properties which are not provided by NotificationChannels\For...lks\Test\TestNotifiable: $email, $phone_number
Loading history...
58
}
59
60
class TestNotification extends Notification
61
{
62
    public function __construct($message)
63
    {
64
        $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...
65
    }
66
67
    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

67
    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...
68
    {
69
        return $this->message;
70
    }
71
}
72