Repository navigation
Expand file tree
/
Copy pathBlobsTest.php
More file actions
104 lines (84 loc) · 2.68 KB
/
Copy pathBlobsTest.php
File metadata and controls
104 lines (84 loc) · 2.68 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
<?php
namespace Github\Tests\Api;
use Github\Tests\Api\TestCase;
class BlobsTest extends TestCase
{
/**
* @test
*/
public function shouldShowBlob()
{
$expectedValue = array('blob' => 'some data');
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('repos/l3l0/l3l0repo/git/blobs/123456sha')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha'));
}
/**
* @test
*/
public function shouldShowRawBlob()
{
$expectedValue = array('blob' => 'some data');
$client = $this->getMockBuilder('Github\Client')
->disableOriginalConstructor()
->getMock();
$api = $this->getMockBuilder($this->getApiClass())
->setMethods(array('configure', 'get'))
->setConstructorArgs(array($client))
->getMock();
$api->expects($this->once())
->method('configure')
->with('raw');
$api->expects($this->once())
->method('get')
->with('repos/l3l0/l3l0repo/git/blobs/123456sha')
->will($this->returnValue($expectedValue));
$api->configure('raw');
$this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha'));
}
/**
* @test
*/
public function shouldCreateBlob()
{
$expectedValue = array('blob' => 'some data');
$data = array('content' => 'some cotent', 'encoding' => 'utf8');
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('repos/l3l0/l3l0repo/git/blobs', $data)
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->create('l3l0', 'l3l0repo', $data));
}
/**
* @test
* @expectedException Github\Exception\MissingArgumentException
*/
public function shouldNotCreateBlobWithoutEncoding()
{
$data = array('content' => 'some cotent');
$api = $this->getApiMock();
$api->expects($this->never())
->method('post');
$api->create('l3l0', 'l3l0repo', $data);
}
/**
* @test
* @expectedException Github\Exception\MissingArgumentException
*/
public function shouldNotCreateBlobWithoutContent()
{
$data = array('encoding' => 'utf8');
$api = $this->getApiMock();
$api->expects($this->never())
->method('post');
$api->create('l3l0', 'l3l0repo', $data);
}
protected function getApiClass()
{
return 'Github\Api\GitData\Blobs';
}
}