Passed
Push — master ( 0fcf12...d4ce0d )
by Gabriel
03:26
created

TopicTraitTest::test_fireEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 9.9332
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ByTIC\Notifier\Tests\Models\Topics;
4
5
use ByTIC\Notifier\Tests\AbstractTest;
6
use ByTIC\Notifier\Tests\Fixtures\Models\Events\Event;
7
use ByTIC\Notifier\Tests\Fixtures\Models\Events\Events;
8
use ByTIC\Notifier\Tests\Fixtures\Models\Topics\Topic;
9
use Nip\Records\Locator\ModelLocator;
10
use Nip\Records\Record;
11
12
/**
13
 * Class TopicTraitTest
14
 * @package ByTIC\Notifier\Tests\Models\Topics
15
 */
16
class TopicTraitTest extends AbstractTest
17
{
18
    public function test_fireEvent()
19
    {
20
        $eventMock = \Mockery::mock(Event::class)->shouldAllowMockingProtectedMethods()->makePartial();
21
        $eventsMock = \Mockery::mock(Events::class)->shouldAllowMockingProtectedMethods()->makePartial();
22
23
        $eventMock->shouldReceive('getManager')->andReturn($eventsMock);
24
        $eventMock->shouldReceive('save')->once();
25
        $eventsMock->shouldReceive('getNew')->andReturn($eventMock);
26
27
        ModelLocator::set('Notifications\Events', $eventsMock);
0 ignored issues
show
Bug introduced by
$eventsMock of type Mockery\Mock is incompatible with the type Nip\Records\AbstractModels\RecordManager expected by parameter $entityManager of Nip\Records\Locator\ModelLocator::set(). ( Ignorable by Annotation )

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

27
        ModelLocator::set('Notifications\Events', /** @scrutinizer ignore-type */ $eventsMock);
Loading history...
28
29
        $model = new Record();
30
31
        $topic = new Topic();
32
        $event = $topic->fireEvent($model);
33
34
        self::assertSame('pending', $event->getAttribute('status'));
0 ignored issues
show
Bug introduced by
It seems like getAttribute() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

34
        self::assertSame('pending', $event->/** @scrutinizer ignore-call */ getAttribute('status'));
Loading history...
35
    }
36
}