|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// CustomTest.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\Custom; |
|
26
|
|
|
use PHPUnit\Framework\TestCase; |
|
27
|
|
|
|
|
28
|
|
|
class CustomTest extends TestCase |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
public function testUpdateCustomBitlink() |
|
32
|
|
|
{ |
|
33
|
|
|
$mock = $this->createMock(ApiInterface::class); |
|
34
|
|
|
$mock |
|
35
|
|
|
->expects($this->once()) |
|
36
|
|
|
->method('patch') |
|
37
|
|
|
->with( |
|
38
|
|
|
$this->equalTo('https://api-ssl.bitly.com/v4/custom_bitlinks/test'), |
|
39
|
|
|
$this->identicalTo(['key' => 'value']) |
|
40
|
|
|
); |
|
41
|
|
|
$bitlink = new Custom($mock); |
|
42
|
|
|
$bitlink->updateCustomBitlink('test', ['key' => 'value']); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testGetCustomBitlink() |
|
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/custom_bitlinks/test') |
|
53
|
|
|
); |
|
54
|
|
|
$bitlink = new Custom($mock); |
|
55
|
|
|
$bitlink->getCustomBitlink('test'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testAddCustomBitlink() |
|
59
|
|
|
{ |
|
60
|
|
|
$mock = $this->createMock(ApiInterface::class); |
|
61
|
|
|
$mock |
|
62
|
|
|
->expects($this->once()) |
|
63
|
|
|
->method('post') |
|
64
|
|
|
->with( |
|
65
|
|
|
$this->equalTo('https://api-ssl.bitly.com/v4/custom_bitlinks'), |
|
66
|
|
|
$this->identicalTo(['key' => 'value']) |
|
67
|
|
|
); |
|
68
|
|
|
$bitlink = new Custom($mock); |
|
69
|
|
|
$bitlink->addCustomBitlink(['key' => 'value']); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function testGetCustomBitlinkMetricsByDestination() |
|
73
|
|
|
{ |
|
74
|
|
|
$mock = $this->createMock(ApiInterface::class); |
|
75
|
|
|
$mock |
|
76
|
|
|
->expects($this->once()) |
|
77
|
|
|
->method('get') |
|
78
|
|
|
->with( |
|
79
|
|
|
$this->equalTo('https://api-ssl.bitly.com/v4/custom_bitlinks/test/clicks_by_destination') |
|
80
|
|
|
); |
|
81
|
|
|
$bitlink = new Custom($mock); |
|
82
|
|
|
$bitlink->getCustomBitlinkMetricsByDestination('test'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|