Issues (14)

tests/ConfigTest.php (2 issues)

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: james
5
 * Date: 18/07/2018
6
 * Time: 12:49
7
 */
8
9
namespace CwsOps\LivePerson\Tests;
10
11
use CwsOps\LivePerson\Account\Config;
12
13
use PHPUnit\Framework\TestCase;
14
15
/**
16
 * @codeCoverageIgnore
17
 * Class ConfigTest
18
 * @package CwsOps\LivePerson\Tests
19
 */
20
class ConfigTest extends TestCase
21
{
22
23
    /**
24
     * @covers \CwsOps\LivePerson\Account\Config::__construct
25
     */
26
    public function testCanConstruct()
27
    {
28
        $accountId = 'foo';
29
        $consumerKey = 'bar';
30
        $consumerSecret = 'biz';
31
        $token = 'baz';
32
        $tokenSecret = 'bee';
33
        $username = 'noo';
34
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
35
36
        $this->assertInstanceOf(Config::class, $config);
37
    }
38
39
    /**
40
     * @covers \CwsOps\LivePerson\Account\Config::__construct
41
     */
42
    public function testCantConstructWithoutDefaultArgs()
43
    {
44
        $this->expectException(\ArgumentCountError::class);
45
46
        $config = new Config('foo', 'bar');
0 ignored issues
show
The assignment to $config is dead and can be removed.
Loading history...
The call to CwsOps\LivePerson\Account\Config::__construct() has too few arguments starting with consumerSecret. ( Ignorable by Annotation )

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

46
        $config = /** @scrutinizer ignore-call */ new Config('foo', 'bar');

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
47
    }
48
49
    /**
50
     * @covers \CwsOps\LivePerson\Account\Config::getUsername()
51
     */
52
    public function testGetUsername()
53
    {
54
        $accountId = 'foo';
55
        $consumerKey = 'bar';
56
        $consumerSecret = 'biz';
57
        $token = 'baz';
58
        $tokenSecret = 'bee';
59
        $username = 'noo';
60
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
61
62
63
        $this->assertInstanceOf(Config::class, $config);
64
65
        $this->assertEquals($username, $config->getUsername());
66
    }
67
68
    /**
69
     * @covers \CwsOps\LivePerson\Account\Config::getConsumerKey()
70
     */
71
    public function testGetConsumerKey()
72
    {
73
        $accountId = 'foo';
74
        $consumerKey = 'bar';
75
        $consumerSecret = 'biz';
76
        $token = 'baz';
77
        $tokenSecret = 'bee';
78
        $username = 'noo';
79
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
80
81
        $this->assertInstanceOf(Config::class, $config);
82
83
        $this->assertEquals($consumerKey, $config->getConsumerKey());
84
    }
85
86
    /**
87
     * @covers \CwsOps\LivePerson\Account\Config::getAccountId()
88
     */
89
    public function testGetAccountId()
90
    {
91
        $accountId = 'foo';
92
        $consumerKey = 'bar';
93
        $consumerSecret = 'biz';
94
        $token = 'baz';
95
        $tokenSecret = 'bee';
96
        $username = 'noo';
97
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
98
99
        $this->assertInstanceOf(Config::class, $config);
100
101
        $this->assertEquals($accountId, $config->getAccountId());
102
    }
103
104
    /**
105
     * @covers \CwsOps\LivePerson\Account\Config::getTokenSecret()
106
     */
107
    public function testGetTokenSecret()
108
    {
109
        $accountId = 'foo';
110
        $consumerKey = 'bar';
111
        $consumerSecret = 'biz';
112
        $token = 'baz';
113
        $tokenSecret = 'bee';
114
        $username = 'noo';
115
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
116
        $this->assertInstanceOf(Config::class, $config);
117
118
        $this->assertEquals($tokenSecret, $config->getTokenSecret());
119
    }
120
121
    /**
122
     * @covers \CwsOps\LivePerson\Account\Config::getConsumerSecret()
123
     */
124
    public function testGetConsumerSecret()
125
    {
126
        $accountId = 'foo';
127
        $consumerKey = 'bar';
128
        $consumerSecret = 'biz';
129
        $token = 'baz';
130
        $tokenSecret = 'bee';
131
        $username = 'noo';
132
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
133
134
        $this->assertInstanceOf(Config::class, $config);
135
136
        $this->assertEquals($consumerSecret, $config->getConsumerSecret());
137
    }
138
139
    /**
140
     * @covers \CwsOps\LivePerson\Account\Config::getToken()
141
     */
142
    public function testGetToken()
143
    {
144
        $accountId = 'foo';
145
        $consumerKey = 'bar';
146
        $consumerSecret = 'biz';
147
        $token = 'baz';
148
        $tokenSecret = 'bee';
149
        $username = 'noo';
150
        $config = new Config($accountId, $consumerKey, $consumerSecret, $token, $tokenSecret, $username);
151
152
        $this->assertInstanceOf(Config::class, $config);
153
154
        $this->assertEquals($token, $config->getToken());
155
    }
156
}
157