forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeploymentTest.php
More file actions
112 lines (93 loc) · 2.84 KB
/
DeploymentTest.php
File metadata and controls
112 lines (93 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
namespace Github\Tests\Api;
class DeploymentTest extends TestCase
{
/**
* @test
*/
public function shouldCreateDeployment()
{
$api = $this->getApiMock();
$deploymentData = ['ref' => 'fd6a5f9e5a430dddae8d6a8ea378f913d3a766f9'];
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/deployments', $deploymentData);
$api->create('KnpLabs', 'php-github-api', $deploymentData);
}
/**
* @test
*/
public function shouldGetAllDeployments()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/deployments');
$api->all('KnpLabs', 'php-github-api');
}
/**
* @test
*/
public function shouldGetAllDeploymentsWithFilterParameters()
{
$api = $this->getApiMock();
$filterData = ['foo' => 'bar', 'bar' => 'foo'];
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/deployments', $filterData);
$api->all('KnpLabs', 'php-github-api', $filterData);
}
/**
* @test
*/
public function shouldShowProject()
{
$expectedValue = ['id' => 123, 'ref' => 'master'];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/deployments/123')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
}
/**
* @test
*/
public function shouldCreateStatusUpdate()
{
$api = $this->getApiMock();
$statusData = ['state' => 'pending', 'description' => 'waiting to start'];
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/deployments/1/statuses', $statusData);
$api->updateStatus('KnpLabs', 'php-github-api', 1, $statusData);
}
/**
* @test
* @expectedException \Github\Exception\MissingArgumentException
*/
public function shouldRejectStatusUpdateWithoutStateField()
{
$api = $this->getApiMock();
$statusData = ['description' => 'waiting to start'];
$api->updateStatus('KnpLabs', 'php-github-api', 1, $statusData);
}
/**
* @test
*/
public function shouldGetAllStatuses()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/deployments/1/statuses');
$api->getStatuses('KnpLabs', 'php-github-api', 1);
}
/**
* @return string
*/
protected function getApiClass()
{
return \Github\Api\Deployment::class;
}
}