GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

testThrowsExceptionIfTaskDontExists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
nc 1
nop 0
dl 0
loc 9
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Task;
9
10
use PHPUnit\Framework\TestCase;
11
12
class ScriptManagerTest extends TestCase
13
{
14
    public function testGetTasks()
15
    {
16
        $notify = new Task('notify');
17
        $info = new GroupTask('info', ['notify']);
18
        $deploy = new GroupTask('deploy', ['deploy:setup', 'deploy:release']);
19
        $deploy->addBefore($info);
20
        $setup = new Task('deploy:setup');
21
        $release = new Task('deploy:release');
22
23
        $taskCollection = new TaskCollection();
24
        $taskCollection->set($notify->getName(), $notify);
25
        $taskCollection->set($info->getName(), $info);
26
        $taskCollection->set($deploy->getName(), $deploy);
27
        $taskCollection->set($setup->getName(), $setup);
28
        $taskCollection->set($release->getName(), $release);
29
30
        $scriptManager = new ScriptManager($taskCollection);
31
        self::assertEquals([$notify, $setup, $release], $scriptManager->getTasks('deploy'));
32
    }
33
34
    public function testOnce()
35
    {
36
        $a = new Task('a');
37
        $b = new Task('b');
38
        $b->once();
39
        $group = new GroupTask('group', ['a', 'b']);
40
41
        $taskCollection = new TaskCollection();
42
        $taskCollection->add($a);
43
        $taskCollection->add($b);
44
        $taskCollection->add($group);
45
46
        $scriptManager = new ScriptManager($taskCollection);
47
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
48
        self::assertFalse($a->isOnce());
49
        self::assertTrue($b->isOnce());
50
51
        $group->once();
52
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
53
        self::assertTrue($a->isOnce());
54
        self::assertTrue($b->isOnce());
55
    }
56
57
    public function testSelectsCombine()
58
    {
59
        $a = new Task('a');
60
        $b = new Task('b');
61
        $c = new Task('c');
62
        $b->select('stage=beta');
63
        $c->select('stage=alpha|beta & role=db');
64
        $group = new GroupTask('group', ['a', 'b', 'c']);
65
66
        $taskCollection = new TaskCollection();
67
        $taskCollection->add($a);
68
        $taskCollection->add($b);
69
        $taskCollection->add($c);
70
        $taskCollection->add($group);
71
72
        $scriptManager = new ScriptManager($taskCollection);
73
        self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group'));
74
        self::assertNull($a->getSelector());
75
        self::assertEquals([[['=', 'stage', ['beta']]]], $b->getSelector());
76
        self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]]], $c->getSelector());
77
78
        $group->select('role=prod');
79
        self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group'));
80
        self::assertEquals([[['=', 'role', ['prod']]]], $a->getSelector());
81
        self::assertEquals([[['=', 'stage', ['beta']]],[['=', 'role', ['prod']]]], $b->getSelector());
82
        self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]],[['=', 'role', ['prod']]]], $c->getSelector());
83
    }
84
85
    public function testThrowsExceptionIfTaskCollectionEmpty()
86
    {
87
        self::expectException(\InvalidArgumentException::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

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

87
        self::/** @scrutinizer ignore-call */ 
88
              expectException(\InvalidArgumentException::class);
Loading history...
88
89
        $scriptManager = new ScriptManager(new TaskCollection());
90
        $scriptManager->getTasks('');
91
    }
92
93
    public function testThrowsExceptionIfTaskDontExists()
94
    {
95
        self::expectException(\InvalidArgumentException::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

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

95
        self::/** @scrutinizer ignore-call */ 
96
              expectException(\InvalidArgumentException::class);
Loading history...
96
97
        $taskCollection = new TaskCollection();
98
        $taskCollection->set('testTask', new Task('testTask'));
99
100
        $scriptManager = new ScriptManager($taskCollection);
101
        $scriptManager->getTasks('testTask2');
102
    }
103
}
104