NotificationFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 12
c 0
b 0
f 0
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateNotificationNameData() 0 8 1
A testGenerateNotificationName() 0 4 1
A testCreateWithOneParam() 0 8 1
1
<?php
2
3
namespace ByTIC\Notifier\Tests\Notifications;
4
5
use ByTIC\Notifications\Notification;
6
use ByTIC\Notifier\Notifications\NotificationFactory;
7
use ByTIC\Notifier\Tests\AbstractTest;
8
use ByTIC\Notifier\Tests\Fixtures\Library\Application;
9
10
/**
11
 * Class NotificationFactoryTest
12
 * @package ByTIC\Notifier\Tests\Notifications
13
 */
14
class NotificationFactoryTest extends AbstractTest
15
{
16
17
    public function testCreateWithOneParam()
18
    {
19
        app()->set('app', new Application());
0 ignored issues
show
Bug introduced by
The method set() does not exist on Psr\Container\ContainerInterface. It seems like you code against a sub-type of Psr\Container\ContainerInterface such as Symfony\Component\Depend...tion\ContainerInterface or Nip\Container\ContainerInterface or Symfony\Component\Depend...rameterBag\ContainerBag or Nip\Container\Bridges\LeagueContainer or Nip\Container\Bridges\LaravelContainer. ( Ignorable by Annotation )

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

19
        app()->/** @scrutinizer ignore-call */ set('app', new Application());
Loading history...
20
21
        $notification = NotificationFactory::create('fundraising-page', 'pending', 'org_supporters', ['789']);
22
23
        self::assertInstanceOf(Notification::class, $notification);
24
        self::assertSame($notification->param, '789');
25
    }
26
27
    /**
28
     * @param $class
29
     * @param $recipient
30
     * @param $target
31
     * @param $trigger
32
     * @dataProvider generateNotificationNameData
33
     */
34
    public function testGenerateNotificationName($class, $target, $trigger, $recipient)
35
    {
36
        app()->set('app', new Application());
37
        self::assertSame($class, NotificationFactory::generateNotificationName($target, $trigger, $recipient));
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function generateNotificationNameData()
44
    {
45
        return [
46
            [
47
                'ByTIC\Notifier\Tests\Fixtures\Notifications\Fundraising_Pages\Pending\OrgSupportersNotification',
48
                'fundraising-page',
49
                'pending',
50
                'org_supporters'
51
            ],
52
        ];
53
    }
54
}
55