forked from Potherca/flysystem-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGithubAdapterTest.php
More file actions
76 lines (66 loc) · 2.37 KB
/
Copy pathGithubAdapterTest.php
File metadata and controls
76 lines (66 loc) · 2.37 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
<?php
namespace Potherca\Flysystem\Github;
/**
* Tests for the GithubAdapter class
*
* @coversDefaultClass \Potherca\Flysystem\Github\GithubAdapter
* @covers ::<!public>
* @covers ::__construct
* @covers ::getApi
*/
class GithubAdapterTest extends \PHPUnit_Framework_TestCase
{
////////////////////////////////// FIXTURES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
const MOCK_FILE_PATH = '/path/to/mock/file';
/** @var GithubAdapter */
private $adapter;
/** @var ApiInterface|\PHPUnit_Framework_MockObject_MockObject */
private $mockClient;
/**
*
*/
protected function setup()
{
$this->mockClient = $this->getMock(ApiInterface::class);
$this->adapter = new GithubAdapter($this->mockClient);
}
/////////////////////////////////// TESTS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/**
* @covers ::has
* @covers ::read
* @covers ::listContents
* @covers ::getMetadata
* @covers ::getSize
* @covers ::getMimetype
* @covers ::getTimestamp
* @covers ::getVisibility
*
* @dataProvider provideReadMethods
*
* @param $method
* @param $apiMethod
* @param $parameters
*/
final public function testAdapterShouldPassParameterToClient($method, $apiMethod, $parameters)
{
$mocker = $this->mockClient->expects($this->exactly(1))
->method($apiMethod);
$mocker->getMatcher()->parametersMatcher = new \PHPUnit_Framework_MockObject_Matcher_Parameters($parameters);
call_user_func_array([$this->adapter, $method], $parameters);
}
////////////////////////////// MOCKS AND STUBS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/////////////////////////////// DATAPROVIDERS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
final public function provideReadMethods()
{
return [
['has', 'exists', [self::MOCK_FILE_PATH]],
['read', 'getFileContents', [self::MOCK_FILE_PATH]],
['listContents', 'getRecursiveMetadata', [self::MOCK_FILE_PATH, true]],
['getMetadata', 'getMetadata', [self::MOCK_FILE_PATH]],
['getSize', 'getMetadata', [self::MOCK_FILE_PATH]],
['getMimetype', 'guessMimeType', [self::MOCK_FILE_PATH]],
['getTimestamp', 'getLastUpdatedTimestamp', [self::MOCK_FILE_PATH]],
['getVisibility', 'getRecursiveMetadata', [self::MOCK_FILE_PATH]],
];
}
}