|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Onesky\Api\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Onesky\Api\Client; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class to test the projects resource. |
|
9
|
|
|
* |
|
10
|
|
|
* See more about projects resource here: |
|
11
|
|
|
* https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md |
|
12
|
|
|
* |
|
13
|
|
|
* @author Bernardo Silva <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class ProjectsApiTest extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var \Onesky\Api\Client $api */ |
|
18
|
|
|
protected $api; |
|
19
|
|
|
|
|
20
|
|
|
public function setUp() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->api = new Client(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @expectedException \InvalidArgumentException |
|
27
|
|
|
* @expectedExceptionMessage Invalid resource action |
|
28
|
|
|
*/ |
|
29
|
|
|
public function testProjectsDetectMissingResourceAction() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->api->projects(); |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @expectedException \InvalidArgumentException |
|
36
|
|
|
* @expectedExceptionMessage Missing parameter: project_group_id |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testProjectsListDetectMissingGroupIdParam() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->api->projects('list'); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @expectedException \UnexpectedValueException |
|
45
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testProjectsListDetectInvalidAuthentication() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->api->projects('list', ['project_group_id' => 123]); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @expectedException \InvalidArgumentException |
|
55
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testProjectsShowDetectMissingParam() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->api->projects('show'); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @expectedException \UnexpectedValueException |
|
64
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
65
|
|
|
*/ |
|
66
|
|
|
public function testProjectsShowDetectInvalidAuthentication() |
|
67
|
|
|
{ |
|
68
|
|
|
$this->api->projects('show', ['project_id' => 123]); |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @expectedException \InvalidArgumentException |
|
73
|
|
|
* @expectedExceptionMessage Missing parameter: project_group_id |
|
74
|
|
|
*/ |
|
75
|
|
|
public function testProjectsCreateDetectMissingGroupIdParam() |
|
76
|
|
|
{ |
|
77
|
|
|
$this->api->projects('create'); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @expectedException \UnexpectedValueException |
|
82
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
83
|
|
|
*/ |
|
84
|
|
|
public function testProjectsCreateDetectMissingParam() |
|
85
|
|
|
{ |
|
86
|
|
|
$this->api->projects('create', ['project_group_id' => 123]); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @expectedException \InvalidArgumentException |
|
91
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
|
92
|
|
|
*/ |
|
93
|
|
|
public function testProjectsUpdateDetectMissingParam() |
|
94
|
|
|
{ |
|
95
|
|
|
$this->api->projects('update'); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @expectedException \UnexpectedValueException |
|
100
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
101
|
|
|
*/ |
|
102
|
|
|
public function testProjectsUpdateDetectInvalidAuthentication() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->api->projects('update', ['project_id' => 123]); |
|
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @expectedException \InvalidArgumentException |
|
109
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
|
110
|
|
|
*/ |
|
111
|
|
|
public function testProjectsDeleteDetectMissingParam() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->api->projects('delete'); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @expectedException \UnexpectedValueException |
|
118
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
119
|
|
|
*/ |
|
120
|
|
|
public function testProjectsDeleteDetectInvalidAuthentication() |
|
121
|
|
|
{ |
|
122
|
|
|
$this->api->projects('delete', ['project_id' => 123]); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @expectedException \InvalidArgumentException |
|
127
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
|
128
|
|
|
*/ |
|
129
|
|
|
public function testProjectsLanguagesDetectMissingParam() |
|
130
|
|
|
{ |
|
131
|
|
|
$this->api->projects('languages'); |
|
|
|
|
|
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @expectedException \UnexpectedValueException |
|
136
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
|
137
|
|
|
*/ |
|
138
|
|
|
public function testProjectsLanguagesDetectInvalidAuthentication() |
|
139
|
|
|
{ |
|
140
|
|
|
$this->api->projects('languages', ['project_id' => 123]); |
|
|
|
|
|
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: