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.

HostTest::testHostWithUserFromConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
nc 1
nop 0
dl 0
loc 15
c 0
b 0
f 0
cc 1
rs 9.9332
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\Host;
9
10
use Deployer\Configuration;
11
use PHPUnit\Framework\TestCase;
12
13
class HostTest extends TestCase
14
{
15
    public function testHost()
16
    {
17
        $host = new Host('host');
18
        $host
19
            ->setHostname('hostname')
20
            ->setRemoteUser('remote_user')
21
            ->setPort(22)
22
            ->setConfigFile('~/.ssh/config')
23
            ->setIdentityFile('~/.ssh/id_rsa')
24
            ->setForwardAgent(true)
25
            ->setSshMultiplexing(true);
26
27
        self::assertEquals('host', $host->getAlias());
28
        self::assertStringContainsString('host', $host->getTag());
0 ignored issues
show
Bug introduced by
It seems like $host->getTag() can also be of type null; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

28
        self::assertStringContainsString('host', /** @scrutinizer ignore-type */ $host->getTag());
Loading history...
29
        self::assertEquals('hostname', $host->getHostname());
30
        self::assertEquals('remote_user', $host->getRemoteUser());
31
        self::assertEquals(22, $host->getPort());
32
        self::assertEquals('~/.ssh/config', $host->getConfigFile());
33
        self::assertEquals('~/.ssh/id_rsa', $host->getIdentityFile());
34
        self::assertEquals(true, $host->getForwardAgent());
35
        self::assertEquals(true, $host->getSshMultiplexing());
36
    }
37
38
    public function testConfigurationAccessor()
39
    {
40
        $host = new Host('host');
41
        $host
42
            ->set('roles', ['db', 'app'])
43
            ->set('key', 'value')
44
            ->set('array', [1])
45
            ->add('array', [2]);
46
47
        self::assertEquals(['db', 'app'], $host->get('roles'));
48
        self::assertEquals('value', $host->get('key'));
49
        self::assertEquals([1, 2], $host->get('array'));
50
    }
51
52
    public function testHostAlias()
53
    {
54
        $host = new Host('host/alias');
55
        self::assertEquals('host/alias', $host->getAlias());
56
        self::assertEquals('host', $host->getHostname());
57
    }
58
59
    public function testHostWithParams()
60
    {
61
        $host = new Host('host');
62
        $value = 'new_value';
63
        $host
64
            ->set('env', $value)
65
            ->set('identity_file', '{{env}}');
66
67
        self::assertEquals($value, $host->getIdentityFile());
68
    }
69
70
    public function testHostWithUserFromConfig()
71
    {
72
        $parent = new Configuration();
73
        $parent->set("deploy_user", function () {
74
            return "test_user";
75
        });
76
77
        $host = new Host('host');
78
        $host->config()->bind($parent);
79
        $host
80
            ->setHostname('host')
81
            ->setRemoteUser('{{deploy_user}}')
82
            ->setPort(22);
83
84
        self::assertEquals('test_user@host', $host->connectionString());
85
    }
86
}
87