Skip to content

Commit a943d30

Browse files
authored
Merge pull request #61 from packagist/synchronizations-endpoint
API: add list synchronizations endpoint
2 parents c3516f0 + cbfc578 commit a943d30

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/Api/Synchronizations.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace PrivatePackagist\ApiClient\Api;
4+
5+
class Synchronizations extends AbstractApi
6+
{
7+
public function all()
8+
{
9+
return $this->get('/synchronizations/');
10+
}
11+
}

src/Client.php

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public function tokens()
112112
return new Api\Tokens($this, $this->responseMediator);
113113
}
114114

115+
public function synchronizations()
116+
{
117+
return new Api\Synchronizations($this, $this->responseMediator);
118+
}
119+
115120
public function getHttpClient()
116121
{
117122
return $this->getHttpClientBuilder()->getHttpClient();

tests/Api/SynchronizationsTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PrivatePackagist\ApiClient\Api;
4+
5+
use PHPUnit\Framework\MockObject\MockObject;
6+
7+
class SynchronizationsTest extends ApiTestCase
8+
{
9+
public function testAll()
10+
{
11+
$expected = [
12+
[
13+
"id" => 42,
14+
"name" => "Acme Organization",
15+
"isPrimary" => true,
16+
"integration" => [
17+
"name" => "GitHub",
18+
"target" => "github",
19+
"url" => "https://github.com"
20+
],
21+
"credentials" => 432,
22+
]
23+
];
24+
25+
/** @var Synchronizations&MockObject $api */
26+
$api = $this->getApiMock();
27+
$api->expects($this->once())
28+
->method('get')
29+
->with($this->equalTo('/synchronizations/'))
30+
->willReturn($expected);
31+
32+
$this->assertSame($expected, $api->all());
33+
}
34+
35+
/**
36+
* @return string
37+
*/
38+
protected function getApiClass()
39+
{
40+
return Synchronizations::class;
41+
}
42+
}

0 commit comments

Comments
 (0)