Completed
Push — master ( efcd9d...99efad )
by PHPLicengine
08:21 queued 02:36
created

GroupTest::testGetGroups()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.9666
1
<?php
2
3
// GroupTest.php
4
#################################################
5
##
6
## PHPLicengine
7
##
8
#################################################
9
## Copyright 2009-{current_year} PHPLicengine
10
## 
11
## Licensed under the Apache License, Version 2.0 (the "License");
12
## you may not use this file except in compliance with the License.
13
## You may obtain a copy of the License at
14
##
15
##    http://www.apache.org/licenses/LICENSE-2.0
16
##
17
## Unless required by applicable law or agreed to in writing, software
18
## distributed under the License is distributed on an "AS IS" BASIS,
19
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
## See the License for the specific language governing permissions and
21
## limitations under the License.
22
#################################################
23
24
use PHPLicengine\Api\ApiInterface;
25
use PHPLicengine\Service\Group;
26
use PHPUnit\Framework\TestCase;
27
28
class GroupTest extends TestCase
29
{
30
31
    public function testGetGroupTags()
32
    {
33
        $mock = $this->createMock(ApiInterface::class);
34
        $mock
35
            ->expects($this->once())
36
            ->method('get')
37
            ->with(
38
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/tags')                    
39
                    );
40
        $bitlink = new Group($mock);
41
        $bitlink->getGroupTags('test');
42
    } 
43
    
44
    public function testGetGroupMetricsByReferringNetworks()
45
    {
46
        $mock = $this->createMock(ApiInterface::class);
47
        $mock
48
            ->expects($this->once())
49
            ->method('get')
50
            ->with(
51
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/referring_networks')                    
52
                    );
53
        $bitlink = new Group($mock);
54
        $bitlink->getGroupMetricsByReferringNetworks('test');
55
    }     
56
    
57
    public function testGetGroupShortenCounts()
58
    {
59
        $mock = $this->createMock(ApiInterface::class);
60
        $mock
61
            ->expects($this->once())
62
            ->method('get')
63
            ->with(
64
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/shorten_counts')                    
65
                    );
66
        $bitlink = new Group($mock);
67
        $bitlink->getGroupShortenCounts('test');
68
    }         
69
70
    public function testGetGroups()
71
    {
72
        $mock = $this->createMock(ApiInterface::class);
73
        $mock
74
            ->expects($this->once())
75
            ->method('get')
76
            ->with(
77
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups'),
78
                    $this->identicalTo(['key' => 'value'])
79
                    );
80
        $bitlink = new Group($mock);
81
        $bitlink->getGroups(['key' => 'value']);
82
    }         
83
84
    public function testGetGroupPreferences()
85
    {
86
        $mock = $this->createMock(ApiInterface::class);
87
        $mock
88
            ->expects($this->once())
89
            ->method('get')
90
            ->with(
91
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/preferences')
92
                    );
93
        $bitlink = new Group($mock);
94
        $bitlink->getGroupPreferences('test');
95
    }         
96
97
    public function testUpdateGroupPreferences()
98
    {
99
        $mock = $this->createMock(ApiInterface::class);
100
        $mock
101
            ->expects($this->once())
102
            ->method('patch')
103
            ->with(
104
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/preferences'),
105
                    $this->identicalTo(['key' => 'value'])
106
                    );
107
        $bitlink = new Group($mock);
108
        $bitlink->updateGroupPreferences('test', ['key' => 'value']);
109
    }        
110
111
    public function testGetBitlinksByGroup()
112
    {
113
        $mock = $this->createMock(ApiInterface::class);
114
        $mock
115
            ->expects($this->once())
116
            ->method('get')
117
            ->with(
118
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/bitlinks'),
119
                    $this->identicalTo(['key' => 'value'])
120
                    );
121
        $bitlink = new Group($mock);
122
        $bitlink->getBitlinksByGroup('test', ['key' => 'value']);
123
    }         
124
125
    public function testGetGroupMetricsByCountries()
126
    {
127
        $mock = $this->createMock(ApiInterface::class);
128
        $mock
129
            ->expects($this->once())
130
            ->method('get')
131
            ->with(
132
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/bitlinks')
133
                    );
134
        $bitlink = new Group($mock);
135
        $bitlink->getBitlinksByGroup('test');
136
    }         
137
138
    public function testGetSortedBitlinks()
139
    {
140
        $mock = $this->createMock(ApiInterface::class);
141
        $mock
142
            ->expects($this->once())
143
            ->method('get')
144
            ->with(
145
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test/bitlinks/clicks'),
146
                    $this->identicalTo(['key' => 'value'])
147
                    );
148
        $bitlink = new Group($mock);
149
        $bitlink->getSortedBitlinks('test', ['key' => 'value']);
150
    }         
151
152
    public function testUpdateGroup()
153
    {
154
        $mock = $this->createMock(ApiInterface::class);
155
        $mock
156
            ->expects($this->once())
157
            ->method('patch')
158
            ->with(
159
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test'),
160
                    $this->identicalTo(['key' => 'value'])
161
                    );
162
        $bitlink = new Group($mock);
163
        $bitlink->updateGroup('test', ['key' => 'value']);
164
    }        
165
166
    public function testGetGroup()
167
    {
168
        $mock = $this->createMock(ApiInterface::class);
169
        $mock
170
            ->expects($this->once())
171
            ->method('get')
172
            ->with(
173
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test')
174
                    );
175
        $bitlink = new Group($mock);
176
        $bitlink->getGroup('test');
177
    }         
178
179
    public function testDeleteGroup()
180
    {
181
        $mock = $this->createMock(ApiInterface::class);
182
        $mock
183
            ->expects($this->once())
184
            ->method('delete')
185
            ->with(
186
                    $this->equalTo('https://api-ssl.bitly.com/v4/groups/test')
187
                    );
188
        $bitlink = new Group($mock);
189
        $bitlink->deleteGroup('test');
190
    }         
191
192
}
193