1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onesky\Api\Tests; |
4
|
|
|
|
5
|
|
|
use Onesky\Api\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class to test the files resource. |
9
|
|
|
* |
10
|
|
|
* See more about files resource here: |
11
|
|
|
* https://github.com/onesky/api-documentation-platform/blob/master/resources/file.md |
12
|
|
|
* |
13
|
|
|
* @author Bernardo Silva <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class FilesApiTest 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 testFilesDetectMissingResourceAction() |
30
|
|
|
{ |
31
|
|
|
$this->api->files(); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @expectedException \InvalidArgumentException |
36
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
37
|
|
|
*/ |
38
|
|
|
public function testFilesListDetectMissingParam() |
39
|
|
|
{ |
40
|
|
|
$this->api->files('list'); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @expectedException \UnexpectedValueException |
45
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
46
|
|
|
*/ |
47
|
|
|
public function testFilesListDetectInvalidAuthentication() |
48
|
|
|
{ |
49
|
|
|
$this->api->files('list', ['project_id' => 123]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @expectedException \InvalidArgumentException |
55
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
56
|
|
|
*/ |
57
|
|
|
public function testFilesUploadDetectMissingParam() |
58
|
|
|
{ |
59
|
|
|
$this->api->files('upload'); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @expectedException \UnexpectedValueException |
64
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
65
|
|
|
*/ |
66
|
|
|
public function testFilesUploadDetectInvalidAuthentication() |
67
|
|
|
{ |
68
|
|
|
$this->api->files('upload', ['project_id' => 123]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @expectedException \InvalidArgumentException |
73
|
|
|
* @expectedExceptionMessage Missing parameter: project_id |
74
|
|
|
*/ |
75
|
|
|
public function testFilesDeleteDetectMissingParam() |
76
|
|
|
{ |
77
|
|
|
$this->api->files('delete'); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @expectedException \UnexpectedValueException |
82
|
|
|
* @expectedExceptionMessage Invalid authenticate data of api key or secret |
83
|
|
|
*/ |
84
|
|
|
public function testFilesDeleteDetectInvalidAuthentication() |
85
|
|
|
{ |
86
|
|
|
$this->api->files('delete', ['project_id' => 123]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|