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

CampaignTest::testCreateCampaign()   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
// CampaignTest.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\Campaign;
26
use PHPUnit\Framework\TestCase;
27
28
class CampaignTest extends TestCase
29
{
30
    
31
    public function testCreateChannel()
32
    {
33
        $mock = $this->createMock(ApiInterface::class);
34
        $mock
35
            ->expects($this->once())
36
            ->method('post')
37
            ->with(
38
                    $this->equalTo('https://api-ssl.bitly.com/v4/channels'),
39
                    $this->identicalTo(['key' => 'value'])
40
                    );
41
        $bitlink = new Campaign($mock);
42
        $bitlink->createChannel(['key' => 'value']);
43
    } 
44
    
45
    public function testGetChannels()
46
    {
47
        $mock = $this->createMock(ApiInterface::class);
48
        $mock
49
            ->expects($this->once())
50
            ->method('get')
51
            ->with(
52
                    $this->equalTo('https://api-ssl.bitly.com/v4/channels'),
53
                    $this->identicalTo(['key' => 'value'])
54
                    );
55
        $bitlink = new Campaign($mock);
56
        $bitlink->getChannels(['key' => 'value']);
57
    } 
58
59
    public function testCreateCampaign()
60
    {
61
        $mock = $this->createMock(ApiInterface::class);
62
        $mock
63
            ->expects($this->once())
64
            ->method('post')
65
            ->with(
66
                    $this->equalTo('https://api-ssl.bitly.com/v4/campaigns'),
67
                    $this->identicalTo(['key' => 'value'])
68
                    );
69
        $bitlink = new Campaign($mock);
70
        $bitlink->createCampaign(['key' => 'value']);
71
    } 
72
73
    public function testGetCampaigns()
74
    {
75
        $mock = $this->createMock(ApiInterface::class);
76
        $mock
77
            ->expects($this->once())
78
            ->method('get')
79
            ->with(
80
                    $this->equalTo('https://api-ssl.bitly.com/v4/campaigns'),
81
                    $this->identicalTo(['key' => 'value'])
82
                    );
83
        $bitlink = new Campaign($mock);
84
        $bitlink->getCampaigns(['key' => 'value']);
85
    } 
86
    
87
    public function testGetCampaign()
88
    {
89
        $mock = $this->createMock(ApiInterface::class);
90
        $mock
91
            ->expects($this->once())
92
            ->method('get')
93
            ->with(
94
                    $this->equalTo('https://api-ssl.bitly.com/v4/campaigns/test')
95
                    );
96
        $bitlink = new Campaign($mock);
97
        $bitlink->getCampaign('test');
98
    } 
99
100
    public function testUpdateCampaign()
101
    {
102
        $mock = $this->createMock(ApiInterface::class);
103
        $mock
104
            ->expects($this->once())
105
            ->method('patch')
106
            ->with(
107
                    $this->equalTo('https://api-ssl.bitly.com/v4/campaigns/test'),
108
                    $this->identicalTo(['key' => 'value'])
109
                    );
110
        $bitlink = new Campaign($mock);
111
        $bitlink->updateCampaign('test', ['key' => 'value']);
112
    } 
113
114
    public function testGetChannel()
115
    {
116
        $mock = $this->createMock(ApiInterface::class);
117
        $mock
118
            ->expects($this->once())
119
            ->method('get')
120
            ->with(
121
                    $this->equalTo('https://api-ssl.bitly.com/v4/channels/test')
122
                    );
123
        $bitlink = new Campaign($mock);
124
        $bitlink->getChannel('test');
125
    } 
126
127
    public function testUpdateChannel()
128
    {
129
        $mock = $this->createMock(ApiInterface::class);
130
        $mock
131
            ->expects($this->once())
132
            ->method('patch')
133
            ->with(
134
                    $this->equalTo('https://api-ssl.bitly.com/v4/channels/test'),
135
                    $this->identicalTo(['key' => 'value'])
136
                    );
137
        $bitlink = new Campaign($mock);
138
        $bitlink->updateChannel('test', ['key' => 'value']);
139
    } 
140
141
}
142