Completed
Push — master ( 9abbc7...a687e5 )
by Fabrizio
03:03
created

SendOneSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace spec\Fenos\Notifynder\Senders;
4
5
use Fenos\Notifynder\Contracts\StoreNotification;
6
use Fenos\Notifynder\Exceptions\CategoryNotFoundException;
7
use Fenos\Notifynder\Models\Notification;
8
use PhpSpec\ObjectBehavior;
9
10
class SendOneSpec extends ObjectBehavior
11
{
12
    public function let()
13
    {
14
        $infoNotification = [];
15
        $this->beConstructedWith($infoNotification);
16
    }
17
18
    public function it_is_initializable()
19
    {
20
        $this->shouldHaveType('Fenos\Notifynder\Senders\SendOne');
21
    }
22
23
    /** @test */
24
    public function it_send_a_single_notification_having_the_category_(StoreNotification $storeNotification)
25
    {
26
        $infoNotification = [
27
            'category_id' => 1,
28
        ];
29
30
        $this->beConstructedWith($infoNotification);
31
32
        $storeNotification->storeSingle($infoNotification)->shouldBeCalled()
33
                ->willReturn(new Notification());
34
35
        $this->send($storeNotification)->shouldReturnAnInstanceOf(Notification::class);
36
    }
37
38
    /** @test */
39
    public function it_try_to_send_a_notification_without_category_id(StoreNotification $storeNotification)
40
    {
41
        // throw exception because I didn't specified a category_id
42
        $this->shouldThrow(CategoryNotFoundException::class)
43
             ->during('send', [$storeNotification]);
44
    }
45
}
46