; rel="last",';
-
- $pagination = [
- 'first' => 'https://github.com',
- 'next' => 'https://github.com',
- 'prev' => 'https://github.com',
- 'last' => 'https://github.com',
- ];
-
- // response mock
- $response = new Response(200, ['link' => $header]);
- $result = ResponseMediator::getPagination($response);
-
- $this->assertEquals($pagination, $result);
- }
-
public function testGetHeader()
{
$header = 'application/json';
diff --git a/test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php b/test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php
similarity index 93%
rename from test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php
rename to test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php
index be937684d01..5c14a7812bc 100644
--- a/test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php
+++ b/test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php
@@ -1,9 +1,9 @@
new \Github\Exception\ApiLimitExceedException(5000),
+ 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000),
],
'Rate Limit Exceeded via 403 status' => [
'response' => new Response(
@@ -90,7 +90,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\ApiLimitExceedException(5000),
+ 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000),
],
'Secondary Rate Limit Exceeded via 403 status' => [
'response' => new Response(
@@ -107,7 +107,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\ApiLimitExceedException(5000),
+ 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000),
],
'Two Factor Authentication Required' => [
'response' => new Response(
@@ -118,7 +118,7 @@ public static function responseProvider()
],
''
),
- 'exception' => new \Github\Exception\TwoFactorAuthenticationRequiredException('2fa-type'),
+ 'exception' => new \ArgoCD\Exception\TwoFactorAuthenticationRequiredException('2fa-type'),
],
'400 Bad Request' => [
'response' => new Response(
@@ -132,7 +132,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\ErrorException('Problems parsing JSON (Bad Request)', 400),
+ 'exception' => new \ArgoCD\Exception\ErrorException('Problems parsing JSON (Bad Request)', 400),
],
'422 Unprocessable Entity' => [
'response' => new Response(
@@ -154,7 +154,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\ErrorException('Validation Failed: The field value does not exist, for resource "resource"', 422),
+ 'exception' => new \ArgoCD\Exception\ErrorException('Validation Failed: The field value does not exist, for resource "resource"', 422),
],
'502 Response' => [
'response' => new Response(
@@ -170,7 +170,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\RuntimeException('Something went wrong with executing your query', 502),
+ 'exception' => new \ArgoCD\Exception\RuntimeException('Something went wrong with executing your query', 502),
],
'Sso required Response' => [
'response' => new Response(
@@ -180,7 +180,7 @@ public static function responseProvider()
'X-GitHub-SSO' => 'required; url=https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4',
]
),
- 'exception' => new \Github\Exception\SsoRequiredException('https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4'),
+ 'exception' => new \ArgoCD\Exception\SsoRequiredException('https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4'),
],
'Default handling' => [
'response' => new Response(
@@ -188,7 +188,7 @@ public static function responseProvider()
[],
'Error message'
),
- 'exception' => new \Github\Exception\RuntimeException('Error message', 555),
+ 'exception' => new \ArgoCD\Exception\RuntimeException('Error message', 555),
],
'Graphql error response (200)' => [
'response' => new Response(
@@ -211,7 +211,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\RuntimeException('Field "xxxx" doesn\'t exist on type "Issue", Field "dummy" doesn\'t exist on type "PullRequest"'),
+ 'exception' => new \ArgoCD\Exception\RuntimeException('Field "xxxx" doesn\'t exist on type "Issue", Field "dummy" doesn\'t exist on type "PullRequest"'),
],
'Grapql requires authentication' => [
'response' => new Response(
@@ -230,7 +230,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\RuntimeException('This endpoint requires you to be authenticated.', 401),
+ 'exception' => new \ArgoCD\Exception\RuntimeException('This endpoint requires you to be authenticated.', 401),
],
'Cannot delete active deployment' => [
'response' => new Response(
@@ -246,7 +246,7 @@ public static function responseProvider()
]
)
),
- 'exception' => new \Github\Exception\ValidationFailedException('Validation Failed: We cannot delete an active deployment unless it is the only deployment in a given environment.', 422),
+ 'exception' => new \ArgoCD\Exception\ValidationFailedException('Validation Failed: We cannot delete an active deployment unless it is the only deployment in a given environment.', 422),
],
];
}
diff --git a/test/Github/Tests/HttpClient/Plugin/PathPrependTest.php b/test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php
similarity index 92%
rename from test/Github/Tests/HttpClient/Plugin/PathPrependTest.php
rename to test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php
index f5d4052d94d..5297eaee13d 100644
--- a/test/Github/Tests/HttpClient/Plugin/PathPrependTest.php
+++ b/test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php
@@ -1,8 +1,8 @@
getHttpMethodsMock(['get']);
- $httpClient
- ->expects($this->any())
- ->method('get')
- ->with('/path?param1=param1value', ['header1' => 'header1value'])
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
- $client = $this->getMockBuilder(\Github\Client::class)
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
-
- $actual = $this->getMethod($api, 'get')
- ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['header1' => 'header1value']]);
-
- $this->assertEquals($expectedArray, $actual);
- }
-
- /**
- * @test
- */
- public function shouldPassPOSTRequestToClient()
- {
- $expectedArray = ['value'];
-
- $httpClient = $this->getHttpMethodsMock(['post']);
- $httpClient
- ->expects($this->once())
- ->method('post')
- ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value']))
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
-
- $client = $this->getMockBuilder(\Github\Client::class)
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
- $actual = $this->getMethod($api, 'post')
- ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]);
-
- $this->assertEquals($expectedArray, $actual);
- }
-
- /**
- * @test
- */
- public function shouldPassPATCHRequestToClient()
- {
- $expectedArray = ['value'];
-
- $httpClient = $this->getHttpMethodsMock(['patch']);
- $httpClient
- ->expects($this->once())
- ->method('patch')
- ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value']))
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
-
- $client = $this->getMockBuilder(\Github\Client::class)
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
- $actual = $this->getMethod($api, 'patch')
- ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]);
-
- $this->assertEquals($expectedArray, $actual);
- }
-
- /**
- * @test
- */
- public function shouldPassPUTRequestToClient()
- {
- $expectedArray = ['value'];
-
- $httpClient = $this->getHttpMethodsMock(['put']);
- $httpClient
- ->expects($this->once())
- ->method('put')
- ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value']))
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
-
- $client = $this->getMockBuilder('Github\Client')
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
- $actual = $this->getMethod($api, 'put')
- ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]);
-
- $this->assertEquals($expectedArray, $actual);
- }
-
- /**
- * @test
- */
- public function shouldPassDELETERequestToClient()
- {
- $expectedArray = ['value'];
-
- $httpClient = $this->getHttpMethodsMock(['delete']);
- $httpClient
- ->expects($this->once())
- ->method('delete')
- ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value']))
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
-
- $client = $this->getMockBuilder('Github\Client')
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
- $actual = $this->getMethod($api, 'delete')
- ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]);
-
- $this->assertEquals($expectedArray, $actual);
- }
-
- /**
- * @test
- */
- public function shouldNotPassEmptyRefToClient()
- {
- $expectedArray = ['value'];
-
- $httpClient = $this->getHttpMethodsMock(['get']);
- $httpClient
- ->expects($this->any())
- ->method('get')
- ->with('/path', [])
- ->will($this->returnValue($this->getPSR7Response($expectedArray)));
-
- $client = $this->getMockBuilder(\Github\Client::class)
- ->setMethods(['getHttpClient'])
- ->getMock();
- $client->expects($this->any())
- ->method('getHttpClient')
- ->willReturn($httpClient);
-
- $api = $this->getAbstractApiObject($client);
- $actual = $this->getMethod($api, 'get')->invokeArgs($api, ['/path', ['ref' => null]]);
-
- $this->assertIsArray($actual);
- }
-
- /**
- * @param $client
- *
- * @return \PHPUnit\Framework\MockObject\MockObject
- */
- protected function getAbstractApiObject($client)
- {
- return $this->getMockBuilder($this->getApiClass())
- ->setMethods(null)
- ->setConstructorArgs([$client])
- ->getMock();
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return AbstractApi::class;
- }
-
- /**
- * @return \Github\Client
- */
- protected function getClientMock()
- {
- return new \Github\Client($this->getHttpMethodsMock());
- }
-
- /**
- * Return a HttpMethods client mock.
- *
- * @param array $methods
- *
- * @return \Http\Client\Common\HttpMethodsClientInterface
- */
- protected function getHttpMethodsMock(array $methods = [])
- {
- $mock = $this->createMock(HttpMethodsClientInterface::class);
-
- $mock
- ->expects($this->any())
- ->method('sendRequest');
-
- return $mock;
- }
-
- /**
- * @param $expectedArray
- *
- * @return Response
- */
- private function getPSR7Response($expectedArray)
- {
- return new Response(
- 200,
- ['Content-Type' => 'application/json'],
- Utils::streamFor(json_encode($expectedArray))
- );
- }
-}
diff --git a/test/Github/Tests/Api/App/HookTest.php b/test/Github/Tests/Api/App/HookTest.php
deleted file mode 100644
index f2ed6ae5ab4..00000000000
--- a/test/Github/Tests/Api/App/HookTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
- 'json',
- 'insecure_ssl' => 0,
- 'secret' => '********',
- 'url' => 'https://localhost/',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/app/hook/config', [])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->showConfig());
- }
-
- /**
- * @test
- */
- public function shouldUpdateHookConfiguration()
- {
- $parameters = [
- 'content_type' => 'json',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/app/hook/config', $parameters)
- ->willReturn([]);
-
- $this->assertEquals([], $api->updateConfig($parameters));
- }
-
- /**
- * @test
- */
- public function shouldListHookDelivieries()
- {
- $result = [];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/app/hook/deliveries', [])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->deliveries());
- }
-
- /**
- * @test
- */
- public function shouldListHookDeliviery()
- {
- $result = [];
-
- $delivery = 1234567;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/app/hook/deliveries/'.$delivery, [])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->delivery($delivery));
- }
-
- /**
- * @test
- */
- public function shouldRedeliveryHook()
- {
- $result = [];
-
- $delivery = 1234567;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/app/hook/deliveries/'.$delivery.'/attempts', [])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->redeliver($delivery));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\App\Hook::class;
- }
-}
diff --git a/test/Github/Tests/Api/AppTest.php b/test/Github/Tests/Api/AppTest.php
deleted file mode 100644
index b813a11dd1f..00000000000
--- a/test/Github/Tests/Api/AppTest.php
+++ /dev/null
@@ -1,187 +0,0 @@
- 'v1.1f699f1069f60xxx',
- 'expires_at' => '2016-07-11T22:14:10Z',
- ];
- $installationId = 'installation1';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/app/installations/'.$installationId.'/access_tokens', [])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->createInstallationToken($installationId));
- }
-
- /**
- * @test
- */
- public function shouldFindInstallationsForApplication()
- {
- $result = ['installation1', 'installation2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/app/installations')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->findInstallations());
- }
-
- /**
- * @test
- */
- public function shouldGetInstallationForApplication()
- {
- $result = ['installation1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/app/installations/1234')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->getInstallation('1234'));
- }
-
- /**
- * @test
- */
- public function shouldGetInstallationForOrganization()
- {
- $result = ['installation1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/1234/installation')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->getInstallationForOrganization('1234'));
- }
-
- /**
- * @test
- */
- public function shouldGetInstallationForRepo()
- {
- $result = ['installation1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/MyOrg/MyRepo/installation')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->getInstallationForRepo('MyOrg', 'MyRepo'));
- }
-
- /**
- * @test
- */
- public function shouldGetInstallationForUser()
- {
- $result = ['installation1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/octocat/installation')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->getInstallationForUser('octocat'));
- }
-
- /**
- * @test
- */
- public function shouldDeleteInstallationForApplication()
- {
- $id = 123;
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/app/installations/'.$id);
-
- $api->removeInstallation($id);
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoriesFromInstallation()
- {
- $result = ['repo1', 'repo2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/installation/repositories', ['user_id' => '1234'])
- ->willReturn($result);
-
- $this->assertEquals($result, $api->listRepositories('1234'));
- }
-
- /**
- * @test
- */
- public function shouldAddRepositoryToInstallation()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/installations/1234/repositories/5678');
-
- $api->addRepository('1234', '5678');
- }
-
- /**
- * @test
- */
- public function shouldRemoveRepositoryToInstallation()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/installations/1234/repositories/5678');
-
- $api->removeRepository('1234', '5678');
- }
-
- /**
- * @test
- */
- public function shouldGetAuthenticatedApp()
- {
- $api = $this->getApiMock();
-
- $result = ['authenticatedApp1'];
-
- $api->expects($this->once())
- ->method('get')
- ->with('/app')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->getAuthenticatedApp());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Apps::class;
- }
-}
diff --git a/test/Github/Tests/Api/Copilot/UsageTest.php b/test/Github/Tests/Api/Copilot/UsageTest.php
deleted file mode 100644
index c14c3e3ffa8..00000000000
--- a/test/Github/Tests/Api/Copilot/UsageTest.php
+++ /dev/null
@@ -1,78 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/copilot/usage', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->orgUsageSummary('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetOrgTeamUsageSummary(): void
- {
- $expectedValue = ['usage1', 'usage2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/team/php-github-api/copilot/usage', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->orgTeamUsageSummary('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetEnterpriseUsageSummary(): void
- {
- $expectedValue = ['usage1', 'usage2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/enterprises/KnpLabs/copilot/usage', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->enterpriseUsageSummary('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetEnterpriseTeamUsageSummary(): void
- {
- $expectedValue = ['usage1', 'usage2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/enterprises/KnpLabs/team/php-github-api/copilot/usage', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->enterpriseTeamUsageSummary('KnpLabs', 'php-github-api'));
- }
-
- protected function getApiClass(): string
- {
- return Usage::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php b/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php
deleted file mode 100644
index 4f147e25e02..00000000000
--- a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php
+++ /dev/null
@@ -1,112 +0,0 @@
- '12', 'key' => 'ssh-rsa ...'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/keys/12')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show(12));
- }
-
- /**
- * @test
- */
- public function shouldGetKeys()
- {
- $expectedValue = [['id' => '12', 'key' => 'ssh-rsa ...']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/keys')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldCreateKey()
- {
- $expectedValue = ['id' => '123', 'key' => 'ssh-rsa ...'];
- $data = ['title' => 'my key', 'key' => 'ssh-rsa ...'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/keys', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create($data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateKeyWithoutTitleParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['key' => 'ssh-rsa ...'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create($data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateKeyWithoutKeyParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['title' => 'my key'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create($data);
- }
-
- /**
- * @test
- */
- public function shouldRemoveKey()
- {
- $expectedValue = ['some value'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/keys/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove(123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\PublicKeys::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/EmailsTest.php b/test/Github/Tests/Api/CurrentUser/EmailsTest.php
deleted file mode 100644
index 1fed2a0d780..00000000000
--- a/test/Github/Tests/Api/CurrentUser/EmailsTest.php
+++ /dev/null
@@ -1,139 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/emails')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldRemoveEmail()
- {
- $expectedValue = ['some value'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/emails', ['email@example.com'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('email@example.com'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveEmails()
- {
- $expectedValue = ['some value'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/emails', ['email@example.com', 'email2@example.com'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove(['email@example.com', 'email2@example.com']));
- }
-
- /**
- * @test
- */
- public function shouldNotRemoveEmailsWhenAreNotPass()
- {
- $this->expectException(InvalidArgumentException::class);
- $api = $this->getApiMock();
- $api->expects($this->any())
- ->method('delete');
-
- $api->remove([]);
- }
-
- /**
- * @test
- */
- public function shouldAddEmail()
- {
- $expectedValue = ['some value'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/emails', ['email@example.com'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add('email@example.com'));
- }
-
- /**
- * @test
- */
- public function shouldAddEmails()
- {
- $expectedValue = ['some value'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/emails', ['email@example.com', 'email2@example.com'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add(['email@example.com', 'email2@example.com']));
- }
-
- /**
- * @test
- */
- public function shouldNotAddEmailsWhenAreNotPass()
- {
- $this->expectException(InvalidArgumentException::class);
- $api = $this->getApiMock();
- $api->expects($this->any())
- ->method('post');
-
- $api->add([]);
- }
-
- /**
- * @test
- */
- public function shouldToggleVisibility()
- {
- $expectedValue = ['primary email info'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/user/email/visibility')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->toggleVisibility());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\Emails::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/FollowersTest.php b/test/Github/Tests/Api/CurrentUser/FollowersTest.php
deleted file mode 100644
index 19b4b0faab6..00000000000
--- a/test/Github/Tests/Api/CurrentUser/FollowersTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
- 'l3l0'],
- ['login' => 'cordoval'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/following')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldCheckFollower()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/following/l3l0')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->check('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldFollowUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/user/following/l3l0')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->follow('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldUnfollowUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/following/l3l0')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->unfollow('l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\Followers::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php b/test/Github/Tests/Api/CurrentUser/MembershipsTest.php
deleted file mode 100644
index aef9f374c23..00000000000
--- a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
- [
- 'login' => 'octocat',
- 'id' => 1,
- ],
- 'user' => [
- 'login' => 'defunkt',
- 'id' => 3,
- ],
- ],
- [
- 'organization' => [
- 'login' => 'invitocat',
- 'id' => 2,
- ],
- 'user' => [
- 'login' => 'defunkt',
- 'id' => 3,
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/memberships/orgs')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetMembershipsForOrganization()
- {
- $expectedValue = [
- 'organization' => [
- 'login' => 'invitocat',
- 'id' => 2,
- ],
- 'user' => [
- 'login' => 'defunkt',
- 'id' => 3,
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/memberships/orgs/invitocat')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->organization('invitocat'));
- }
-
- /**
- * @test
- */
- public function shouldEditMembershipsForOrganization()
- {
- $expectedValue = [
- 'state' => 'active',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/user/memberships/orgs/invitocat')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->edit('invitocat'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\Memberships::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/StarringTest.php b/test/Github/Tests/Api/CurrentUser/StarringTest.php
deleted file mode 100644
index 2210aaf2197..00000000000
--- a/test/Github/Tests/Api/CurrentUser/StarringTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
- 'l3l0/test'],
- ['name' => 'cordoval/test'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/starred')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldCheckStar()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/starred/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->check('l3l0', 'test'));
- }
-
- /**
- * @test
- */
- public function shouldStarUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/user/starred/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->star('l3l0', 'test'));
- }
-
- /**
- * @test
- */
- public function shouldUnstarUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/starred/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->unstar('l3l0', 'test'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\Starring::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUser/WatchersTest.php b/test/Github/Tests/Api/CurrentUser/WatchersTest.php
deleted file mode 100644
index 81491eab153..00000000000
--- a/test/Github/Tests/Api/CurrentUser/WatchersTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
- 'l3l0/test'],
- ['name' => 'cordoval/test'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/subscriptions')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldCheckWatcher()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/subscriptions/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->check('l3l0', 'test'));
- }
-
- /**
- * @test
- */
- public function shouldWatchUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/user/subscriptions/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->watch('l3l0', 'test'));
- }
-
- /**
- * @test
- */
- public function shouldUnwatchUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/subscriptions/l3l0/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->unwatch('l3l0', 'test'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser\Watchers::class;
- }
-}
diff --git a/test/Github/Tests/Api/CurrentUserTest.php b/test/Github/Tests/Api/CurrentUserTest.php
deleted file mode 100644
index 5de99f5c911..00000000000
--- a/test/Github/Tests/Api/CurrentUserTest.php
+++ /dev/null
@@ -1,170 +0,0 @@
- 1, 'username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show());
- }
-
- /**
- * @test
- */
- public function shouldUpdateCurrentUserData()
- {
- $expectedArray = ['id' => 1, 'username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/user', ['value' => 'toChange'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->update(['value' => 'toChange']));
- }
-
- /**
- * @test
- */
- public function shouldGetUserFollowers()
- {
- $expectedArray = [['id' => 1, 'username' => 'l3l0test']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/followers', ['page' => 1])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->followers(1));
- }
-
- /**
- * @test
- */
- public function shouldGetIssuesAssignedToUser()
- {
- $expectedArray = [['id' => 1, 'title' => 'issues']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/issues', ['page' => 1, 'some' => 'param'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->issues(['some' => 'param']));
- }
-
- /**
- * @test
- */
- public function shouldGetInstallations()
- {
- $result = ['installation1', 'installation2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/installations')
- ->willReturn($result);
-
- $this->assertEquals($result, $api->installations());
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoriesByInstallation()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/installations/42/repositories', ['page' => 1])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->repositoriesByInstallation(42));
- }
-
- /**
- * @test
- */
- public function shouldGetDeployKeysApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\PublicKeys::class, $api->keys());
- }
-
- /**
- * @test
- */
- public function shouldGetEmailsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\Emails::class, $api->emails());
- }
-
- /**
- * @test
- */
- public function shouldGetFollowersApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\Followers::class, $api->follow());
- }
-
- /**
- * @test
- */
- public function shouldGetNotificationsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\Notifications::class, $api->notifications());
- }
-
- /**
- * @test
- */
- public function shouldGetWatchersApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\Watchers::class, $api->watchers());
- }
-
- /**
- * @test
- */
- public function shouldGetStarredApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\CurrentUser\Starring::class, $api->starring());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\CurrentUser::class;
- }
-}
diff --git a/test/Github/Tests/Api/Deployment/EnvironmentsTest.php b/test/Github/Tests/Api/Deployment/EnvironmentsTest.php
deleted file mode 100644
index ab761ab90cf..00000000000
--- a/test/Github/Tests/Api/Deployment/EnvironmentsTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-getApiMock();
-
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/environments/production');
-
- $api->createOrUpdate('KnpLabs', 'php-github-api', 'production');
- }
-
- /**
- * @test
- */
- public function shouldGetAllEnvironments()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/environments');
-
- $api->all('KnpLabs', 'php-github-api');
- }
-
- /**
- * @test
- */
- public function shouldShowEnvironment()
- {
- $expectedValue = 'production';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/environments/production')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'production'));
- }
-
- /**
- * @test
- */
- public function shouldDeleteEnvironment()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/environments/production')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->remove('KnpLabs', 'php-github-api', 'production'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Deployment\Environments::class;
- }
-}
diff --git a/test/Github/Tests/Api/Deployment/PoliciesTest.php b/test/Github/Tests/Api/Deployment/PoliciesTest.php
deleted file mode 100644
index 6b387881ce7..00000000000
--- a/test/Github/Tests/Api/Deployment/PoliciesTest.php
+++ /dev/null
@@ -1,91 +0,0 @@
-getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies');
-
- $api->create('KnpLabs', 'php-github-api', 'production', [
- 'name' => 'name',
- ]);
- }
-
- /**
- * @test
- */
- public function shouldUpdatePolicy()
- {
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1');
-
- $api->update('KnpLabs', 'php-github-api', 'production', 1, [
- 'name' => 'name',
- ]);
- }
-
- /**
- * @test
- */
- public function shouldGetAllPolicies()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies');
-
- $api->all('KnpLabs', 'php-github-api', 'production');
- }
-
- /**
- * @test
- */
- public function shouldShowPolicy()
- {
- $expectedValue = 'production';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'production', 1));
- }
-
- /**
- * @test
- */
- public function shouldDeletePolicy()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->remove('KnpLabs', 'php-github-api', 'production', 1));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Deployment\Policies::class;
- }
-}
diff --git a/test/Github/Tests/Api/DeploymentTest.php b/test/Github/Tests/Api/DeploymentTest.php
deleted file mode 100644
index 8741ee625f7..00000000000
--- a/test/Github/Tests/Api/DeploymentTest.php
+++ /dev/null
@@ -1,148 +0,0 @@
-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 shouldShowDeployment()
- {
- $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 shouldDeleteDeployment()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/deployments/123')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->remove('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
- */
- public function shouldRejectStatusUpdateWithoutStateField()
- {
- $this->expectException(MissingArgumentException::class);
- $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);
- }
-
- /**
- * @test
- */
- public function shouldGetEnvironmentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Deployment\Environments::class, $api->environments());
- }
-
- /**
- * @test
- */
- public function shouldGetPoliciesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Deployment\Policies::class, $api->policies());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Deployment::class;
- }
-}
diff --git a/test/Github/Tests/Api/Enterprise/LicenseTest.php b/test/Github/Tests/Api/Enterprise/LicenseTest.php
deleted file mode 100644
index b8d988a6146..00000000000
--- a/test/Github/Tests/Api/Enterprise/LicenseTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
- 1400,
- 'seats_used' => 1316,
- 'seats_available' => 84,
- 'kind' => 'standard',
- 'days_until_expiration' => 365,
- 'expire_at' => '2016/02/06 12:41:52 -0600',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/enterprise/settings/license')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Enterprise\License::class;
- }
-}
diff --git a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php b/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php
deleted file mode 100644
index fd1d2064f66..00000000000
--- a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php
+++ /dev/null
@@ -1,117 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/setup/api/configcheck', ['license_md5' => $this->getLicenseHash()])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->configcheck($this->getLicenseHash()));
- }
-
- /**
- * @test
- */
- public function shouldShowSettingsData()
- {
- $expectedJson = '{ "enterprise": { "private_mode": false, "github_hostname": "ghe.local", "auth_mode":
- "default", "storage_mode": "rootfs", "admin_password": null, "configuration_id": 1401777404,
- "configuration_run_count": 4, "package_version": "11.10.332", "avatar": { "enabled": false, "uri": "" },
- "customer": { "name": "GitHub", "email": "stannis@themannis.biz", "uuid":
- "af6cac80-e4e1-012e-d822-1231380e52e9",
- "secret_key_data": "-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nlQcYBE5TCgsBEACk4yHpUcapplebaumBMXYMiLF+nCQ0lxpx...\n-----END PGP PRIVATE KEY BLOCK-----\n",
- "public_key_data": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nmI0ETqzZYgEEALSe6snowdenXyqvLfSQ34HWD6C7....\n-----END PGP PUBLIC KEY BLOCK-----\n" },
- "license": { "seats": 0, "evaluation": false, "expire_at": "2015-04-27T00:00:00-07:00", "perpetual": false,
- "unlimited_seating": true, "support_key": "ssh-rsa AAAAB3N....", "ssh_allowed": true }, "github_ssl":
- { "enabled": false, "cert": null, "key": null }, "ldap": { "host": "", "port": "", "base": [ ], "uid": "",
- "bind_dn": "", "password": "", "method": "Plain", "user_groups": [ ], "admin_group": "" }, "cas": { "url": "" },
- "github_oauth": { "client_id": "12313412", "client_secret": "kj123131132", "organization_name":
- "Homestar Runners", "organization_team": "homestarrunners/owners" }, "smtp": { "enabled": true, "address":
- "smtp.example.com", "authentication": "plain", "port": "1234", "domain": "blah", "username": "foo", "user_name":
- "mr_foo", "enable_starttls_auto": true, "password": "bar", "support_address": "enterprise@github.com",
- "noreply_address": "noreply@github.com" }, "dns": { "primary_nameserver": "8.8.8.8", "secondary_nameserver":
- "8.8.4.4" }, "ntp": { "primary_server": "0.ubuntu.pool.ntp.org", "secondary_server": "1.ubuntu.pool.ntp.org" },
- "timezone": { "identifier": "UTC" }, "device": { "path": "/dev/xyz" }, "snmp": { "enabled": false,
- "community": "" }, "rsyslog": { "enabled": false, "server": "", "protocol_name": "TCP" }, "assets": { "storage":
- "file", "bucket": null, "host_name": null, "key_id": null, "access_key": null }, "pages": { "enabled": true },
- "collectd": { "enabled": false, "server": "", "port": "", "encryption": "", "username": "foo", "password":
- "bar" } }, "run_list": [ "role[configure]" ] }';
- $expectedArray = json_decode($expectedJson, true);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/setup/api/settings', ['license_md5' => $this->getLicenseHash()])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->settings($this->getLicenseHash()));
- }
-
- /**
- * @test
- */
- public function shouldShowMaintenanceStatus()
- {
- $expectedJson = '{ "status": "scheduled", "scheduled_time": "Tuesday, January 22 at 15 => 34 -0800",
- "connection_services": [ { "name": "git operations", "number": 0 }, { "name": "mysql queries", "number": 233 },
- { "name": "resque jobs", "number": 54 } ] }';
- $expectedArray = json_decode($expectedJson, true);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/setup/api/maintenance', ['license_md5' => $this->getLicenseHash()])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->maintenance($this->getLicenseHash()));
- }
-
- /**
- * @test
- */
- public function shouldShowAuthorizedKeys()
- {
- $expectedJson = '[ { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print":
- "ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" },
- { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print":
- "ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" } ]';
- $expectedArray = json_decode($expectedJson, true);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/setup/api/settings/authorized-keys', ['license_md5' => $this->getLicenseHash()])
- ->will($this->returnValue($expectedArray));
- $this->assertEquals($expectedArray, $api->keys($this->getLicenseHash()));
- }
-
- protected function getLicenseHash()
- {
- return '1234567890abcdefghijklmnopqrstuv';
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Enterprise\ManagementConsole::class;
- }
-}
diff --git a/test/Github/Tests/Api/Enterprise/SecretScanningTest.php b/test/Github/Tests/Api/Enterprise/SecretScanningTest.php
deleted file mode 100644
index cc5b14b6547..00000000000
--- a/test/Github/Tests/Api/Enterprise/SecretScanningTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
- 1, 'state' => 'resolved', 'resolution' => 'false_positive'],
- ['number' => 2, 'state' => 'open', 'resolution' => null],
- ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'],
- ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'],
- ];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/enterprises/KnpLabs/secret-scanning/alerts')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->alerts('KnpLabs', [
- 'state' => 'all',
- ]));
- }
-
- protected function getApiClass()
- {
- return \Github\Api\Enterprise\SecretScanning::class;
- }
-}
diff --git a/test/Github/Tests/Api/Enterprise/StatsTest.php b/test/Github/Tests/Api/Enterprise/StatsTest.php
deleted file mode 100644
index f97060e0a14..00000000000
--- a/test/Github/Tests/Api/Enterprise/StatsTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-getStatsData();
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/enterprise/stats/all')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('all'));
- }
-
- /**
- * @test
- *
- * @dataProvider getTypes
- */
- public function shouldShowStatsByType($type)
- {
- $expectedArray = $this->getStatsData($type);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with(sprintf('/enterprise/stats/%s', $type))
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, call_user_func([$api, $type]));
- }
-
- /**
- * @return array
- */
- public function getTypes()
- {
- return [
- ['issues'],
- ['hooks'],
- ['milestones'],
- ['orgs'],
- ['comments'],
- ['pages'],
- ['users'],
- ['gists'],
- ['pulls'],
- ['repos'],
- ['all'],
- ];
- }
-
- /**
- * @param string $key
- *
- * @return mixed
- */
- protected function getStatsData($key = '')
- {
- $json = '{"repos":{"total_repos": 212, "root_repos": 194, "fork_repos": 18, "org_repos": 51,
- "total_pushes": 3082, "total_wikis": 15 }, "hooks": { "total_hooks": 27, "active_hooks": 23,
- "inactive_hooks": 4 }, "pages": { "total_pages": 36 }, "orgs": { "total_orgs": 33, "disabled_orgs": 0,
- "total_teams": 60, "total_team_members": 314 }, "users": { "total_users": 254, "admin_users": 45,
- "suspended_users": 21 }, "pulls": { "total_pulls": 86, "merged_pulls": 60, "mergeable_pulls": 21,
- "unmergeable_pulls": 3 }, "issues": { "total_issues": 179, "open_issues": 83, "closed_issues": 96 },
- "milestones": { "total_milestones": 7, "open_milestones": 6, "closed_milestones": 1 }, "gists":
- { "total_gists": 178, "private_gists": 151, "public_gists": 25 }, "comments": { "total_commit_comments": 6,
- "total_gist_comments": 28, "total_issue_comments": 366, "total_pull_request_comments": 30 } }';
- $stats = json_decode($json, true);
- if (is_null($key)) {
- return $stats;
- } elseif (array_key_exists($key, $stats)) {
- return $stats[$key];
- }
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Enterprise\Stats::class;
- }
-}
diff --git a/test/Github/Tests/Api/Enterprise/UserAdminTest.php b/test/Github/Tests/Api/Enterprise/UserAdminTest.php
deleted file mode 100644
index 37b97a43447..00000000000
--- a/test/Github/Tests/Api/Enterprise/UserAdminTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/users/l3l0/suspended')
- ->will($this->returnValue($expectedArray));
- $this->assertEquals($expectedArray, $api->suspend('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldUnsuspendUser()
- {
- $expectedArray = [];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/users/l3l0/suspended')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->unsuspend('l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Enterprise\UserAdmin::class;
- }
-}
diff --git a/test/Github/Tests/Api/EnterpriseTest.php b/test/Github/Tests/Api/EnterpriseTest.php
deleted file mode 100644
index eb69b8e05d0..00000000000
--- a/test/Github/Tests/Api/EnterpriseTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Enterprise\Stats::class, $api->stats());
- }
-
- /**
- * @test
- */
- public function shouldGetEnterpriseLicenseApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Enterprise\License::class, $api->license());
- }
-
- /**
- * @test
- */
- public function shouldGetEnterpriseManagementConsoleApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Enterprise\ManagementConsole::class, $api->console());
- }
-
- /**
- * @test
- */
- public function shouldGetEnterpriseUserAdminApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Enterprise\UserAdmin::class, $api->userAdmin());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Enterprise::class;
- }
-}
diff --git a/test/Github/Tests/Api/Environment/SecretsTest.php b/test/Github/Tests/Api/Environment/SecretsTest.php
deleted file mode 100644
index 0609a64f0f6..00000000000
--- a/test/Github/Tests/Api/Environment/SecretsTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
- 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repositories/3948501/environments/production/secrets')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all(3948501, 'production'));
- }
-
- /**
- * @test
- */
- public function shouldGetEnvironmentSecret()
- {
- $expectedArray = [];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repositories/3948501/environments/production/secrets/secretName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show(3948501, 'production', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateOrCreateEnvironmentSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repositories/3948501/environments/production/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->createOrUpdate(3948501, 'production', 'secretName', [
- 'encrypted_value' => 'foo', 'key_id' => 'key_id',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveEnvironmentSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repositories/3948501/environments/production/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove(3948501, 'production', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldGetPublicKey()
- {
- $expectedArray = ['key_id' => 'key_id', 'key' => 'foo'];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repositories/3948501/environments/production/secrets/public-key')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->publicKey(3948501, 'production'));
- }
-
- protected function getApiClass()
- {
- return Secrets::class;
- }
-}
diff --git a/test/Github/Tests/Api/Environment/VariablesTest.php b/test/Github/Tests/Api/Environment/VariablesTest.php
deleted file mode 100644
index 0fc01193fd1..00000000000
--- a/test/Github/Tests/Api/Environment/VariablesTest.php
+++ /dev/null
@@ -1,118 +0,0 @@
- 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repositories/3948501/environments/production/variables')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all(3948501, 'production'));
- }
-
- /**
- * @test
- */
- public function shouldGetEnvironmentVariable()
- {
- $expectedArray = [];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repositories/3948501/environments/production/variables/variableName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show(3948501, 'production', 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldCreateEnvironmentVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repositories/3948501/environments/production/variables')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create(3948501, 'production', [
- 'name' => 'foo', 'value' => 'bar',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldUpdateEnvironmentVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('patch')
- ->with('/repositories/3948501/environments/production/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update(3948501, 'production', 'variableName', [
- 'name' => 'variableName', 'value' => 'bar',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveEnvironmentVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repositories/3948501/environments/production/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove(3948501, 'production', 'variableName'));
- }
-
- protected function getApiClass()
- {
- return Variables::class;
- }
-}
diff --git a/test/Github/Tests/Api/Gist/CommentsTest.php b/test/Github/Tests/Api/Gist/CommentsTest.php
deleted file mode 100644
index 9f0b88fda9e..00000000000
--- a/test/Github/Tests/Api/Gist/CommentsTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/comments')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('123'));
- }
-
- /**
- * @test
- */
- public function shouldShowGistComment()
- {
- $expectedValue = ['comment1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/comments/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show(123, 123));
- }
-
- /**
- * @test
- */
- public function shouldCreateGistComment()
- {
- $expectedValue = ['comment1data'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/gists/123/comments', ['body' => 'Test body'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('123', 'Test body'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateGistComment()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'body test'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/gists/123/comments/233', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update(123, 233, 'body test'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveComment()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/gists/123/comments/233')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove(123, 233));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Gist\Comments::class;
- }
-}
diff --git a/test/Github/Tests/Api/GistsTest.php b/test/Github/Tests/Api/GistsTest.php
deleted file mode 100644
index ff4673e4082..00000000000
--- a/test/Github/Tests/Api/GistsTest.php
+++ /dev/null
@@ -1,266 +0,0 @@
- '123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/starred')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('starred'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllGists()
- {
- $expectedArray = [['id' => '123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldShowGist()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show(123));
- }
-
- /**
- * @test
- */
- public function shouldShowGistWithSpecificReference()
- {
- $expectedArray = ['id' => '123', 'sha' => 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/d189dbd4c5d96442db74ebcb62bb38e661a0c8ce')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->revision(123, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'));
- }
-
- /**
- * @test
- */
- public function shouldShowCommits()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/commits')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->commits(123));
- }
-
- /**
- * @test
- */
- public function shouldGetCommentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Gist\Comments::class, $api->comments());
- }
-
- /**
- * @test
- */
- public function shouldForkGist()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/gists/123/fork')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->fork(123));
- }
-
- /**
- * @test
- */
- public function shouldListGistForks()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/forks')
- ->will($this->returnValue($expectedArray));
-
- $api->forks(123);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateGistWithoutFile()
- {
- $this->expectException(MissingArgumentException::class);
- $input = [
- 'description' => '',
- 'public' => false,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create($input);
- }
-
- /**
- * @test
- */
- public function shouldCheckGist()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gists/123/star')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->check(123));
- }
-
- /**
- * @test
- */
- public function shouldStarGist()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/gists/123/star')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->star(123));
- }
-
- /**
- * @test
- */
- public function shouldUnstarGist()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/gists/123/star')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->unstar(123));
- }
-
- /**
- * @test
- */
- public function shouldCreateAnonymousGist()
- {
- $input = [
- 'description' => '',
- 'public' => false,
- 'files' => [
- 'filename.txt' => [
- 'content' => 'content',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/gists', $input);
-
- $api->create($input);
- }
-
- /**
- * @test
- */
- public function shouldUpdateGist()
- {
- $input = [
- 'description' => 'jimbo',
- 'files' => [
- 'filename.txt' => [
- 'filename' => 'new_name.txt',
- 'content' => 'content',
- ],
- 'filename_new.txt' => [
- 'content' => 'content new',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/gists/5', $input);
-
- $api->update(5, $input);
- }
-
- /**
- * @test
- */
- public function shouldDeleteGist()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/gists/5');
-
- $api->remove(5);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Gists::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitData/BlobsTest.php b/test/Github/Tests/Api/GitData/BlobsTest.php
deleted file mode 100644
index 4b87ed33e41..00000000000
--- a/test/Github/Tests/Api/GitData/BlobsTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
- '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 = ['blob' => 'some data'];
-
- $client = $this->getMockBuilder('Github\Client')
- ->disableOriginalConstructor()
- ->getMock();
-
- $api = $this->getMockBuilder($this->getApiClass())
- ->setMethods(['configure', 'get'])
- ->setConstructorArgs([$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 = ['blob' => 'some data'];
- $data = ['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
- */
- public function shouldNotCreateBlobWithoutContent()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['encoding' => 'utf8'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('l3l0', 'l3l0repo', $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData\Blobs::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitData/CommitsTest.php b/test/Github/Tests/Api/GitData/CommitsTest.php
deleted file mode 100644
index 20903f3e1f2..00000000000
--- a/test/Github/Tests/Api/GitData/CommitsTest.php
+++ /dev/null
@@ -1,95 +0,0 @@
- '123', 'comitter'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/git/commits/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldCreateCommit()
- {
- $expectedValue = ['sha' => '123', 'comitter'];
- $data = ['message' => 'some message', 'tree' => 1234, 'parents' => []];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/git/commits', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateCommitWithoutMessageParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['tree' => 1234, 'parents' => []];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateCommitWithoutTreeParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['message' => 'some message', 'parents' => []];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateCommitWithoutParentsParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['message' => 'some message', 'tree' => '12334'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData\Commits::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitData/ReferencesTest.php b/test/Github/Tests/Api/GitData/ReferencesTest.php
deleted file mode 100644
index 70f17cde1d8..00000000000
--- a/test/Github/Tests/Api/GitData/ReferencesTest.php
+++ /dev/null
@@ -1,208 +0,0 @@
- 'some data'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/refs/master/some%2A%26%40%23branch/dasd1212')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', 'master/some*&@#branch/dasd1212'));
- }
-
- /**
- * @test
- */
- public function shouldShowReference()
- {
- $expectedValue = ['reference' => 'some data'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/refs/123456sha')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveReference()
- {
- $expectedValue = ['reference' => 'some data'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/l3l0/l3l0repo/git/refs/123456sha')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('l3l0', 'l3l0repo', '123456sha'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepoReferences()
- {
- $expectedValue = [['reference' => 'some data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/refs')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('l3l0', 'l3l0repo'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllMatchingReferences()
- {
- $expectedValue = [['reference' => 'some data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/matching-refs/heads/refName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->matching('l3l0', 'l3l0repo', 'heads/refName'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepoBranches()
- {
- $expectedValue = [['branch' => 'some data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/refs/heads')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->branches('l3l0', 'l3l0repo'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepoTags()
- {
- $expectedValue = [['tag' => 'some data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/l3l0/l3l0repo/git/refs/tags')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->tags('l3l0', 'l3l0repo'));
- }
-
- /**
- * @test
- */
- public function shouldCreateReference()
- {
- $expectedValue = ['reference' => 'some data'];
- $data = ['ref' => '122', 'sha' => '1234'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/l3l0/l3l0repo/git/refs', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('l3l0', 'l3l0repo', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReferenceWithoutShaParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['ref' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('l3l0', 'l3l0repo', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReferenceWithoutRefsParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['sha' => '1234'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('l3l0', 'l3l0repo', $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateReference()
- {
- $expectedValue = ['reference' => 'some data'];
- $data = ['sha' => '12345sha'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/l3l0/l3l0repo/git/refs/someRefs', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('l3l0', 'l3l0repo', 'someRefs', $data));
- }
-
- /**
- * @test
- */
- public function shouldNoUpdateReferenceWithoutSha()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('l3l0', 'l3l0repo', 'someRefs', $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData\References::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitData/TagsTest.php b/test/Github/Tests/Api/GitData/TagsTest.php
deleted file mode 100644
index 83230175554..00000000000
--- a/test/Github/Tests/Api/GitData/TagsTest.php
+++ /dev/null
@@ -1,263 +0,0 @@
- '123', 'comitter'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/git/tags/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldGetAllTags()
- {
- $expectedValue = [['sha' => '123', 'tagger']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/git/refs/tags')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldCreateTag()
- {
- $expectedValue = ['sha' => '123', 'comitter'];
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/git/tags', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutMessageParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateTagWithoutTaggerParam()
- {
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutTaggerNameParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutTaggerEmailParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutTaggerDateParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutTagParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'object' => 'test',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutObjectParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'type' => 'unsigned',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTagWithoutTypeParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'message' => 'some message',
- 'tag' => 'v2.2',
- 'object' => 'test',
- 'tagger' => [
- 'name' => 'l3l0',
- 'email' => 'leszek.prabucki@gmail.com',
- 'date' => date('Y-m-d H:i:s'),
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData\Tags::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitData/TreesTest.php b/test/Github/Tests/Api/GitData/TreesTest.php
deleted file mode 100644
index 0b415f1fb1c..00000000000
--- a/test/Github/Tests/Api/GitData/TreesTest.php
+++ /dev/null
@@ -1,213 +0,0 @@
- '123', 'comitter'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/git/trees/123', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldCreateTreeUsingSha()
- {
- $expectedValue = ['sha' => '123', 'comitter'];
- $data = [
- 'tree' => [
- [
- 'path' => 'path',
- 'mode' => 'mode',
- 'type' => 'type',
- 'sha' => '1234',
- ],
- [
- 'path' => 'htap',
- 'mode' => 'edom',
- 'type' => 'epyt',
- 'sha' => '4321',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/git/trees', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldCreateTreeUsingContent()
- {
- $expectedValue = ['sha' => '123', 'comitter'];
- $data = [
- 'tree' => [
- [
- 'path' => 'path',
- 'mode' => 'mode',
- 'type' => 'type',
- 'content' => 'content',
- ],
- [
- 'path' => 'htap',
- 'mode' => 'edom',
- 'type' => 'epyt',
- 'content' => 'tnetnoc',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/git/trees', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWithoutShaAndContentParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tree' => [
- 'path' => 'path',
- 'mode' => 'mode',
- 'type' => 'type',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWithoutPathParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tree' => [
- 'mode' => 'mode',
- 'type' => 'type',
- 'content' => 'content',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWithoutModeParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tree' => [
- 'path' => 'path',
- 'type' => 'type',
- 'content' => 'content',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWithoutTypeParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tree' => [
- 'path' => 'path',
- 'mode' => 'mode',
- 'content' => 'content',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWithoutTreeParam()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTreeWhenTreeParamIsNotArray()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'tree' => '',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData\Trees::class;
- }
-}
diff --git a/test/Github/Tests/Api/GitDataTest.php b/test/Github/Tests/Api/GitDataTest.php
deleted file mode 100644
index 4c25936b994..00000000000
--- a/test/Github/Tests/Api/GitDataTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-getApiMock();
-
- $this->assertInstanceOf(\Github\Api\GitData\Blobs::class, $api->blobs());
- }
-
- /**
- * @test
- */
- public function shouldGetCommitsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\GitData\Commits::class, $api->commits());
- }
-
- /**
- * @test
- */
- public function shouldGetReferencesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\GitData\References::class, $api->references());
- }
-
- /**
- * @test
- */
- public function shouldGetTagsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\GitData\Tags::class, $api->tags());
- }
-
- /**
- * @test
- */
- public function shouldGetTreesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\GitData\Trees::class, $api->trees());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\GitData::class;
- }
-}
diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php
deleted file mode 100644
index b241cc5ae90..00000000000
--- a/test/Github/Tests/Api/GraphQLTest.php
+++ /dev/null
@@ -1,58 +0,0 @@
-getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with($this->equalTo('/graphql'), $this->equalTo(['query' => 'bar']))
- ->will($this->returnValue('foo'));
-
- $result = $api->execute('bar');
- $this->assertEquals('foo', $result);
- }
-
- /**
- * @test
- */
- public function shouldSupportGraphQLVariables()
- {
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with('/graphql', $this->arrayHasKey('variables'));
-
- $api->execute('bar', ['variable' => 'foo']);
- }
-
- /**
- * @test
- */
- public function shouldJSONEncodeGraphQLVariables()
- {
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with('/graphql', $this->equalTo([
- 'query' => 'bar',
- 'variables' => '{"variable":"foo"}',
- ]));
-
- $api->execute('bar', ['variable' => 'foo']);
- }
-
- protected function getApiClass()
- {
- return \Github\Api\GraphQL::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/AssigneesTest.php b/test/Github/Tests/Api/Issue/AssigneesTest.php
deleted file mode 100644
index b6939a1b59e..00000000000
--- a/test/Github/Tests/Api/Issue/AssigneesTest.php
+++ /dev/null
@@ -1,108 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/assignees');
-
- $api->listAvailable('knplabs', 'php-github-api');
- }
-
- /**
- * @test
- */
- public function shouldCheckAssignee()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/assignees/test-user');
-
- $api->check('knplabs', 'php-github-api', 'test-user');
- }
-
- /**
- * @test
- */
- public function shouldNotAddAssigneeMissingParameter()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->add('knplabs', 'php-github-api', 4, $data);
- }
-
- /**
- * @test
- */
- public function shouldAddAssignee()
- {
- $data = [
- 'assignees' => ['test-user'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/knplabs/php-github-api/issues/4/assignees', $data);
-
- $api->add('knplabs', 'php-github-api', 4, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotRemoveAssigneeMissingParameter()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('delete');
-
- $api->remove('knplabs', 'php-github-api', 4, $data);
- }
-
- /**
- * @test
- */
- public function shouldRemoveAssignee()
- {
- $data = [
- 'assignees' => ['test-user'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/knplabs/php-github-api/issues/4/assignees', $data);
-
- $api->remove('knplabs', 'php-github-api', 4, $data);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return Assignees::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/CommentsTest.php b/test/Github/Tests/Api/Issue/CommentsTest.php
deleted file mode 100644
index 3a8db85a922..00000000000
--- a/test/Github/Tests/Api/Issue/CommentsTest.php
+++ /dev/null
@@ -1,147 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/123/comments', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldGetAllIssueCommentsBySpecifyParameters()
- {
- $expectedValue = [['comment1data'], ['comment2data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/123/comments', ['since' => '1990-08-03T00:00:00Z'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123, [
- 'since' => '1990-08-03T00:00:00Z',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldShowIssueComment()
- {
- $expectedValue = ['comment1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/comments/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', '123', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateIssueComment()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'test body'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/issues/123/comments', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', '123', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['somedata'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('KnpLabs', 'php-github-api', '123', $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateIssueComment()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'body test'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/issues/comments/233', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', '233', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveComment()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/issues/comments/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue\Comments::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/EventsTest.php b/test/Github/Tests/Api/Issue/EventsTest.php
deleted file mode 100644
index 37139936c63..00000000000
--- a/test/Github/Tests/Api/Issue/EventsTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/events', ['page' => 1])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetIssueEvents()
- {
- $expectedValue = [['event1data'], ['event2data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/123/events', ['page' => 1])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldShowIssueEvent()
- {
- $expectedValue = ['event1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/events/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue\Events::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/LabelsTest.php b/test/Github/Tests/Api/Issue/LabelsTest.php
deleted file mode 100644
index ec55ccc54cb..00000000000
--- a/test/Github/Tests/Api/Issue/LabelsTest.php
+++ /dev/null
@@ -1,229 +0,0 @@
- 'l3l0repo'],
- ['name' => 'other'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/labels', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllIssueLabels()
- {
- $expectedValue = [['name' => 'label']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', '123'));
- }
-
- /**
- * @test
- */
- public function shouldCreateLabel()
- {
- $expectedValue = [['name' => 'label', 'color' => 'FFFFFF']];
- $data = ['name' => 'label'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/labels', $data + ['color' => 'FFFFFF'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldGetSingleLabel()
- {
- $expectedValue = [['name' => 'label1']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/labels/label1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'label1'));
- }
-
- /**
- * @test
- */
- public function shouldCreateLabelWithColor()
- {
- $expectedValue = [['name' => 'label', 'color' => '111111']];
- $data = ['name' => 'label', 'color' => '111111'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/labels', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldDeleteLabel()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/labels/foo')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->deleteLabel('KnpLabs', 'php-github-api', 'foo'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateLabel()
- {
- $expectedValue = [['name' => 'bar', 'color' => 'FFF']];
- $data = ['name' => 'bar', 'color' => 'FFF'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/labels/foo', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'foo', 'bar', 'FFF'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveLabel()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels/somename')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123, 'somename'));
- }
-
- /**
- * @test
- */
- public function shouldAddOneLabel()
- {
- $expectedValue = ['label' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, 'labelname'));
- }
-
- /**
- * @test
- */
- public function shouldAddManyLabels()
- {
- $expectedValue = ['label' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname', 'labelname2'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, ['labelname', 'labelname2']));
- }
-
- /**
- * @test
- */
- public function shouldReplaceLabels()
- {
- $expectedValue = [['label' => 'somename']];
- $data = ['labels' => ['labelname']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->replace('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotAddWhenDoNotHaveLabelsToAdd()
- {
- $this->expectException(InvalidArgumentException::class);
- $api = $this->getApiMock();
- $api->expects($this->any())
- ->method('post');
-
- $api->add('KnpLabs', 'php-github-api', 123, []);
- }
-
- /**
- * @test
- */
- public function shouldClearLabels()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/issues/123/labels')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->clear('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue\Labels::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/MilestonesTest.php b/test/Github/Tests/Api/Issue/MilestonesTest.php
deleted file mode 100644
index 6a1996e0bbc..00000000000
--- a/test/Github/Tests/Api/Issue/MilestonesTest.php
+++ /dev/null
@@ -1,229 +0,0 @@
- 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldCreateMilestone()
- {
- $expectedValue = [['title' => 'milestone']];
- $data = ['title' => 'milestone'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/milestones', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateMilestoneWithoutTitle()
- {
- $this->expectException(MissingArgumentException::class);
- $expectedValue = [['title' => 'milestone']];
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldSetStateToOpenWhileCreationWhenStateParamNotRecognized()
- {
- $expectedValue = ['title' => 'l3l0repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/milestones', ['state' => 'open', 'title' => 'milestone'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', ['state' => 'clos', 'title' => 'milestone']));
- }
-
- /**
- * @test
- */
- public function shouldUpdateMilestone()
- {
- $expectedValue = [['title' => 'milestone']];
- $data = ['title' => 'milestone'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/milestones/123', ['title' => 'milestone'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldUpdateMilestoneWithClosedStatus()
- {
- $expectedValue = [['title' => 'milestone']];
- $data = ['title' => 'milestone', 'status' => 'closed'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/milestones/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldSetStateToOpenWhileUpdateWhenStateParamNotRecognized()
- {
- $expectedValue = ['title' => 'l3l0repo'];
- $data = ['title' => 'milestone', 'state' => 'some'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/milestones/123', ['state' => 'open', 'title' => 'milestone'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldSortByDueDateWhenSortParamNotRecognized()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'completenes']));
- }
-
- /**
- * @test
- */
- public function shouldSetStateToOpenWhenStateParamNotRecognized()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['state' => 'clos']));
- }
-
- /**
- * @test
- */
- public function shouldSetDirectionToDescWhenDirectionParamNotRecognized()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['direction' => 'asc']));
- }
-
- /**
- * @test
- */
- public function shouldRemoveMilestones()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/milestones/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldShowMilestone()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldGetMilestoneLabels()
- {
- $expectedValue = [['label'], ['label2']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones/123/labels')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->labels('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue\Milestones::class;
- }
-}
diff --git a/test/Github/Tests/Api/Issue/TimelineTest.php b/test/Github/Tests/Api/Issue/TimelineTest.php
deleted file mode 100644
index 401219af32b..00000000000
--- a/test/Github/Tests/Api/Issue/TimelineTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/issues/123/timeline', [])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue\Timeline::class;
- }
-}
diff --git a/test/Github/Tests/Api/IssueTest.php b/test/Github/Tests/Api/IssueTest.php
deleted file mode 100644
index a151076ce1f..00000000000
--- a/test/Github/Tests/Api/IssueTest.php
+++ /dev/null
@@ -1,246 +0,0 @@
- 'open',
- ];
- $sentData = $data + [
- 'page' => 1,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ornicar/php-github-api/issues', $sentData);
-
- $api->all('ornicar', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldGetIssuesUsingAdditionalParameters()
- {
- $expectedArray = [['id' => '123']];
- $data = [
- 'state' => 'open',
- 'milestone' => '*',
- 'assignee' => 'l3l0',
- 'mentioned' => 'l3l0',
- 'labels' => 'bug,@high',
- 'sort' => 'created',
- 'direction' => 'asc',
- ];
- $sentData = $data + [
- 'page' => 1,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ornicar/php-github-api/issues', $sentData)
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('ornicar', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldShowIssue()
- {
- $expectedArray = ['id' => '123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ornicar/php-github-api/issues/14')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('ornicar', 'php-github-api', 14));
- }
-
- /**
- * @test
- */
- public function shouldCreateIssue()
- {
- $data = [
- 'title' => 'some title',
- 'body' => 'some body',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/ornicar/php-github-api/issues', $data);
-
- $api->create('ornicar', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateIssueWithoutTitle()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'body' => 'some body',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('ornicar', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateIssueWithoutBody()
- {
- $data = [
- 'title' => 'some title',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/ornicar/php-github-api/issues', $data);
-
- $api->create('ornicar', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCloseIssue()
- {
- $data = [
- 'state' => 'closed',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/ornicar/php-github-api/issues/14', $data);
-
- $api->update('ornicar', 'php-github-api', 14, $data);
- }
-
- /**
- * @test
- */
- public function shouldReOpenIssue()
- {
- $data = [
- 'state' => 'open',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/ornicar/php-github-api/issues/14', $data);
-
- $api->update('ornicar', 'php-github-api', 14, $data);
- }
-
- /**
- * @test
- */
- public function shouldGetCommentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Issue\Comments::class, $api->comments());
- }
-
- /**
- * @test
- */
- public function shouldGetEventsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Issue\Events::class, $api->events());
- }
-
- /**
- * @test
- */
- public function shouldGetLabelsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Issue\Labels::class, $api->labels());
- }
-
- /**
- * @test
- */
- public function shouldGetMilestonesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Issue\Milestones::class, $api->milestones());
- }
-
- /**
- * @test
- */
- public function shouldGetTimelineApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Issue\Timeline::class, $api->timeline());
- }
-
- /**
- * @test
- */
- public function shouldLockIssue()
- {
- $parameters = [];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/knplabs/php-github-api/issues/1/lock', $parameters);
-
- $api->lock('knplabs', 'php-github-api', '1');
- }
-
- /**
- * @test
- */
- public function shouldUnlockIssue()
- {
- $parameters = [];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/knplabs/php-github-api/issues/1/lock', $parameters);
-
- $api->unlock('knplabs', 'php-github-api', '1');
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Issue::class;
- }
-}
diff --git a/test/Github/Tests/Api/MetaTest.php b/test/Github/Tests/Api/MetaTest.php
deleted file mode 100644
index 9275e5a1f1b..00000000000
--- a/test/Github/Tests/Api/MetaTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
- [
- '127.0.0.1/32',
- ],
- 'git' => [
- '127.0.0.1/32',
- ],
- 'verifiable_password_authentication' => true,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->service());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Meta::class;
- }
-}
diff --git a/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php b/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php
deleted file mode 100644
index 0e07dea5752..00000000000
--- a/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
- 'CoC1'],
- ['name' => 'CoC2'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/codes_of_conduct')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetSingleCodeOfConducts()
- {
- $expectedArray = [
- 'name' => 'CoC',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/codes_of_conduct/contributor_covenant')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('contributor_covenant'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return CodeOfConduct::class;
- }
-}
diff --git a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php b/test/Github/Tests/Api/Miscellaneous/EmojisTest.php
deleted file mode 100644
index b4408b80aa1..00000000000
--- a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
- 'https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5',
- '-1' => 'https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/emojis')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return Emojis::class;
- }
-}
diff --git a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php b/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php
deleted file mode 100644
index 6a244adaef5..00000000000
--- a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gitignore/templates')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetTemplate()
- {
- $expectedArray = [
- 'name' => 'C',
- 'source' => "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a",
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/gitignore/templates/C')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('C'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return Gitignore::class;
- }
-}
diff --git a/test/Github/Tests/Api/Miscellaneous/LicensesTest.php b/test/Github/Tests/Api/Miscellaneous/LicensesTest.php
deleted file mode 100644
index ed504c9b4aa..00000000000
--- a/test/Github/Tests/Api/Miscellaneous/LicensesTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
- 'mit'],
- ['key' => 'apache-2.0'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/licenses')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetSingleLicenses()
- {
- $expectedArray = [
- 'key' => 'gpl-2.0',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/licenses/gpl-2.0')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('gpl-2.0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return Licenses::class;
- }
-}
diff --git a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php b/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php
deleted file mode 100644
index b327a1b83c8..00000000000
--- a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/markdown', ['text' => $input, 'mode' => 'markdown']);
-
- $api->render($input);
- }
-
- /**
- * @test
- */
- public function shouldRenderMarkdownUsingGfmMode()
- {
- $input = 'Hello world github/linguist#1 **cool**, and #1!';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/markdown', ['text' => $input, 'mode' => 'gfm']);
-
- $api->render($input, 'gfm');
- }
-
- /**
- * @test
- */
- public function shouldSetModeToMarkdownWhenIsNotRecognized()
- {
- $input = 'Hello world github/linguist#1 **cool**, and #1!';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/markdown', ['text' => $input, 'mode' => 'markdown']);
-
- $api->render($input, 'abc');
- }
-
- /**
- * @test
- */
- public function shouldSetContextOnlyForGfmMode()
- {
- $input = 'Hello world github/linguist#1 **cool**, and #1!';
-
- $apiWithMarkdown = $this->getApiMock();
- $apiWithMarkdown->expects($this->once())
- ->method('post')
- ->with('/markdown', ['text' => $input, 'mode' => 'markdown']);
-
- $apiWithGfm = $this->getApiMock();
- $apiWithGfm->expects($this->once())
- ->method('post')
- ->with('/markdown', ['text' => $input, 'mode' => 'gfm', 'context' => 'someContext']);
-
- $apiWithMarkdown->render($input, 'markdown', 'someContext');
- $apiWithGfm->render($input, 'gfm', 'someContext');
- }
-
- /**
- * @test
- */
- public function shouldRenderRawFile()
- {
- $file = 'file';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/markdown/raw', ['file' => $file]);
-
- $api->renderRaw($file);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Markdown::class;
- }
-}
diff --git a/test/Github/Tests/Api/NotificationTest.php b/test/Github/Tests/Api/NotificationTest.php
deleted file mode 100644
index 7ef3e64ba45..00000000000
--- a/test/Github/Tests/Api/NotificationTest.php
+++ /dev/null
@@ -1,153 +0,0 @@
- false,
- 'participating' => false,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/notifications', $parameters);
-
- $api->all();
- }
-
- /**
- * @test
- */
- public function shouldGetNotificationsSince()
- {
- $since = new DateTime('now');
-
- $parameters = [
- 'all' => false,
- 'participating' => false,
- 'since' => $since->format(DateTime::ISO8601),
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/notifications', $parameters);
-
- $api->all(false, false, $since);
- }
-
- /**
- * @test
- */
- public function shouldGetNotificationsBefore()
- {
- $before = new DateTime('now');
-
- $parameters = [
- 'all' => false,
- 'participating' => false,
- 'before' => $before->format(DateTime::ISO8601),
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/notifications', $parameters);
-
- $api->all(false, false, null, $before);
- }
-
- /**
- * @test
- */
- public function shouldGetNotificationsIncludingAndParticipating()
- {
- $parameters = [
- 'all' => true,
- 'participating' => true,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/notifications', $parameters);
-
- $api->all(true, true);
- }
-
- /**
- * @test
- */
- public function shouldMarkNotificationsAsRead()
- {
- $parameters = [];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/notifications', $parameters);
-
- $api->markRead();
- }
-
- /**
- * @test
- */
- public function shouldMarkNotificationsAsReadForGivenDate()
- {
- $since = new DateTime('now');
-
- $parameters = [
- 'last_read_at' => $since->format(DateTime::ISO8601),
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/notifications', $parameters);
-
- $api->markRead($since);
- }
-
- /**
- * @test
- */
- public function shouldMarkThreadAsRead()
- {
- $id = mt_rand(1, time());
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/notifications/threads/'.$id);
-
- $api->markThreadRead($id);
- }
-
- public function shouldGetNotification()
- {
- $id = mt_rand(1, time());
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/notification/'.$id);
-
- $api->id($id);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Notification::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/Actions/SecretsTest.php b/test/Github/Tests/Api/Organization/Actions/SecretsTest.php
deleted file mode 100644
index 324b706975d..00000000000
--- a/test/Github/Tests/Api/Organization/Actions/SecretsTest.php
+++ /dev/null
@@ -1,219 +0,0 @@
- 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'all'],
- ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'private'],
- ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'selected'],
- ];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/secrets')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetOrganizationSecret()
- {
- $expectedArray = [];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/secrets/secretName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldCreateOrganizationSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'secretName', [
- 'encrypted_value' => 'foo', 'visibility' => 'all', 'selected_repository_ids' => [1, 2, 3],
- ]));
- }
-
- /**
- * @test
- */
- public function shouldUpdateOrganizationSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'secretName', [
- 'key_id' => 'keyId',
- 'encrypted_value' => 'encryptedValue',
- 'visibility' => 'private',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveOrganizationSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldGetSelectedRepositories()
- {
- $expectedArray = [1, 2, 3];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->selectedRepositories('KnpLabs', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldSetSelectedRepositories()
- {
- $expectedArray = [
- 'selected_repository_ids' => [1, 2, 3],
- ];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->setSelectedRepositories('KnpLabs', 'secretName', [
- 'selected_repository_ids' => [1, 2, 3],
- ]));
- }
-
- /**
- * @test
- */
- public function shouldAddSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addSecret('KnpLabs', '1', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeSecret('KnpLabs', '1', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldGetPublicKey()
- {
- $expectedArray = ['key_id' => 'key_id', 'key' => 'foo'];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/secrets/public-key')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->publicKey('KnpLabs'));
- }
-
- protected function getApiClass()
- {
- return Secrets::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php b/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php
deleted file mode 100644
index e313a88202a..00000000000
--- a/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
- 1,
- 'name' => 'MBP',
- 'os' => 'macos',
- 'status' => 'online',
- ],
- [
- 'id' => 2,
- 'name' => 'iMac',
- 'os' => 'macos',
- 'status' => 'offline',
- ],
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/runners')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetSelfHostedRunner()
- {
- $expectedArray = [
- 'id' => 1,
- 'name' => 'MBP',
- 'os' => 'macos',
- 'status' => 'online',
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/runners/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 1));
- }
-
- /**
- * @test
- */
- public function shouldRemoveSelfHostedRunner()
- {
- $expectedValue = 'response';
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/actions/runners/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 1));
- }
-
- /**
- * @test
- */
- public function shouldGetSelfHostedRunnerApps()
- {
- $expectedArray = [
- ['os' => 'osx', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'arm', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'win', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'arm64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/runners/downloads')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->applications('KnpLabs'));
- }
-
- protected function getApiClass()
- {
- return SelfHostedRunners::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/Actions/VariablesTest.php b/test/Github/Tests/Api/Organization/Actions/VariablesTest.php
deleted file mode 100644
index 98d5072377e..00000000000
--- a/test/Github/Tests/Api/Organization/Actions/VariablesTest.php
+++ /dev/null
@@ -1,198 +0,0 @@
- 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'all'],
- ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'private'],
- ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'selected'],
- ];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/variables')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetOrganizationVariable()
- {
- $expectedArray = [];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/variables/variableName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldCreateOrganizationVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/actions/variables')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', [
- 'name' => 'foo', 'value' => 'value', 'visibility' => 'all',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldUpdateOrganizationVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('patch')
- ->with('/orgs/KnpLabs/actions/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'variableName', [
- 'name' => 'foo', 'value' => 'value', 'visibility' => 'private',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveOrganizationVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/actions/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldGetSelectedRepositories()
- {
- $expectedArray = [1, 2, 3];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/actions/variables/variableName/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->selectedRepositories('KnpLabs', 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldSetSelectedRepositories()
- {
- $expectedArray = [
- 'selected_repository_ids' => [1, 2, 3],
- ];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/variables/variableName/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->setSelectedRepositories('KnpLabs', 'variableName', [
- 'selected_repository_ids' => [1, 2, 3],
- ]));
- }
-
- /**
- * @test
- */
- public function shouldAddRepository()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/actions/variables/variableName/repositories/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addRepository('KnpLabs', 1, 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveRepository()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/actions/variables/variableName/repositories/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeRepository('KnpLabs', 1, 'variableName'));
- }
-
- protected function getApiClass()
- {
- return Variables::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/HooksTest.php b/test/Github/Tests/Api/Organization/HooksTest.php
deleted file mode 100644
index 82d586a087e..00000000000
--- a/test/Github/Tests/Api/Organization/HooksTest.php
+++ /dev/null
@@ -1,160 +0,0 @@
- 'hook']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/hooks')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldShowHook()
- {
- $expectedValue = ['hook' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/hooks/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 123));
- }
-
- /**
- * @test
- */
- public function shouldRemoveHook()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/hooks/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateHookWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['config' => 'conf'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateHookWithoutConfig()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['name' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateHook()
- {
- $expectedValue = ['hook' => 'somename'];
- $data = ['name' => 'test', 'config' => 'someconfig'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/hooks', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateHookWithoutConfig()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('KnpLabs', 123, $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateHook()
- {
- $expectedValue = ['hook' => 'somename'];
- $data = ['config' => 'config'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/orgs/KnpLabs/hooks/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldPingHook()
- {
- $expectedValue = null;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/hooks/123/pings')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->ping('KnpLabs', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization\Hooks::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/MembersTest.php b/test/Github/Tests/Api/Organization/MembersTest.php
deleted file mode 100644
index 58ff1ea3c08..00000000000
--- a/test/Github/Tests/Api/Organization/MembersTest.php
+++ /dev/null
@@ -1,144 +0,0 @@
- 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/members')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetPublicOrganizationMembers()
- {
- $expectedValue = [['username' => 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/public_members')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', true));
- }
-
- /**
- * @test
- */
- public function shouldCheckIfOrganizationMember()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/public_members/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->check('KnpLabs', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldAddOrganizationMember()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/memberships/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add('KnpLabs', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveOrganizationMember()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/members/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldPublicizeOrganizationMembership()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/public_members/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->publicize('KnpLabs', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldConcealOrganizationMembership()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/public_members/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->conceal('KnpLabs', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldShowOrganizationMember()
- {
- $expectedValue = ['username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/members/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization\Members::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/OrganizationRolesTest.php b/test/Github/Tests/Api/Organization/OrganizationRolesTest.php
deleted file mode 100644
index f2d801afceb..00000000000
--- a/test/Github/Tests/Api/Organization/OrganizationRolesTest.php
+++ /dev/null
@@ -1,187 +0,0 @@
- 1,
- 'roles' => [[
- 'id' => 1,
- 'name' => 'all_repo_admin',
- 'description' => 'Grants admin access to all repositories in the organization.',
- 'permissions' => [],
- 'organization' => null,
- 'created_at' => '2023-01-01T00:00:00Z',
- 'updated_at' => '2023-01-01T00:00:00Z',
- 'source' => 'Predefined',
- 'base_role' => 'admin',
- ]],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/acme/organization-roles')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('acme'));
- }
-
- /**
- * @test
- */
- public function shouldShowSingleOrganizationRole()
- {
- $expectedValue = [
- 'id' => 1,
- 'name' => 'all_repo_admin',
- 'description' => 'Grants admin access to all repositories in the organization.',
- 'permissions' => [],
- 'organization' => null,
- 'created_at' => '2023-01-01T00:00:00Z',
- 'updated_at' => '2023-01-01T00:00:00Z',
- 'source' => 'Predefined',
- 'base_role' => 'admin',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/acme/organization-roles/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('acme', 1));
- }
-
- /**
- * @test
- */
- public function shouldGetAllTeamsWithRole()
- {
- $expectedValue = [['name' => 'Acme Admins']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/acme/organization-roles/1/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->listTeamsWithRole('acme', 1));
- }
-
- /**
- * @test
- */
- public function shouldAssignRoleToTeam()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/acme/organization-roles/teams/acme-admins/1')
- ->will($this->returnValue(''));
-
- $api->assignRoleToTeam('acme', 1, 'acme-admins');
- }
-
- /**
- * @test
- */
- public function shouldRemoveRoleFromTeam()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/acme/organization-roles/teams/acme-admins/1')
- ->will($this->returnValue(''));
-
- $api->removeRoleFromTeam('acme', 1, 'acme-admins');
- }
-
- /**
- * @test
- */
- public function shouldRemoveAllRolesFromTeam()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/acme/organization-roles/teams/acme-admins')
- ->will($this->returnValue(''));
-
- $api->removeAllRolesFromTeam('acme', 'acme-admins');
- }
-
- /**
- * @test
- */
- public function shouldGetAllUsersWithRole()
- {
- $expectedValue = [['username' => 'Admin']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/acme/organization-roles/1/users')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->listUsersWithRole('acme', 1));
- }
-
- /**
- * @test
- */
- public function shouldAssignRoleToUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/acme/organization-roles/users/admin/1')
- ->will($this->returnValue(''));
-
- $api->assignRoleToUser('acme', 1, 'admin');
- }
-
- /**
- * @test
- */
- public function shouldRemoveRoleFromUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/acme/organization-roles/users/admin/1')
- ->will($this->returnValue(''));
-
- $api->removeRoleFromUser('acme', 1, 'admin');
- }
-
- /**
- * @test
- */
- public function shouldRemoveAllRolesFromUser()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/acme/organization-roles/users/admin')
- ->will($this->returnValue(''));
-
- $api->removeAllRolesFromUser('acme', 'admin');
- }
-
- protected function getApiClass(): string
- {
- return OrganizationRoles::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php b/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php
deleted file mode 100644
index eb74b266c09..00000000000
--- a/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
- 'KnpLabs']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/outside_collaborators')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldConvertAnOrganizationMemberToOutsideCollaborator()
- {
- $expectedValue = 'expectedResponse';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/outside_collaborators/username')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->convert('KnpLabs', 'username'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveAnOutsideCollaboratorFromAnOrganization()
- {
- $expectedValue = 'expectedResponse';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/outside_collaborators/username')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'username'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization\OutsideCollaborators::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/ProjectsTest.php b/test/Github/Tests/Api/Organization/ProjectsTest.php
deleted file mode 100644
index 05d607e34d8..00000000000
--- a/test/Github/Tests/Api/Organization/ProjectsTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
- 'Test project 1']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/projects')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateColumn()
- {
- $expectedValue = ['project1data'];
- $data = ['name' => 'Project 1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/projects', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization\Projects::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/SecretScanningTest.php b/test/Github/Tests/Api/Organization/SecretScanningTest.php
deleted file mode 100644
index 01b8f844007..00000000000
--- a/test/Github/Tests/Api/Organization/SecretScanningTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
- 1, 'state' => 'resolved', 'resolution' => 'false_positive'],
- ['number' => 2, 'state' => 'open', 'resolution' => null],
- ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'],
- ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'],
- ];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/secret-scanning/alerts')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->alerts('KnpLabs', [
- 'state' => 'all',
- ]));
- }
-
- protected function getApiClass()
- {
- return \Github\Api\Organization\SecretScanning::class;
- }
-}
diff --git a/test/Github/Tests/Api/Organization/TeamsTest.php b/test/Github/Tests/Api/Organization/TeamsTest.php
deleted file mode 100644
index 18b476986aa..00000000000
--- a/test/Github/Tests/Api/Organization/TeamsTest.php
+++ /dev/null
@@ -1,324 +0,0 @@
- 'KnpWorld'], ['name' => 'KnpFrance'], ['name' => 'KnpMontreal']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldCheckIfMemberIsInOrganizationTeam()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->check('KnpWorld', 'l3l0', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveOrganizationTeam()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/teams/KnpWorld')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpWorld', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldShowOrganizationTeam()
- {
- $expectedValue = ['username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/teams/KnpWorld')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpWorld', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetTeamMembers()
- {
- $expectedValue = [['username' => 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/teams/KnpWorld/members')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->members('KnpWorld', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldAddTeamMembers()
- {
- $expectedValue = ['username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addMember('KnpWorld', 'l3l0', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveTeamMembers()
- {
- $expectedValue = ['username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeMember('KnpWorld', 'l3l0', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetTeamRepositories()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/teams/KnpWorld/repos')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->repositories('KnpWorld', 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetTeamRepositoriesViaLegacy()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/teams/KnpWorld/repos')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->repositories('KnpWorld'));
- }
-
- /**
- * @test
- */
- public function shouldGetTeamRepository()
- {
- $expectedValue = ['name' => 'l3l0repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/teams/KnpWorld/repos/l3l0/l3l0Repo')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->repository('KnpWorld', 'l3l0', 'l3l0Repo'));
- }
-
- /**
- * @test
- */
- public function shouldAddTeamRepository()
- {
- $expectedValue = ['name' => 'l3l0repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/orgs/l3l0/teams/KnpWorld/repos/l3l0/l3l0Repo')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addRepository('KnpWorld', 'l3l0', 'l3l0Repo'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveTeamRepository()
- {
- $expectedValue = ['name' => 'l3l0repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/orgs/l3l0/teams/KnpWorld/repos/l3l0/l3l0Repo')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeRepository('KnpWorld', 'l3l0', 'l3l0Repo'));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateTeamWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateOrganizationTeam()
- {
- $expectedValue = ['name' => 'KnpWorld'];
- $data = ['name' => 'KnpWorld'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/teams', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', $data));
- }
-
- /**
- * @test
- */
- public function shouldCreateOrganizationTeamWithRepoName()
- {
- $expectedValue = ['name' => 'KnpWorld'];
- $data = ['name' => 'KnpWorld', 'repo_names' => 'somerepo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'repo_names' => ['somerepo']])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', $data));
- }
-
- /**
- * @test
- */
- public function shouldCreateWithPullPermissionWhenPermissionParamNotRecognized()
- {
- $expectedValue = ['name' => 'KnpWorld'];
- $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'permission' => 'pull'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateTeamWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('KnpWorld', $data, 'KnpLabs');
- }
-
- /**
- * @test
- */
- public function shouldUpdateOrganizationTeam()
- {
- $expectedValue = ['name' => 'KnpWorld'];
- $data = ['name' => 'KnpWorld'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/orgs/KnpLabs/teams/KnpWorld', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateWithPullPermissionWhenPermissionParamNotRecognized()
- {
- $expectedValue = ['name' => 'KnpWorld'];
- $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/orgs/KnpLabs/teams/KnpWorld', ['name' => 'KnpWorld', 'permission' => 'pull'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization\Teams::class;
- }
-}
diff --git a/test/Github/Tests/Api/OrganizationTest.php b/test/Github/Tests/Api/OrganizationTest.php
deleted file mode 100644
index 2b920662691..00000000000
--- a/test/Github/Tests/Api/OrganizationTest.php
+++ /dev/null
@@ -1,118 +0,0 @@
- 'KnpLabs']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/organizations?since=1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all(1));
- }
-
- /**
- * @test
- */
- public function shouldShowOrganization()
- {
- $expectedArray = ['id' => 1, 'name' => 'KnpLabs'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateOrganization()
- {
- $expectedArray = ['id' => 1, 'name' => 'KnpLabs'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/orgs/KnpLabs', ['value' => 'toUpdate'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->update('KnpLabs', ['value' => 'toUpdate']));
- }
-
- /**
- * @test
- */
- public function shouldGetOrganizationRepositories()
- {
- $expectedArray = [['id' => 1, 'username' => 'KnpLabs', 'name' => 'php-github-api']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->repositories('KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldGetMembersApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Organization\Members::class, $api->members());
- }
-
- /**
- * @test
- */
- public function shouldGetTeamsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Organization\Teams::class, $api->teams());
- }
-
- /**
- * @test
- */
- public function shouldGetSelfHostedRunnersApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Organization\Actions\SelfHostedRunners::class, $api->runners());
- }
-
- /**
- * @test
- */
- public function shouldGetVariablesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Organization\Actions\Variables::class, $api->variables());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Organization::class;
- }
-}
diff --git a/test/Github/Tests/Api/Project/CardsTest.php b/test/Github/Tests/Api/Project/CardsTest.php
deleted file mode 100644
index 8b3b37090db..00000000000
--- a/test/Github/Tests/Api/Project/CardsTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/projects/columns/123/cards')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all(123));
- }
-
- /**
- * @test
- */
- public function shouldShowCard()
- {
- $expectedValue = ['card1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/projects/columns/cards/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show(123));
- }
-
- /**
- * @test
- */
- public function shouldCreateCard()
- {
- $expectedValue = ['card1data'];
- $data = ['content_id' => '123', 'content_type' => 'Issue'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/projects/columns/1234/cards', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('1234', $data));
- }
-
- /**
- * @test
- */
- public function shouldUpdateCard()
- {
- $expectedValue = ['note1data'];
- $data = ['note' => 'note test'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/projects/columns/cards/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update(123, $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveCard()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/projects/columns/cards/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->deleteCard(123));
- }
-
- /**
- * @test
- */
- public function shouldNotMoveWithoutPosition()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->move('123', $data);
- }
-
- /**
- * @test
- */
- public function shouldMoveCard()
- {
- $expectedValue = ['card1'];
- $data = ['position' => 'top'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/projects/columns/cards/123/moves')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->move(123, $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Project\Cards::class;
- }
-}
diff --git a/test/Github/Tests/Api/Project/ColumnsTest.php b/test/Github/Tests/Api/Project/ColumnsTest.php
deleted file mode 100644
index 7df1225190b..00000000000
--- a/test/Github/Tests/Api/Project/ColumnsTest.php
+++ /dev/null
@@ -1,171 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/projects/123/columns')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all(123));
- }
-
- /**
- * @test
- */
- public function shouldShowColumn()
- {
- $expectedValue = ['column1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/projects/columns/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show(123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('123', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateColumn()
- {
- $expectedValue = ['column1data'];
- $data = ['name' => 'column 1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/projects/123/columns', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create(123, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->update('123', $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateColumn()
- {
- $expectedValue = ['column1data'];
- $data = ['name' => 'column 1 update'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/projects/columns/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update(123, $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveCard()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/projects/columns/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->deleteColumn(123));
- }
-
- /**
- * @test
- */
- public function shouldNotMoveWithoutPosition()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->move('123', $data);
- }
-
- /**
- * @test
- */
- public function shouldMoveCard()
- {
- $expectedValue = ['card1'];
- $data = ['position' => 'first'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/projects/columns/123/moves')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->move(123, $data));
- }
-
- /**
- * @test
- */
- public function shouldGetCardsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf('Github\Api\Project\Cards', $api->cards());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Project\Columns::class;
- }
-}
diff --git a/test/Github/Tests/Api/Project/ProjectsTest.php b/test/Github/Tests/Api/Project/ProjectsTest.php
deleted file mode 100644
index 0dc7e2645a5..00000000000
--- a/test/Github/Tests/Api/Project/ProjectsTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
- 'Test project 1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/projects/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show(123));
- }
-
- /**
- * @test
- */
- public function shouldUpdateProject()
- {
- $expectedValue = ['project1data'];
- $data = ['name' => 'Project 1 update'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/projects/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update(123, $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveProject()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/projects/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->deleteProject(123));
- }
-
- /**
- * @test
- */
- public function shouldGetColumnsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf('Github\Api\Project\Columns', $api->columns());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return AbstractProjectApi::class;
- }
-}
diff --git a/test/Github/Tests/Api/PullRequest/CommentsTest.php b/test/Github/Tests/Api/PullRequest/CommentsTest.php
deleted file mode 100644
index c180607e837..00000000000
--- a/test/Github/Tests/Api/PullRequest/CommentsTest.php
+++ /dev/null
@@ -1,495 +0,0 @@
- 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/12/comments')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12));
- }
-
- /**
- * @test
- */
- public function shouldGetAllReviewComments()
- {
- $expectedValue = [
- [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/comments')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World'));
- }
-
- /**
- * @test
- */
- public function shouldShowReviewComment()
- {
- $expectedValue = [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/comments/1')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->show('octocat', 'Hello-World', 1));
- }
-
- /**
- * @test
- */
- public function shouldCreateReviewComment()
- {
- $expectedValue = [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ];
- $data = [
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'path' => 'file1.txt',
- 'position' => 4,
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/octocat/Hello-World/pulls/1/comments', $data)
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->create('octocat', 'Hello-World', 1, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReviewCommentWithoutCommitId()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'path' => 'file1.txt',
- 'position' => 4,
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->create('octocat', 'Hello-World', 1, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReviewCommentWithoutPath()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'position' => 4,
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->create('octocat', 'Hello-World', 1, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReviewCommentWithoutPosition()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'path' => 'file1.txt',
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->create('octocat', 'Hello-World', 1, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReviewCommentWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'path' => 'file1.txt',
- 'position' => 4,
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->create('octocat', 'Hello-World', 1, $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateReviewComment()
- {
- $expectedValue = [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ];
- $data = [
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/octocat/Hello-World/pulls/comments/1', $data)
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 1, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateReviewCommentWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $expectedValue = [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch')
- ;
-
- $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 1, []));
- }
-
- /**
- * @test
- */
- public function shouldDeleteReviewComment()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/octocat/Hello-World/pulls/comments/1')
- ;
-
- $api->remove('octocat', 'Hello-World', 1);
- }
-
- protected function getApiClass()
- {
- return Comments::class;
- }
-}
diff --git a/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php b/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php
deleted file mode 100644
index 3335b4a3494..00000000000
--- a/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
- 80],
- ['id' => 81],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12));
- }
-
- /**
- * @test
- */
- public function shouldCreateReviewRequest()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']])
- ;
-
- $api->create('octocat', 'Hello-World', 12, ['testuser'], ['testteam']);
- }
-
- /**
- * @test
- */
- public function shouldDeleteReviewRequest()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']])
- ;
-
- $api->remove('octocat', 'Hello-World', 12, ['testuser'], ['testteam']);
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return ReviewRequest::class;
- }
-}
diff --git a/test/Github/Tests/Api/PullRequest/ReviewTest.php b/test/Github/Tests/Api/PullRequest/ReviewTest.php
deleted file mode 100644
index eb94203bc68..00000000000
--- a/test/Github/Tests/Api/PullRequest/ReviewTest.php
+++ /dev/null
@@ -1,455 +0,0 @@
- 80,
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}',
- 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}',
- 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Here is the body for the review.',
- 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091',
- 'state' => 'APPROVED',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- '_links' => [
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- ],
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12));
- }
-
- /**
- * @test
- */
- public function shouldShowReview()
- {
- $expectedValue = [
- 'id' => 80,
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}',
- 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}',
- 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Here is the body for the review.',
- 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091',
- 'state' => 'APPROVED',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- '_links' => [
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews/80')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->show('octocat', 'Hello-World', 12, 80));
- }
-
- /**
- * @test
- */
- public function shouldDeleteReview()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews/80')
- ;
-
- $api->remove('octocat', 'Hello-World', 12, 80);
- }
-
- /**
- * @test
- */
- public function shouldShowReviewComments()
- {
- $expectedValue = [
- [
- 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- 'id' => 1,
- 'pull_request_review_id' => 42,
- 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...',
- 'path' => 'file1.txt',
- 'position' => 1,
- 'original_position' => 4,
- 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]',
- 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]',
- 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'created_at' => '2011-04-14T16:00:49Z',
- 'updated_at' => '2011-04-14T16:00:49Z',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- '_links' => [
- 'self' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1',
- ],
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1',
- ],
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/octocat/Hello-World/pulls/1/reviews/42/comments')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->comments('octocat', 'Hello-World', 1, 42));
- }
-
- /**
- * @test
- */
- public function shouldCreateReviewComment()
- {
- $data = [
- 'event' => 'APPROVE',
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews')
- ;
-
- $api->create('octocat', 'Hello-World', 12, $data);
- }
-
- /**
- * @test
- */
- public function shouldCreatePendingReviewWithoutEvent()
- {
- $data = [
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews')
- ;
-
- $api->create('octocat', 'Hello-World', 12, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateReviewWithInvalidEvent()
- {
- $this->expectException(InvalidArgumentException::class);
- $data = [
- 'event' => 'DISMISSED',
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->create('octocat', 'Hello-World', 12, $data);
- }
-
- /**
- * @test
- */
- public function shouldSubmitReviewComment()
- {
- $expectedValue = [
- 'id' => 80,
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}',
- 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}',
- 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Here is the body for the review.',
- 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091',
- 'state' => 'APPROVED',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- '_links' => [
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- ],
- ],
- ];
- $data = [
- 'event' => 'APPROVE',
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews/80/events')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->submit('octocat', 'Hello-World', 12, 80, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotSubmitReviewWithoutEvent()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->submit('octocat', 'Hello-World', 12, 80, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotSubmitReviewWithInvalidEvent()
- {
- $this->expectException(InvalidArgumentException::class);
- $data = [
- 'event' => 'DISMISSED',
- 'body' => 'Nice change',
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->never())
- ->method('post')
- ;
-
- $api->submit('octocat', 'Hello-World', 12, 80, $data);
- }
-
- /**
- * @test
- */
- public function shouldDismissReview()
- {
- $expectedValue = [
- 'id' => 80,
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}',
- 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}',
- 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Here is the body for the review.',
- 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091',
- 'state' => 'APPROVED',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- '_links' => [
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews/80/dismissals')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->dismiss('octocat', 'Hello-World', 12, 80, 'Dismiss reason'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateReviewComment()
- {
- $expectedValue = [
- 'id' => 80,
- 'node_id' => 'MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=',
- 'user' => [
- 'login' => 'octocat',
- 'id' => 1,
- 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif',
- 'gravatar_id' => '',
- 'url' => 'https://api.github.com/users/octocat',
- 'html_url' => 'https://github.com/octocat',
- 'followers_url' => 'https://api.github.com/users/octocat/followers',
- 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}',
- 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}',
- 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}',
- 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions',
- 'organizations_url' => 'https://api.github.com/users/octocat/orgs',
- 'repos_url' => 'https://api.github.com/users/octocat/repos',
- 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}',
- 'received_events_url' => 'https://api.github.com/users/octocat/received_events',
- 'type' => 'User',
- 'site_admin' => false,
- ],
- 'body' => 'Great stuff',
- 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091',
- 'state' => 'CHANGES_REQUESTED',
- 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- '_links' => [
- 'html' => [
- 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80',
- ],
- 'pull_request' => [
- 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12',
- ],
- ],
- ];
- $body = 'Nice change';
-
- $api = $this->getApiMock();
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/octocat/Hello-World/pulls/12/reviews/80')
- ->willReturn($expectedValue);
-
- $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 12, 80, $body));
- }
-
- protected function getApiClass()
- {
- return Review::class;
- }
-}
diff --git a/test/Github/Tests/Api/PullRequestTest.php b/test/Github/Tests/Api/PullRequestTest.php
deleted file mode 100644
index 54cc34f55e0..00000000000
--- a/test/Github/Tests/Api/PullRequestTest.php
+++ /dev/null
@@ -1,402 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish'));
- }
-
- /**
- * @test
- */
- public function shouldGetOpenPullRequests()
- {
- $expectedArray = ['pr1', 'pr2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'open'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'open']));
- }
-
- /**
- * @test
- */
- public function shouldGetClosedPullRequests()
- {
- $expectedArray = ['pr1', 'pr2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'closed'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'closed']));
- }
-
- /**
- * @test
- */
- public function shouldShowPullRequest()
- {
- $expectedArray = ['id' => 'id', 'sha' => '123123'];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('ezsystems', 'ezpublish', '15'));
- }
-
- /**
- * @test
- */
- public function shouldShowCommitsFromPullRequest()
- {
- $expectedArray = [['id' => 'id', 'sha' => '123123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15/commits')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15'));
- }
-
- /**
- * @test
- */
- public function shouldShowCommitsFromPullRequestForPage()
- {
- $expectedArray = [['id' => 'id', 'sha' => '123123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15/commits', ['page' => 2, 'per_page' => 30])
- ->willReturn($expectedArray);
-
- $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30]));
- }
-
- /**
- * @test
- */
- public function shouldShowFilesFromPullRequest()
- {
- $expectedArray = [['id' => 'id', 'sha' => '123123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15/files')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->files('ezsystems', 'ezpublish', '15'));
- }
-
- /**
- * @test
- */
- public function shouldShowFilesFromPullRequestForPage()
- {
- $expectedArray = [['id' => 'id', 'sha' => '123123']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15/files', ['page' => 2, 'per_page' => 30])
- ->willReturn($expectedArray);
-
- $this->assertSame($expectedArray, $api->files('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30]));
- }
-
- /**
- * @test
- */
- public function shouldShowStatusesFromPullRequest()
- {
- $expectedArray = [['id' => 'id', 'sha' => '123123']];
- $expectedArray['_links']['statuses']['href'] = '/repos/ezsystems/ezpublish/pulls/15/statuses';
-
- $api = $this->getApiMock();
-
- $api->expects($this->exactly(2))
- ->method('get')
- ->withConsecutive(
- [$this->equalTo('/repos/ezsystems/ezpublish/pulls/15')],
- [$this->equalTo('/repos/ezsystems/ezpublish/pulls/15/statuses')]
- )
- ->willReturn($expectedArray)
- ;
-
- $this->assertEquals($expectedArray, $api->status('ezsystems', 'ezpublish', '15'));
- }
-
- /**
- * @test
- */
- public function shouldUpdatePullRequests()
- {
- $expectedArray = ['id' => 15, 'sha' => '123123'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/ezsystems/ezpublish/pulls/15', ['state' => 'open', 'some' => 'param'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->update('ezsystems', 'ezpublish', 15, ['state' => 'aa', 'some' => 'param']));
- }
-
- /**
- * @test
- */
- public function shouldCheckIfPullRequestIsMerged()
- {
- $expectedArray = ['some' => 'response'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/ezsystems/ezpublish/pulls/15/merge')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->merged('ezsystems', 'ezpublish', 15));
- }
-
- /**
- * @test
- */
- public function shouldMergePullRequest()
- {
- $expectedArray = ['some' => 'response'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'merge'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40)));
- }
-
- /**
- * @test
- */
- public function shouldMergePullRequestWithSquashAsBool()
- {
- $expectedArray = ['some' => 'response'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'squash'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), true));
- }
-
- /**
- * @test
- */
- public function shouldMergePullRequestWithMergeMethod()
- {
- $expectedArray = ['some' => 'response'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'rebase'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), 'rebase'));
- }
-
- /**
- * @test
- */
- public function shouldCreatePullRequestUsingTitle()
- {
- $data = [
- 'base' => 'master',
- 'head' => 'virtualtestbranch',
- 'title' => 'TITLE: Testing pull-request creation from PHP Github API',
- 'body' => 'BODY: Testing pull-request creation from PHP Github API',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/ezsystems/ezpublish/pulls', $data);
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreatePullRequestUsingIssueId()
- {
- $data = [
- 'base' => 'master',
- 'head' => 'virtualtestbranch',
- 'issue' => 25,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/ezsystems/ezpublish/pulls', $data);
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateDraftPullRequest()
- {
- $data = [
- 'base' => 'master',
- 'head' => 'virtualtestbranch',
- 'title' => 'TITLE: Testing draft pull-request creation from PHP Github API',
- 'body' => 'BODY: Testing draft pull-request creation from PHP Github API',
- 'draft' => 'true',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/ezsystems/ezpublish/pulls', $data);
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreatePullRequestWithoutBase()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'head' => 'virtualtestbranch',
- 'title' => 'TITLE: Testing pull-request creation from PHP Github API',
- 'body' => 'BODY: Testing pull-request creation from PHP Github API',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreatePullRequestWithoutHead()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'base' => 'master',
- 'title' => 'TITLE: Testing pull-request creation from PHP Github API',
- 'body' => 'BODY: Testing pull-request creation from PHP Github API',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreatePullRequestUsingTitleButWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'base' => 'master',
- 'head' => 'virtualtestbranch',
- 'title' => 'TITLE: Testing pull-request creation from PHP Github API',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreatePullRequestWithoutIssueIdOrTitle()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [
- 'base' => 'master',
- 'head' => 'virtualtestbranch',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('ezsystems', 'ezpublish', $data);
- }
-
- /**
- * @test
- */
- public function shouldGetCommentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\PullRequest\Comments::class, $api->comments());
- }
-
- /**
- * @test
- */
- public function shouldGetReviewApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\PullRequest\Review::class, $api->reviews());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\PullRequest::class;
- }
-}
diff --git a/test/Github/Tests/Api/RateLimitTest.php b/test/Github/Tests/Api/RateLimitTest.php
deleted file mode 100644
index d13d001d890..00000000000
--- a/test/Github/Tests/Api/RateLimitTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
- [
- 'core' => [
- 'limit' => 5000,
- 'remaining' => 4999,
- 'reset' => 1372700873,
- ],
- 'search' => [
- 'limit' => 30,
- 'remaining' => 18,
- 'reset' => 1372697452,
- ],
- 'graphql' => [
- 'limit' => 5000,
- 'remaining' => 4030,
- 'reset' => 1372697452,
- ],
- ],
- ];
-
- /**
- * @var RateLimit
- */
- protected $api;
-
- /**
- * @before
- */
- public function initMocks()
- {
- $this->api = $this->getApiMock();
- $this->api->expects($this->once())
- ->method('get')
- ->with('/rate_limit')
- ->will($this->returnValue($this->expectedArray));
- }
-
- /**
- * @test
- */
- public function shouldReturnArrayOfLimitInstances()
- {
- $this->assertContainsOnlyInstancesOf(RateLimit\RateLimitResource::class, $this->api->getResources());
- }
-
- /**
- * @test
- */
- public function shouldReturnRemainingGraphQLRequests()
- {
- $this->assertSame(4030, $this->api->getResource('graphql')->getRemaining());
- }
-
- /**
- * @test
- */
- public function shouldReturnResetForSearch()
- {
- $this->assertSame(1372697452, $this->api->getResource('search')->getReset());
- }
-
- /**
- * @test
- */
- public function shouldReturnFalseWhenResourceIsNotFound()
- {
- $this->assertFalse($this->api->getResource('non-exitent'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\RateLimit::class;
- }
-}
diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php
deleted file mode 100644
index 786c27d97b5..00000000000
--- a/test/Github/Tests/Api/RepoTest.php
+++ /dev/null
@@ -1,789 +0,0 @@
- 1, 'name' => 'repoName'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowRepositoryById()
- {
- $expectedArray = ['id' => 123456, 'name' => 'repoName'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repositories/123456')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->showById(123456));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepositories()
- {
- $expectedArray = [
- ['id' => 1, 'name' => 'dummy project'],
- ['id' => 2, 'name' => 'awesome another project'],
- ['id' => 3, 'name' => 'fork of php'],
- ['id' => 4, 'name' => 'fork of php-cs'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepositoriesStartingIndex()
- {
- $expectedArray = [
- ['id' => 1, 'name' => 'dummy project'],
- ['id' => 2, 'name' => 'awesome another project'],
- ['id' => 3, 'name' => 'fork of php'],
- ['id' => 4, 'name' => 'fork of php-cs'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repositories', ['since' => 2])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all(2));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryUsingNameOnly()
- {
- $expectedArray = ['id' => 1, 'name' => 'l3l0Repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/repos', [
- 'name' => 'l3l0Repo',
- 'description' => '',
- 'homepage' => '',
- 'private' => false,
- 'has_issues' => false,
- 'has_wiki' => false,
- 'has_downloads' => false,
- 'auto_init' => false,
- 'has_projects' => true,
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->create('l3l0Repo'));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryForOrganization()
- {
- $expectedArray = ['id' => 1, 'name' => 'KnpLabsRepo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/orgs/KnpLabs/repos', [
- 'name' => 'KnpLabsRepo',
- 'description' => '',
- 'homepage' => '',
- 'private' => false,
- 'has_issues' => false,
- 'has_wiki' => false,
- 'has_downloads' => false,
- 'auto_init' => false,
- 'has_projects' => true,
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->create('KnpLabsRepo', '', '', true, 'KnpLabs'));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryWithInternalVisibility()
- {
- $expectedArray = ['id' => 1, 'name' => 'KnpLabsRepo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/repos', [
- 'name' => 'KnpLabsRepo',
- 'description' => '',
- 'homepage' => '',
- 'has_issues' => false,
- 'has_wiki' => false,
- 'has_downloads' => false,
- 'auto_init' => false,
- 'has_projects' => true,
- 'visibility' => 'internal',
- 'private' => false,
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->create(
- 'KnpLabsRepo',
- '',
- '',
- false,
- null,
- false,
- false,
- false,
- null,
- false,
- true,
- 'internal'
- )
- );
- }
-
- /**
- * @test
- */
- public function shouldGetRepositorySubscribers()
- {
- $expectedArray = [['id' => 1, 'username' => 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/subscribers', ['page' => 2])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->subscribers('KnpLabs', 'php-github-api', 2));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryTags()
- {
- $expectedArray = [['sha' => 1234]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/tags')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->tags('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryBranches()
- {
- $expectedArray = [['sha' => 1234, 'name' => 'master']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryBranch()
- {
- $expectedArray = ['sha' => 1234, 'name' => 'master'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldMergeUpstreamRepository()
- {
- $expectedArray = [
- 'message' => 'Successfully fetched and fast-forwarded from upstream upstreamRepo:main',
- 'merge_type' => 'fast-forward',
- 'merge_branch' => 'upstreamRepo:main',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/merge-upstream', ['branch' => 'main'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->mergeUpstream('KnpLabs', 'php-github-api', 'main'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryLanguages()
- {
- $expectedArray = ['lang1', 'lang2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/languages')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->languages('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryMilestones()
- {
- $expectedArray = ['milestone1', 'milestone2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/milestones')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->milestones('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldEnableAutomatedSecurityFixes()
- {
- $expectedResponse = 'response';
-
- /** @var Repo|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/automated-security-fixes')
- ->will($this->returnValue($expectedResponse));
-
- $this->assertEquals($expectedResponse, $api->enableAutomatedSecurityFixes('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldDisableAutomatedSecurityFixes()
- {
- $expectedResponse = 'response';
-
- /** @var Repo|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/automated-security-fixes')
- ->will($this->returnValue($expectedResponse));
-
- $this->assertEquals($expectedResponse, $api->disableAutomatedSecurityFixes('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetContributorsExcludingAnonymousOnes()
- {
- $expectedArray = ['contrib1', 'contrib2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => null])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', false));
- }
-
- /**
- * @test
- */
- public function shouldGetContributorsIncludingAnonymousOnes()
- {
- $expectedArray = ['contrib1', 'contrib2'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => true])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', true));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryTeams()
- {
- $expectedArray = [['id' => 1234], ['id' => 2345]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/teams')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->teams('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldCreateUsingAllParams()
- {
- $expectedArray = ['id' => 1, 'name' => 'l3l0Repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/user/repos', [
- 'name' => 'l3l0Repo',
- 'description' => 'test',
- 'homepage' => 'http://l3l0.eu',
- 'private' => true,
- 'has_issues' => false,
- 'has_wiki' => false,
- 'has_downloads' => false,
- 'auto_init' => false,
- 'has_projects' => true,
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->create('l3l0Repo', 'test', 'http://l3l0.eu', false));
- }
-
- /**
- * @test
- */
- public function shouldUpdate()
- {
- $expectedArray = ['id' => 1, 'name' => 'l3l0Repo'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/l3l0Repo/test', ['description' => 'test', 'homepage' => 'http://l3l0.eu'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', ['description' => 'test', 'homepage' => 'http://l3l0.eu']));
- }
-
- /**
- * @test
- */
- public function shouldDelete()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/l3l0Repo/test')
- ->will($this->returnValue(null));
-
- $this->assertNull($api->remove('l3l0Repo', 'test'));
- }
-
- /**
- * @test
- */
- public function shouldNotDelete()
- {
- $expectedArray = ['message' => 'Not Found'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/l3l0Repo/unknown-repo')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->remove('l3l0Repo', 'unknown-repo'));
- }
-
- /**
- * @test
- */
- public function shouldGetCollaboratorsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Collaborators::class, $api->collaborators());
- }
-
- /**
- * @test
- */
- public function shouldGetCommentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Comments::class, $api->comments());
- }
-
- /**
- * @test
- */
- public function shouldGetCommitsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Commits::class, $api->commits());
- }
-
- /**
- * @test
- */
- public function shouldGetContentsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Contents::class, $api->contents());
- }
-
- /**
- * @test
- */
- public function shouldGetDeployKeysApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\DeployKeys::class, $api->keys());
- }
-
- /**
- * @test
- */
- public function shouldGetDownloadsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Downloads::class, $api->downloads());
- }
-
- /**
- * @test
- */
- public function shouldGetForksApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Forks::class, $api->forks());
- }
-
- /**
- * @test
- */
- public function shouldGetHooksApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Hooks::class, $api->hooks());
- }
-
- /**
- * @test
- */
- public function shouldGetLabelsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Labels::class, $api->labels());
- }
-
- /**
- * @test
- */
- public function shouldGetStatusesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Statuses::class, $api->statuses());
- }
-
- /**
- * @test
- */
- public function shouldGetStargazersApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Stargazers::class, $api->stargazers());
- }
-
- /**
- * @test
- */
- public function shouldGetReleasesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Releases::class, $api->releases());
- }
-
- /**
- * @test
- */
- public function shouldGetVariablesApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf(\Github\Api\Repository\Actions\Variables::class, $api->variables());
- }
-
- /**
- * @test
- */
- public function shouldGetCommitActivity()
- {
- $expectedArray = [['days' => [0, 3, 26, 20, 39, 1, 0], 'total' => 89, 'week' => 1336280400]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/stats/commit_activity')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->activity('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryEvents()
- {
- $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/events', [
- 'page' => 3,
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->events('KnpLabs', 'php-github-api', 3));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryCommunityProfile()
- {
- $expectedArray = ['health_percentage' => 100, 'description' => 'A simple PHP GitHub API client...'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/community/profile')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->communityProfile('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryCodeOfConduct()
- {
- $expectedArray = ['name' => 'Contributor Covenant', 'url' => 'http://...'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/community/code_of_conduct')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->codeOfConduct('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryTopics()
- {
- $expectedArray = ['names' => ['octocat', 'atom', 'electron', 'API']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/topics')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->topics('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldReplaceRepositoryTopics()
- {
- $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/topics', [
- 'names' => ['octocat', 'atom', 'electron', 'API'],
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->replaceTopics('KnpLabs', 'php-github-api', ['octocat', 'atom', 'electron', 'API']));
- }
-
- /**
- * @test
- */
- public function shouldTransferRepository()
- {
- $expectedArray = ['id' => 1, 'name' => 'php-github-api'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/transfer', [
- 'new_owner' => 'github',
- 'team_id' => [1234, 1235],
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->transfer('KnpLabs', 'php-github-api', 'github', [1234, 1235]));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryUsingTemplate()
- {
- $expectedArray = [
- 'id' => 1,
- 'name' => 'newrepo',
- 'full_name' => 'johndoe/newrepo',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/acme/template/generate', [
- 'name' => 'newrepo',
- 'owner' => 'johndoe',
- ])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->createFromTemplate('acme', 'template', [
- 'name' => 'newrepo',
- 'owner' => 'johndoe',
- ]));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repo::class;
- }
-
- /**
- * @test
- */
- public function shouldCheckVulnerabilityAlertsEnabled()
- {
- $expectedResponse = '';
-
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts')
- ->will($this->returnValue($expectedResponse));
-
- $this->assertEquals($expectedResponse, $api->isVulnerabilityAlertsEnabled('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldEnableVulnerabilityAlerts()
- {
- $expectedResponse = '';
-
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts')
- ->will($this->returnValue($expectedResponse));
-
- $this->assertEquals($expectedResponse, $api->enableVulnerabilityAlerts('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldDisableVulnerabilityAlerts()
- {
- $expectedResponse = '';
-
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts')
- ->will($this->returnValue($expectedResponse));
-
- $this->assertEquals($expectedResponse, $api->disableVulnerabilityAlerts('KnpLabs', 'php-github-api'));
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php b/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php
deleted file mode 100644
index 90ace988bab..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
- 'id',
- 'node_id' => 'node_id',
- 'name' => 'name',
- 'size_in_bytes' => 453,
- 'url' => 'foo',
- 'archive_download_url' => 'foo',
- 'expired' => false,
- 'created_at' => '2020-01-10T14:59:22Z',
- 'expires_at' => '2020-01-21T14:59:22Z',
- ],
- ];
-
- /** @var Artifacts|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/artifacts')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetRunArtifacts()
- {
- $expectedArray = [
- [
- 'id' => 'id',
- 'node_id' => 'node_id',
- 'name' => 'name',
- 'size_in_bytes' => 453,
- 'url' => 'foo',
- 'archive_download_url' => 'foo',
- 'expired' => false,
- 'created_at' => '2020-01-10T14:59:22Z',
- 'expires_at' => '2020-01-21T14:59:22Z',
- ],
- ];
-
- /** @var Artifacts|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/1/artifacts')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->runArtifacts('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldRemoveArtifact()
- {
- $expectedValue = 'response';
-
- /** @var Artifacts|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/artifacts/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 1));
- }
-
- protected function getApiClass()
- {
- return Artifacts::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/SecretsTest.php b/test/Github/Tests/Api/Repository/Actions/SecretsTest.php
deleted file mode 100644
index 5a5e20a4616..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/SecretsTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
- 'GH_TOKEN', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'GIST_ID', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetSecret()
- {
- $expectedArray = ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldCreateSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'secretName', [
- 'encrypted_value' => 'encryptedValue',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldUpdateSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'secretName', [
- 'key_id' => 'keyId', 'encrypted_value' => 'encryptedValue',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveSecret()
- {
- $expectedValue = 'response';
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'secretName'));
- }
-
- /**
- * @test
- */
- public function shouldGetPublicKey()
- {
- $expectedArray = ['key_id' => 'key_id', 'key' => 'foo'];
-
- /** @var Secrets|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/secrets/public-key')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->publicKey('KnpLabs', 'php-github-api'));
- }
-
- protected function getApiClass()
- {
- return Secrets::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php b/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php
deleted file mode 100644
index 67c8eade4bd..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
- 1,
- 'name' => 'MBP',
- 'os' => 'macos',
- 'status' => 'online',
- ],
- [
- 'id' => 2,
- 'name' => 'iMac',
- 'os' => 'macos',
- 'status' => 'offline',
- ],
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runners')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetSelfHostedRunner()
- {
- $expectedArray = [
- 'id' => 1,
- 'name' => 'MBP',
- 'os' => 'macos',
- 'status' => 'online',
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runners/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldRemoveSelfHostedRunner()
- {
- $expectedValue = 'response';
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/runners/1')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldGetSelfHostedRunnerApps()
- {
- $expectedArray = [
- ['os' => 'osx', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'arm', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'win', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ['os' => 'linux', 'architecture' => 'arm64', 'download_url' => 'download_url', 'filename' => 'filename'],
- ];
-
- /** @var SelfHostedRunners|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runners/downloads')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->applications('KnpLabs', 'php-github-api'));
- }
-
- protected function getApiClass()
- {
- return SelfHostedRunners::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/VariablesTest.php b/test/Github/Tests/Api/Repository/Actions/VariablesTest.php
deleted file mode 100644
index e362d31f7bc..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/VariablesTest.php
+++ /dev/null
@@ -1,119 +0,0 @@
- 'GH_TOKEN', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ['name' => 'GIST_ID', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'],
- ];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/variables')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetVariable()
- {
- $expectedArray = ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'];
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 'variableName'));
- }
-
- /**
- * @test
- */
- public function shouldCreateVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/actions/variables')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', [
- 'name' => 'name',
- 'value' => 'value',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldUpdateVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'variableName', [
- 'name' => 'name',
- 'value' => 'value',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldRemoveVariable()
- {
- $expectedValue = 'response';
-
- /** @var Variables|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'variableName'));
- }
-
- protected function getApiClass()
- {
- return Variables::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php
deleted file mode 100644
index 4af8b52ebc9..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php
+++ /dev/null
@@ -1,57 +0,0 @@
- 'id', 'run_id' => 'run_id', 'status' => 'completed', 'conclusion' => 'success'],
- ];
-
- /** @var WorkflowJobs|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/1/jobs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldShowWorkflowJob()
- {
- $expectedArray = [
- 'id' => 'id', 'run_id' => 'run_id', 'status' => 'completed', 'conclusion' => 'success',
- ];
-
- /** @var WorkflowJobs|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/jobs/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1));
- }
-
- protected function getApiClass()
- {
- return WorkflowJobs::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php
deleted file mode 100644
index 1c5af0badc9..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php
+++ /dev/null
@@ -1,223 +0,0 @@
- 'id',
- 'event' => 'push',
- 'status' => 'queued',
- ],
- ];
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetWorkflowRuns()
- {
- $expectedArray = [
- [
- 'id' => 'id',
- 'name' => 'CI',
- 'event' => 'push',
- 'status' => 'completed',
- 'conclusion' => 'success',
- 'workflow_id' => 3441570,
- ],
- ];
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/workflows/3441570/runs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->listRuns('KnpLabs', 'php-github-api', 3441570));
- }
-
- /**
- * @test
- */
- public function shouldShowWorkflowRun()
- {
- $expectedArray = ['id' => 'id', 'name' => 'CI'];
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldDeleteWorkflowRun()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldGetWorkflowRunUsage()
- {
- $expectedArray = [
- 'billable' => [
- 'UBUNTU' => ['total_ms' => 180000, 'jobs' => 1],
- 'MACOS' => ['total_ms' => 240000, 'jobs' => 1],
- 'WINDOWS' => ['total_ms' => 300000, 'jobs' => 1],
- ],
- 'run_duration_ms' => 500000,
- ];
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/timing')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->usage('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldRerunWorkflowRun()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/rerun')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->rerun('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldCancelWorkflowRun()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/cancel')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->cancel('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldDownloadWorkflowRunLogs()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/logs')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->downloadLogs('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldDeleteWorkflowRunLogs()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/logs')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->deleteLogs('KnpLabs', 'php-github-api', 374473304));
- }
-
- /**
- * @test
- */
- public function shouldApproveWorkflowRunLogs()
- {
- $expectedValue = 'response';
-
- /** @var WorkflowRuns|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/approve')
- ->will($this->returnValue($expectedValue));
-
- $this->assertSame($expectedValue, $api->approve('KnpLabs', 'php-github-api', 374473304));
- }
-
- protected function getApiClass()
- {
- return WorkflowRuns::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php
deleted file mode 100644
index 7413fc5d7c0..00000000000
--- a/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
- 'id',
- 'node_id' => 'node_id',
- 'name' => 'CI',
- 'path' => '.github/workflows/ci.yml',
- 'state' => 'active',
- 'created_at' => '2020-11-07T15:09:45.000Z',
- 'updated_at' => '2020-11-07T15:09:45.000Z',
- ],
- ];
-
- /** @var Workflows|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/workflows')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowWorkflow()
- {
- $expectedArray = [
- 'id' => 'id',
- 'node_id' => 'node_id',
- 'name' => 'CI',
- 'path' => '.github/workflows/ci.yml',
- 'state' => 'active',
- 'created_at' => '2020-11-07T15:09:45.000Z',
- 'updated_at' => '2020-11-07T15:09:45.000Z',
- ];
-
- /** @var Workflows|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/workflows/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldGetWorkflowUsage()
- {
- $expectedArray = [
- 'billable' => [
- 'UBUNTU' => ['total_ms' => 180000, 'jobs' => 1],
- 'MACOS' => ['total_ms' => 240000, 'jobs' => 1],
- 'WINDOWS' => ['total_ms' => 300000, 'jobs' => 1],
- ],
- ];
-
- /** @var Workflows|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/actions/workflows/1/timing')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->usage('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldDispatchWorkflow()
- {
- // empty
- $expectedArray = [];
-
- /** @var Workflows|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/actions/workflows/1/dispatches')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->dispatches('KnpLabs', 'php-github-api', 1, 'main'));
- }
-
- protected function getApiClass()
- {
- return Workflows::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/AssetsTest.php b/test/Github/Tests/Api/Repository/AssetsTest.php
deleted file mode 100644
index 6cea75fe975..00000000000
--- a/test/Github/Tests/Api/Repository/AssetsTest.php
+++ /dev/null
@@ -1,129 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases/'.$id.'/assets')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', $id));
- }
-
- /**
- * @test
- */
- public function shouldGetSingleReleaseAsset()
- {
- $expectedValue = ['assetData'];
- $assetId = 2;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $assetId));
- }
-
- /**
- * @test
- *
- * @requires PHP 5.3.4
- */
- public function shouldCreateReleaseAsset()
- {
- if (!defined('OPENSSL_TLSEXT_SERVER_NAME') || !OPENSSL_TLSEXT_SERVER_NAME) {
- return $this->markTestSkipped(
- 'Asset upload support requires Server Name Indication. This is not supported by your PHP version.'
- );
- }
-
- $name = 'asset.gzip';
- $body = 'assetCreatedData';
- $contentType = 'application/gzip';
- $releaseId = '12345';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('postRaw')
- ->with('https://uploads.github.com/repos/KnpLabs/php-github-api/releases/'.$releaseId.'/assets?name='.$name)
- ->will($this->returnValue($body));
-
- $this->assertEquals($body, $api->create('KnpLabs', 'php-github-api', $releaseId, $name, $contentType, $body));
- }
-
- /**
- * @test
- */
- public function shouldEditReleaseAsset()
- {
- $expectedValue = ['assetUpdatedData'];
- $assetId = 5;
- $data = ['name' => 'asset111_name_qweqwe'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->edit('KnpLabs', 'php-github-api', $assetId, $data));
- }
-
- /**
- * @test
- */
- public function shouldNotEditReleaseAssetWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $assetId = 5;
- $data = ['not_a_name' => 'just a value'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->edit('KnpLabs', 'php-github-api', $assetId, $data);
- }
-
- /**
- * @test
- */
- public function shouldRemoveReleaseAsset()
- {
- $expectedValue = ['assetUpdatedData'];
- $assetId = 5;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', $assetId));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Assets::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php b/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php
deleted file mode 100644
index 66bb5277c4b..00000000000
--- a/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php
+++ /dev/null
@@ -1,123 +0,0 @@
- 'success'];
- $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check'];
-
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/check-runs', $data)
- ->willReturn($expectedValue);
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldShowSingleCheckRun()
- {
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/check-runs/14');
-
- $api->show('KnpLabs', 'php-github-api', 14);
- }
-
- /**
- * @test
- */
- public function shouldUpdateCheck()
- {
- $expectedValue = ['state' => 'success'];
- $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check'];
-
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/check-runs/123', $data)
- ->willReturn($expectedValue);
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldListCheckRunAnnotations()
- {
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/check-runs/14/annotations');
-
- $api->annotations('KnpLabs', 'php-github-api', 14);
- }
-
- /**
- * @test
- */
- public function shouldGetAllChecksForCheckSuite()
- {
- $params = ['test' => true];
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/check-suites/123/check-runs', $params);
-
- $api->allForCheckSuite('KnpLabs', 'php-github-api', 123, $params);
- }
-
- /**
- * @test
- */
- public function shouldGetAllChecksForReference()
- {
- $params = ['test' => true];
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/cb4abc15424c0015b4468d73df55efb8b60a4a3d/check-runs', $params);
-
- $api->allForReference('KnpLabs', 'php-github-api', 'cb4abc15424c0015b4468d73df55efb8b60a4a3d', $params);
- }
-
- /**
- * @test
- */
- public function shouldRerequestCheckRun()
- {
- /** @var CheckRuns|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/check-runs/123/rerequest');
-
- $api->rerequest('KnpLabs', 'php-github-api', 123);
- }
-
- protected function getApiClass(): string
- {
- return CheckRuns::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php b/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php
deleted file mode 100644
index 87d8831d0da..00000000000
--- a/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
- 'success'];
- $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check'];
-
- /** @var CheckSuites|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/check-suites', $data)
- ->willReturn($expectedValue);
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldUpdateCheckSuitePreferences()
- {
- $expectedValue = ['preferences' => []];
- $data = ['preference_1' => true];
-
- /** @var CheckSuites|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/check-suites/preferences', $data)
- ->willReturn($expectedValue);
-
- $this->assertEquals($expectedValue, $api->updatePreferences('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldGetCheckSuite()
- {
- /** @var CheckSuites|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/check-suites/14');
-
- $api->getCheckSuite('KnpLabs', 'php-github-api', 14);
- }
-
- /**
- * @test
- */
- public function shouldRerequest()
- {
- /** @var CheckSuites|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/check-suites/14/rerequest');
-
- $api->rerequest('KnpLabs', 'php-github-api', 14);
- }
-
- /**
- * @test
- */
- public function shouldGetAllCheckSuitesForReference()
- {
- /** @var CheckSuites|MockObject $api */
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/cb4abc15424c0015b4468d73df55efb8b60a4a3d/check-suites');
-
- $api->allForReference('KnpLabs', 'php-github-api', 'cb4abc15424c0015b4468d73df55efb8b60a4a3d');
- }
-
- protected function getApiClass(): string
- {
- return CheckSuites::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/CollaboratorsTest.php b/test/Github/Tests/Api/Repository/CollaboratorsTest.php
deleted file mode 100644
index 8bf57d96791..00000000000
--- a/test/Github/Tests/Api/Repository/CollaboratorsTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
- 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/collaborators')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldCheckIfRepositoryCollaborator()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->check('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldAddRepositoryCollaborator()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveRepositoryCollaborator()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetRepositoryCollaboratorPermission()
- {
- $expectedValue = [['permission' => 'admin', 'user' => 'l3l0']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0/permission')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->permission('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Collaborators::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/CommentsTest.php b/test/Github/Tests/Api/Repository/CommentsTest.php
deleted file mode 100644
index 949bf4e231d..00000000000
--- a/test/Github/Tests/Api/Repository/CommentsTest.php
+++ /dev/null
@@ -1,160 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/comments')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetSpecificCommitRepositoryComments()
- {
- $expectedValue = [['comment1data'], ['comment2data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 'commitSHA123456'));
- }
-
- /**
- * @test
- */
- public function shouldShowComment()
- {
- $expectedValue = ['comment1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/comments/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['line' => 53, 'path' => 'test.php', 'position' => 2];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryCommitComment()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'test body', 'line' => 53, 'path' => 'test.php', 'position' => 2];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryCommitCommentWithoutLine()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'body', 'path' => 'test.php', 'position' => 2];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments', $data)
- ->will($this->returnValue($expectedValue));
-
- $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateWithoutBody()
- {
- $this->expectException(MissingArgumentException::class);
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('KnpLabs', 'php-github-api', 'commitSHA123456', []);
- }
-
- /**
- * @test
- */
- public function shouldUpdateComment()
- {
- $expectedValue = ['comment1data'];
- $data = ['body' => 'body test'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/comments/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveComment()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/comments/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Comments::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/CommitsTest.php b/test/Github/Tests/Api/Repository/CommitsTest.php
deleted file mode 100644
index 9d1b3288afe..00000000000
--- a/test/Github/Tests/Api/Repository/CommitsTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
- [], 'comitter'];
- $data = ['sha' => 'v3'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldCompareTwoCommits()
- {
- $expectedValue = ['someCompareChanges'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/compare/v3...HEAD')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->compare('KnpLabs', 'php-github-api', 'v3', 'HEAD'));
- }
-
- /**
- * @test
- */
- public function shouldShowCommitUsingSha()
- {
- $expectedValue = ['sha' => '123', 'comitter'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldGetAllPullRequestsUsingSha()
- {
- $expectedValue = [
- ['number' => '1', 'title' => 'My first PR'],
- ['number' => '2', 'title' => 'Another PR'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/123/pulls')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->pulls('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Commits::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/ContentsTest.php b/test/Github/Tests/Api/Repository/ContentsTest.php
deleted file mode 100644
index 81a79db64fa..00000000000
--- a/test/Github/Tests/Api/Repository/ContentsTest.php
+++ /dev/null
@@ -1,347 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php'));
- }
-
- /**
- * @test
- */
- public function shouldShowReadme()
- {
- $expectedValue = 'README...';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/readme', ['ref' => null])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->readme('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldReturnTrueWhenFileExists()
- {
- $response = new Response(200);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('head')
- ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null])
- ->will($this->returnValue($response));
-
- $this->assertTrue($api->exists('KnpLabs', 'php-github-api', 'composer.json'));
- }
-
- public function getFailureStubsForExistsTest()
- {
- $response = new Response(403);
-
- return [
- [$this->throwException(new \ErrorException())],
- [$this->returnValue($response)],
- ];
- }
-
- /**
- * @param \PHPUnit_Framework_MockObject_Stub|\PHPUnit\Framework\MockObject\Stub\Exception
- *
- * @test
- *
- * @dataProvider getFailureStubsForExistsTest
- */
- public function shouldReturnFalseWhenFileIsNotFound($failureStub)
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('head')
- ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null])
- ->will($failureStub);
-
- $this->assertFalse($api->exists('KnpLabs', 'php-github-api', 'composer.json'));
- }
-
- /**
- * @test
- */
- public function shouldBubbleTwoFactorAuthenticationRequiredExceptionsWhenCheckingFileRequiringAuth()
- {
- $this->expectException(TwoFactorAuthenticationRequiredException::class);
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('head')
- ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null])
- ->will($this->throwException(new TwoFactorAuthenticationRequiredException(0)));
-
- $api->exists('KnpLabs', 'php-github-api', 'composer.json');
- }
-
- /**
- * @test
- */
- public function shouldCreateNewFile()
- {
- $expectedArray = ['content' => 'some data'];
- $content = ' 'committer name', 'email' => 'email@example.com'];
- $parameters = [
- 'content' => base64_encode($content),
- 'message' => $message,
- 'committer' => $committer,
- 'branch' => $branch,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters)
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->create('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $content, $message, $branch, $committer));
- }
-
- /**
- * @test
- */
- public function shouldThrowExceptionWhenCreateNewFileWithInvalidCommitter()
- {
- $this->expectException(MissingArgumentException::class);
- $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!');
- $committer = ['invalid_key' => 'some data'];
- $api = $this->getApiMock();
- $api->create('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, $committer);
- }
-
- /**
- * @test
- */
- public function shouldUpdateFile()
- {
- $expectedArray = ['content' => 'some data'];
- $content = ' 'committer name', 'email' => 'email@example.com'];
- $parameters = [
- 'content' => base64_encode($content),
- 'message' => $message,
- 'committer' => $committer,
- 'branch' => $branch,
- 'sha' => $sha,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters)
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->update('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $content, $message, $sha, $branch, $committer));
- }
-
- /**
- * @test
- */
- public function shouldThrowExceptionWhenUpdateFileWithInvalidCommitter()
- {
- $this->expectException(MissingArgumentException::class);
- $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!');
- $committer = ['invalid_key' => 'some data'];
- $api = $this->getApiMock();
- $api->update('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, null, $committer);
- }
-
- /**
- * @test
- */
- public function shouldDeleteFile()
- {
- $expectedArray = ['content' => 'some data'];
- $message = 'a commit message';
- $sha = 'a sha';
- $branch = 'master';
- $committer = ['name' => 'committer name', 'email' => 'email@example.com'];
- $parameters = [
- 'message' => $message,
- 'committer' => $committer,
- 'branch' => $branch,
- 'sha' => $sha,
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters)
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->rm('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $message, $sha, $branch, $committer));
- }
-
- /**
- * @test
- */
- public function shouldThrowExceptionWhenDeleteFileWithInvalidCommitter()
- {
- $this->expectException(MissingArgumentException::class);
- $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!');
- $committer = ['invalid_key' => 'some data'];
- $api = $this->getApiMock();
- $api->rm('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'a commit message', null, null, $committer);
- }
-
- /**
- * @test
- */
- public function shouldFetchTarballArchiveWhenFormatNotRecognized()
- {
- $expectedValue = 'tar';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/tarball')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'someFormat'));
- }
-
- /**
- * @test
- */
- public function shouldFetchTarballArchive()
- {
- $expectedValue = 'tar';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/tarball')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'tarball'));
- }
-
- /**
- * @test
- */
- public function shouldFetchZipballArchive()
- {
- $expectedValue = 'zip';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/zipball')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'zipball'));
- }
-
- /**
- * @test
- */
- public function shouldFetchZipballArchiveByReference()
- {
- $expectedValue = 'zip';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/zipball/master')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'zipball', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldDownloadForGivenPath()
- {
- // The show() method return
- $getValue = include __DIR__.'/fixtures/ContentsDownloadFixture.php';
-
- // The download() method return
- $expectedValue = base64_decode($getValue['content']);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null])
- ->will($this->returnValue($getValue));
-
- $this->assertEquals($expectedValue, $api->download('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php'));
- }
-
- /**
- * @test
- */
- public function shouldDownloadForSpacedPath()
- {
- // The show() method return
- $getValue = include __DIR__.'/fixtures/ContentsDownloadSpacedFixture.php';
-
- // The download() method return
- $expectedValue = base64_decode($getValue['content']);
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/mads379/scala.tmbundle/contents/Syntaxes%2FSimple%20Build%20Tool.tmLanguage', ['ref' => null])
- ->will($this->returnValue($getValue));
-
- $this->assertEquals($expectedValue, $api->download('mads379', 'scala.tmbundle', 'Syntaxes/Simple Build Tool.tmLanguage'));
- }
-
- /**
- * @test
- */
- public function shouldRawDownloadForGivenPath()
- {
- // The show() method return
- $getValue = include __DIR__.'/fixtures/ContentsDownloadFixture.php';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null])
- ->will($this->returnValue($getValue));
-
- $this->assertEquals($getValue, $api->rawDownload('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Contents::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/DeployKeysTest.php b/test/Github/Tests/Api/Repository/DeployKeysTest.php
deleted file mode 100644
index 2962390bc83..00000000000
--- a/test/Github/Tests/Api/Repository/DeployKeysTest.php
+++ /dev/null
@@ -1,167 +0,0 @@
- 'key']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/keys')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowDeployKey()
- {
- $expectedValue = ['key' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/keys/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldRemoveDeployKey()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/keys/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateDeployKeyWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['config' => 'conf'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateDeployKeyWithoutColor()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['name' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateDeployKey()
- {
- $expectedValue = ['key' => 'somename'];
- $data = ['title' => 'test', 'key' => 'ssh-rsa 1231234232'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/keys', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateDeployKeyWithoutTitle()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['key' => 'ssh-rsa 12323213'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('delete');
- $api->expects($this->never())
- ->method('post');
-
- $api->update('KnpLabs', 'php-github-api', 123, $data);
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateDeployKeyWithoutKey()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['title' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('delete');
- $api->expects($this->never())
- ->method('post');
-
- $api->update('KnpLabs', 'php-github-api', 123, $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateDeployKey()
- {
- $expectedValue = ['key' => 'somename'];
- $data = ['title' => 'test', 'key' => 'ssh-rsa 12312312321...'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/keys/123')
- ->will($this->returnValue($expectedValue));
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/keys', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\DeployKeys::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/DownloadsTest.php b/test/Github/Tests/Api/Repository/DownloadsTest.php
deleted file mode 100644
index f73b71491e4..00000000000
--- a/test/Github/Tests/Api/Repository/DownloadsTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/downloads')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowRepositoryDownload()
- {
- $expectedValue = ['download'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/downloads/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveRepositoryDownload()
- {
- $expectedValue = 'response';
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/downloads/l3l0')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Downloads::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/ForksTest.php b/test/Github/Tests/Api/Repository/ForksTest.php
deleted file mode 100644
index fbc6eb67212..00000000000
--- a/test/Github/Tests/Api/Repository/ForksTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
- 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldCreateFork()
- {
- $expectedValue = [['name' => 'l3l0repo']];
- $data = ['someparam'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/forks', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldSortByNewestWhenSortParamNotRecognized()
- {
- $expectedValue = [['name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1, 'sort' => 'newest'])
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'oldes']));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Forks::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/HooksTest.php b/test/Github/Tests/Api/Repository/HooksTest.php
deleted file mode 100644
index 00cdc69df2c..00000000000
--- a/test/Github/Tests/Api/Repository/HooksTest.php
+++ /dev/null
@@ -1,160 +0,0 @@
- 'hook']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/hooks')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowHook()
- {
- $expectedValue = ['hook' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/hooks/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldRemoveHook()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/hooks/123')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateHookWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['config' => 'conf'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateHookWithoutColor()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['name' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateHook()
- {
- $expectedValue = ['hook' => 'somename'];
- $data = ['name' => 'test', 'config' => 'someconfig'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/hooks', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotUpdateHookWithoutConfig()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['name' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('patch');
-
- $api->update('KnpLabs', 'php-github-api', 123, $data);
- }
-
- /**
- * @test
- */
- public function shouldUpdateHook()
- {
- $expectedValue = ['hook' => 'somename'];
- $data = ['name' => 'test', 'config' => 'config'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/hooks/123', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
- }
-
- /**
- * @test
- */
- public function shouldTestHook()
- {
- $expectedValue = [['name' => 'hook']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/hooks/123/tests')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->test('KnpLabs', 'php-github-api', 123));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Hooks::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/LabelsTest.php b/test/Github/Tests/Api/Repository/LabelsTest.php
deleted file mode 100644
index 4fe2fd81493..00000000000
--- a/test/Github/Tests/Api/Repository/LabelsTest.php
+++ /dev/null
@@ -1,129 +0,0 @@
- 'label']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/labels')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldShowLabel()
- {
- $expectedValue = ['label' => 'somename'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/labels/somename')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'somename'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveLabel()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/labels/somename')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'somename'));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateLabelWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['color' => 'red'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldNotCreateLabelWithoutColor()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['name' => 'test'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateLabel()
- {
- $expectedValue = ['label' => 'somename'];
- $data = ['name' => 'test', 'color' => 'red'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/labels', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldUpdateLabel()
- {
- $expectedValue = ['name' => 'test'];
- $data = ['new_name' => 'test', 'color' => 'red'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/labels/labelName', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'labelName', $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Labels::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/PagesTest.php b/test/Github/Tests/Api/Repository/PagesTest.php
deleted file mode 100644
index 2fde0df1622..00000000000
--- a/test/Github/Tests/Api/Repository/PagesTest.php
+++ /dev/null
@@ -1,150 +0,0 @@
- 'built'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/pages')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldEnablePages()
- {
- $params = [
- 'source' => [
- 'branch' => 'master',
- 'path' => '/path',
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/pages', $params);
-
- $api->enable('KnpLabs', 'php-github-api', $params);
- }
-
- /**
- * @test
- */
- public function shouldDisablePages()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/pages');
-
- $api->disable('KnpLabs', 'php-github-api');
- }
-
- /**
- * @test
- */
- public function shouldUpdatePages()
- {
- $params = [
- 'source' => 'master /docs',
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/pages', $params);
-
- $api->update('KnpLabs', 'php-github-api', $params);
- }
-
- /**
- * @test
- */
- public function shouldRequestPagesBuild()
- {
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/pages/builds');
-
- $api->requestBuild('KnpLabs', 'php-github-api');
- }
-
- /**
- * @test
- */
- public function shouldGetAllPagesBuilds()
- {
- $expectedValue = [['status' => 'built']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/pages/builds')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->builds('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetLatestPagesBuild()
- {
- $expectedValue = ['status' => 'built'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/pages/builds/latest')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showLatestBuild('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function showGetOnePagesBuild()
- {
- $expectedValue = ['status' => 'built'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/pages/builds/some')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showBuild('KnpLabs', 'php-github-api', 'some'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Pages::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/ProjectsTest.php b/test/Github/Tests/Api/Repository/ProjectsTest.php
deleted file mode 100644
index 225bda4baf6..00000000000
--- a/test/Github/Tests/Api/Repository/ProjectsTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
- 'Test project 1']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/projects')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateColumn()
- {
- $expectedValue = ['project1data'];
- $data = ['name' => 'Project 1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/projects', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Projects::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/ProtectionTest.php b/test/Github/Tests/Api/Repository/ProtectionTest.php
deleted file mode 100644
index f4f711dce74..00000000000
--- a/test/Github/Tests/Api/Repository/ProtectionTest.php
+++ /dev/null
@@ -1,444 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateProtection()
- {
- $expectedValue = ['required_status_checks', 'required_pull_reqeust_reviews', 'restrictions'];
- $data = ['required_status_checks' => null];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveProtection()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldShowStatusChecks()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showStatusChecks('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldUpdateStatusChecks()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->updateStatusChecks('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveStatusChecks()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeStatusChecks('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldShowStatusChecksContexts()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showStatusChecksContexts('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldReplaceStatusChecksContexts()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->replaceStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldAddStatusChecksContexts()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveStatusChecksContexts()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldShowPullRequestReviewEnforcement()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showPullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldUpdatePullRequestReviewEnforcement()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->updatePullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemovePullRequestReviewEnforcement()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removePullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldShowAdminEnforcement()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showAdminEnforcement('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldAddAdminEnforcement()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addAdminEnforcement('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveAdminEnforcement()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeAdminEnforcement('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldShowRestrictions()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showRestrictions('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldRemoveRestrictions()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeRestrictions('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldShowTeamRestrictions()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showTeamRestrictions('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldReplaceTeamRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->replaceTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldAddTeamRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveTeamRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldShowUserRestrictions()
- {
- $expectedValue = ['someOutput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->showUserRestrictions('KnpLabs', 'php-github-api', 'master'));
- }
-
- /**
- * @test
- */
- public function shouldReplaceUserRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('put')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->replaceUserRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldAddUserRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->addUserRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveUserRestrictions()
- {
- $expectedValue = ['someOutput'];
- $data = ['someInput'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->removeUserRestrictions('KnpLabs', 'php-github-api', 'master', $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Protection::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/ReleasesTest.php b/test/Github/Tests/Api/Repository/ReleasesTest.php
deleted file mode 100644
index dda8999a163..00000000000
--- a/test/Github/Tests/Api/Repository/ReleasesTest.php
+++ /dev/null
@@ -1,183 +0,0 @@
-getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases/latest')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->latest('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetReleaseByTag()
- {
- $expectedValue = ['latest_release_data'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases/tags/5f078080e01e0365690920d618f12342d2c941c8')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->tag(
- 'KnpLabs',
- 'php-github-api',
- '5f078080e01e0365690920d618f12342d2c941c8'
- ));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepositoryReleases()
- {
- $expectedValue = [['release1data'], ['release2data']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetSingleRepositoryRelease()
- {
- $expectedValue = ['releaseData'];
- $id = 331;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/releases/'.$id)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $id));
- }
-
- /**
- * @test
- */
- public function shouldGenerateReleaseNotes()
- {
- $expectedValue = [
- 'name' => 'Release v1.0.0 is now available!',
- 'body' => '##Changes in Release v1.0.0 ... ##Contributors @monalisa',
- ];
- $data = ['tag_name' => 'some-tag'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/releases/generate-notes')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->generateNotes('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldCreateRepositoryRelease()
- {
- $expectedValue = ['newReleaseData'];
- $data = ['tag_name' => '1.1'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/releases')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateRepositoryReleaseWithoutTagName()
- {
- $this->expectException(MissingArgumentException::class);
- $data = ['not_a_tag_name' => '1.1'];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', $data);
- }
-
- /**
- * @test
- */
- public function shouldEditRepositoryRelease()
- {
- $expectedValue = ['updatedData'];
- $id = 332;
- $data = ['some' => 'thing'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/releases/'.$id)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->edit('KnpLabs', 'php-github-api', $id, $data));
- }
-
- /**
- * @test
- */
- public function shouldRemoveRepositoryRelease()
- {
- $expectedValue = ['deleted'];
- $id = 333;
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('delete')
- ->with('/repos/KnpLabs/php-github-api/releases/'.$id)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', $id));
- }
-
- /**
- * @test
- */
- public function shouldGetAssetsApiObject()
- {
- $api = $this->getApiMock();
-
- $this->assertInstanceOf('Github\Api\Repository\Assets', $api->assets());
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Releases::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/SecretScanningTest.php b/test/Github/Tests/Api/Repository/SecretScanningTest.php
deleted file mode 100644
index e2e98dfa879..00000000000
--- a/test/Github/Tests/Api/Repository/SecretScanningTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
- 1, 'state' => 'resolved', 'resolution' => 'false_positive'],
- ['number' => 2, 'state' => 'open', 'resolution' => null],
- ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'],
- ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'],
- ];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->alerts('KnpLabs', 'php-github-api', [
- 'state' => 'all',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldGetAlert()
- {
- $expectedArray = ['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive'];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->getAlert('KnpLabs', 'php-github-api', 1));
- }
-
- /**
- * @test
- */
- public function shouldUpdateAlert()
- {
- $expectedArray = ['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive'];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('patch')
- ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/2')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->updateAlert('KnpLabs', 'php-github-api', 2, [
- 'state' => 'resolved',
- 'resolution' => 'false_positive',
- ]));
- }
-
- /**
- * @test
- */
- public function shouldGetLocations()
- {
- $expectedArray = [
- [
- 'type' => 'commit',
- 'details' => [
- 'path' => '/example/secrets.txt',
- 'start_line' => 1,
- 'end_line' => 1,
- 'start_column' => 1,
- 'end_column' => 64,
- 'blob_sha' => 'af5626b4a114abcb82d63db7c8082c3c4756e51b',
- 'blob_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/blobs/af5626b4a114abcb82d63db7c8082c3c4756e51b',
- 'commit_sha' => 'f14d7debf9775f957cf4f1e8176da0786431f72b',
- 'commit_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b',
- ],
- ],
- [
- 'type' => 'commit',
- 'details' => [
- 'path' => '/example/secrets.txt',
- 'start_line' => 5,
- 'end_line' => 5,
- 'start_column' => 1,
- 'end_column' => 64,
- 'blob_sha' => '9def38117ab2d8355b982429aa924e268b4b0065',
- 'blob_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/blobs/9def38117ab2d8355b982429aa924e268b4b0065',
- 'commit_sha' => '588483b99a46342501d99e3f10630cfc1219ea32',
- 'commit_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/commits/588483b99a46342501d99e3f10630cfc1219ea32',
- ],
- ],
- ];
-
- /** @var SecretScanning|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/2/locations')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->locations('KnpLabs', 'php-github-api', 2, [
- 'per_page' => 10,
- ]));
- }
-
- protected function getApiClass()
- {
- return \Github\Api\Repository\SecretScanning::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/StargazersTest.php b/test/Github/Tests/Api/Repository/StargazersTest.php
deleted file mode 100644
index 0552100556c..00000000000
--- a/test/Github/Tests/Api/Repository/StargazersTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 'nidup']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/stargazers')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldGetAllRepositoryStargazersWithAlternativeResponse()
- {
- $expectedValue = [['starred_at' => '2013-10-01T13:22:01Z', 'user' => ['login' => 'nidup']]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/stargazers')
- ->will($this->returnValue($expectedValue));
- $api->configure('star');
-
- $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Stargazers::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/StatusesTest.php b/test/Github/Tests/Api/Repository/StatusesTest.php
deleted file mode 100644
index e253955f25a..00000000000
--- a/test/Github/Tests/Api/Repository/StatusesTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
- 'success', 'context' => 'Travis'],
- ['state' => 'pending', 'context' => 'Travis'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/statuses')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'commitSHA123456'));
- }
-
- /**
- * @test
- */
- public function shouldShowCombinedCommitStatuses()
- {
- $expectedValue = [
- [
- 'state' => 'success',
- 'statuses' => [
- [
- 'state' => 'success',
- 'context' => 'Travis',
- ],
- [
- 'state' => 'success',
- 'context' => 'Jenkins',
- ],
- ],
- ],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/status')
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->combined('KnpLabs', 'php-github-api', 'commitSHA123456'));
- }
-
- /**
- * @test
- */
- public function shouldNotCreateWithoutStatus()
- {
- $this->expectException(MissingArgumentException::class);
- $data = [];
-
- $api = $this->getApiMock();
- $api->expects($this->never())
- ->method('post');
-
- $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data);
- }
-
- /**
- * @test
- */
- public function shouldCreateCommitStatus()
- {
- $expectedValue = ['state' => 'success'];
- $data = ['state' => 'success'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('post')
- ->with('/repos/KnpLabs/php-github-api/statuses/commitSHA123456', $data)
- ->will($this->returnValue($expectedValue));
-
- $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Repository\Statuses::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/TrafficTest.php b/test/Github/Tests/Api/Repository/TrafficTest.php
deleted file mode 100644
index b6136cebe86..00000000000
--- a/test/Github/Tests/Api/Repository/TrafficTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
- 'github.com', 'count' => 112, 'uniques' => 15]);
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/traffic/popular/referrers')
- ->will($this->returnValue($expectedValue));
-
- $result = $api->referers('knplabs', 'php-github-api');
-
- $this->assertEquals($expectedValue, $result);
- }
-
- public function shouldgetPaths()
- {
- $expectedValue = json_encode(['path' => '/knplabs/php-github-api', 'title' => 'KnpLabs/php-github-api: A simple PHP GitHub API client, Object Oriented, tested and documented. For 5.5+.', 'count' => 203, 'uniques' => 54]);
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/traffic/popular/paths')
- ->will($this->returnValue($expectedValue));
-
- $result = $api->paths('knplabs', 'php-github-api');
-
- $this->assertEquals($expectedValue, $result);
- }
-
- public function shouldgetViews()
- {
- $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'views' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 40, 'uniques' => 3]]]);
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/traffic/views?per=day')
- ->will($this->returnValue($expectedValue));
-
- $result = $api->views('knplabs', 'php-github-api');
-
- $this->assertEquals($expectedValue, $result);
- }
-
- public function shouldgetClones()
- {
- $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'clones' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 14, 'uniques' => 8]]]);
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/repos/knplabs/php-github-api/traffic/clones?per=day')
- ->will($this->returnValue($expectedValue));
-
- $result = $api->clones('knplabs', 'php-github-api');
-
- $this->assertEquals($expectedValue, $result);
- }
-
- protected function getApiClass()
- {
- return \Github\Api\Repository\Traffic::class;
- }
-}
diff --git a/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php b/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php
deleted file mode 100644
index a403c2feb23..00000000000
--- a/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php
+++ /dev/null
@@ -1,6 +0,0 @@
- '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/repositories',
- ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->repositories('query text'));
- }
-
- /**
- * @test
- */
- public function shouldSearchRepositoriesRegardingSortAndOrder()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/repositories',
- ['q' => 'query text', 'sort' => 'created', 'order' => 'asc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->repositories('query text', 'created', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchIssuesByQuery()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/issues',
- ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->issues('query text'));
- }
-
- /**
- * @test
- */
- public function shouldSearchIssuesRegardingSortAndOrder()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/issues',
- ['q' => 'query text', 'sort' => 'created', 'order' => 'asc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->issues('query text', 'created', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchCodeByQuery()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/code',
- ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->code('query text'));
- }
-
- /**
- * @test
- */
- public function shouldSearchCodeRegardingSortAndOrder()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/code',
- ['q' => 'query text', 'sort' => 'created', 'order' => 'asc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->code('query text', 'created', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchCodeWithMatchByQuery()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/code',
- ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->codeWithMatch('query text'));
- }
-
- /**
- * @test
- */
- public function shouldSearchCodeWithMatchRegardingSortAndOrder()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/code',
- ['q' => 'query text', 'sort' => 'created', 'order' => 'asc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->codeWithMatch('query text', 'created', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchUsersByQuery()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/users',
- ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->users('query text'));
- }
-
- /**
- * @test
- */
- public function shouldSearchUsersRegardingSortAndOrder()
- {
- $expectedArray = [['total_count' => '0']];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with(
- '/search/users',
- ['q' => 'query text', 'sort' => 'created', 'order' => 'asc']
- )
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->users('query text', 'created', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchCommitsRegardingSortAndOrder()
- {
- $expectedArray = ['total_count' => '0'];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/search/commits', ['q' => 'query text', 'sort' => 'author-date', 'order' => 'asc'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->commits('query text', 'author-date', 'asc')
- );
- }
-
- /**
- * @test
- */
- public function shouldSearchTopics()
- {
- $expectedArray = ['total_count' => '0'];
-
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/search/topics', ['q' => 'query text'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals(
- $expectedArray,
- $api->topics('query text')
- );
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\Search::class;
- }
-}
diff --git a/test/Github/Tests/Api/User/MigrationTest.php b/test/Github/Tests/Api/User/MigrationTest.php
deleted file mode 100644
index 3ee1620a3ae..00000000000
--- a/test/Github/Tests/Api/User/MigrationTest.php
+++ /dev/null
@@ -1,186 +0,0 @@
- 79,
- 'state' => 'pending',
- 'lock_repositories' => true,
- 'repositories' => [
- [
- 'id' => 1296269,
- 'name' => 'Hello-World',
- 'full_name' => 'octocat/Hello-World',
- ],
- ],
- ],
- [
- 'id' => 2,
- 'name' => 'pending',
- 'lock_repositories' => false,
- 'repositories' => [
- [
- 'id' => 123,
- 'name' => 'php-github-api',
- 'full_name' => 'KnpLabs/php-github-api',
- ],
- ],
- ],
- ];
-
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api
- ->expects($this->once())
- ->method('get')
- ->with('/user/migrations')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->list());
- }
-
- /**
- * @test
- */
- public function shouldStartMigration()
- {
- $expectedArray = [
- 'id' => 79,
- 'state' => 'pending',
- 'lock_repositories' => true,
- 'repositories' => [
- [
- 'id' => 1296269,
- 'name' => 'Hello-World',
- 'full_name' => 'octocat/Hello-World',
- ],
- ],
- ];
-
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('post')
- ->with('/user/migrations')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->start([
- 'lock_repositories' => true,
- 'repositories' => [
- 'KnpLabs/php-github-api',
- ],
- ]));
- }
-
- /**
- * @test
- */
- public function shouldGetMigrationStatus()
- {
- $expectedArray = [
- 'id' => 79,
- 'state' => 'exported',
- 'lock_repositories' => true,
- 'repositories' => [
- [
- 'id' => 1296269,
- 'name' => 'Hello-World',
- 'full_name' => 'octocat/Hello-World',
- ],
- ],
- ];
-
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/user/migrations/79')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->status(79));
- }
-
- /**
- * @test
- */
- public function shouldDeleteMigrationArchive()
- {
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/migrations/79/archive')
- ->will($this->returnValue(204));
-
- $this->assertEquals(204, $api->deleteArchive(79));
- }
-
- /**
- * @test
- */
- public function shouldUnlockUserRepo()
- {
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('delete')
- ->with('/user/migrations/79/repos/php-github-api/lock')
- ->will($this->returnValue(204));
-
- $this->assertEquals(204, $api->unlockRepo(79, 'php-github-api'));
- }
-
- /**
- * @test
- */
- public function shouldListRepos()
- {
- $expectedArray = [
- [
- 'id' => 1296269,
- 'name' => 'Hello-World',
- 'full_name' => 'test/Hello-World',
- ],
- [
- 'id' => 234324,
- 'name' => 'Hello-World2',
- 'full_name' => 'test/Hello-World2',
- ],
- ];
-
- /** @var Migration|MockObject $api */
- $api = $this->getApiMock();
-
- $api->expects($this->once())
- ->method('get')
- ->with('/user/migrations/79/repositories')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->repos(79));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\User\Migration::class;
- }
-}
diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php
deleted file mode 100644
index 0be80a28f01..00000000000
--- a/test/Github/Tests/Api/UserTest.php
+++ /dev/null
@@ -1,261 +0,0 @@
- 1, 'username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->show('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldShowByIdUser()
- {
- $expectedArray = ['id' => 1, 'username' => 'l3l0'];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/1')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->showById(1));
- }
-
- /**
- * @test
- */
- public function shouldGetUserOrganizations()
- {
- $expectedArray = [[
- 'id' => 202732,
- 'url' => 'https://api.github.com/orgs/KnpLabs',
- 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos',
- 'events_url' => 'https://api.github.com/orgs/KnpLabs/events',
- 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}',
- 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}',
- ]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/orgs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->organizations('l3l0'));
- }
-
- public function shouldGetUserOrgs()
- {
- $expectedArray = [[
- 'id' => 202732,
- 'url' => 'https://api.github.com/orgs/KnpLabs',
- 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos',
- 'events_url' => 'https://api.github.com/orgs/KnpLabs/events',
- 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}',
- 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}',
- ]];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/user/orgs')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->orgs());
- }
-
- /**
- * @test
- */
- public function shouldGetAllUsers()
- {
- $expectedArray = [
- ['id' => 1, 'username' => 'l3l0'],
- ['id' => 2, 'username' => 'l3l0test'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all());
- }
-
- /**
- * @test
- */
- public function shouldGetAllUsersSince()
- {
- $expectedArray = [
- ['id' => 3, 'username' => 'test3'],
- ['id' => 4, 'username' => 'test4'],
- ];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users', ['since' => 2])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->all(2));
- }
-
- /**
- * @test
- */
- public function shouldGetFollowingUsers()
- {
- $expectedArray = [['id' => 1, 'username' => 'l3l0test']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/following')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->following('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetUserFollowers()
- {
- $expectedArray = [['id' => 1, 'username' => 'l3l0test']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/followers')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->followers('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetStarredToRepositories()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/starred', ['page' => 2, 'per_page' => 30, 'sort' => 'created', 'direction' => 'desc'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->starred('l3l0', 2));
- }
-
- /**
- * @test
- */
- public function shouldGetSubscriptionsToRepositories()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/subscriptions')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->subscriptions('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetUserRepositories()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/repos', ['type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc', 'visibility' => 'all', 'affiliation' => 'owner,collaborator,organization_member'])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->repositories('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetMyRepositories()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')->with('/user/repos', [])
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->myRepositories());
- }
-
- /**
- * @test
- */
- public function shouldGetUserGists()
- {
- $expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
-
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/gists')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->gists('l3l0'));
- }
-
- /**
- * @test
- */
- public function shouldGetAuthorizedUserEvents()
- {
- $expectedArray = [
- [
- 'id' => 1,
- 'actor' => [
- 'id' => 1,
- 'login' => 'l3l0',
- ],
- ],
- ];
- $api = $this->getApiMock();
- $api->expects($this->once())
- ->method('get')
- ->with('/users/l3l0/events')
- ->will($this->returnValue($expectedArray));
-
- $this->assertEquals($expectedArray, $api->events('l3l0'));
- }
-
- /**
- * @return string
- */
- protected function getApiClass()
- {
- return \Github\Api\User::class;
- }
-}
diff --git a/test/Github/Tests/Functional/CacheTest.php b/test/Github/Tests/Functional/CacheTest.php
deleted file mode 100644
index bd217dc5dc2..00000000000
--- a/test/Github/Tests/Functional/CacheTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
- */
-class CacheTest extends \PHPUnit\Framework\TestCase
-{
- /**
- * @test
- */
- public function shouldServeCachedResponse()
- {
- $mockClient = new \Http\Mock\Client();
- $mockClient->addResponse($this->getCurrentUserResponse('nyholm'));
- $mockClient->addResponse($this->getCurrentUserResponse('octocat'));
-
- $github = Client::createWithHttpClient($mockClient);
- $github->addCache(new ArrayAdapter(), ['default_ttl' => 600]);
-
- $github->authenticate('fake_token_aaa', AuthMethod::ACCESS_TOKEN);
- $userA = $github->currentUser()->show();
- $this->assertEquals('nyholm', $userA['login']);
-
- $userB = $github->currentUser()->show();
- $this->assertEquals('nyholm', $userB['login'], 'Two request following each other should be cached.');
- }
-
- /**
- * @test
- */
- public function shouldVaryOnAuthorization()
- {
- $mockClient = new \Http\Mock\Client();
- $mockClient->addResponse($this->getCurrentUserResponse('nyholm'));
- $mockClient->addResponse($this->getCurrentUserResponse('octocat'));
-
- $github = Client::createWithHttpClient($mockClient);
- $github->addCache(new ArrayAdapter(), ['default_ttl' => 600]);
-
- $github->authenticate('fake_token_aaa', AuthMethod::ACCESS_TOKEN);
- $userA = $github->currentUser()->show();
- $this->assertEquals('nyholm', $userA['login']);
-
- $github->authenticate('fake_token_bbb', AuthMethod::ACCESS_TOKEN);
- $userB = $github->currentUser()->show();
- $this->assertEquals('octocat', $userB['login'], 'We must vary on the Authorization header.');
- }
-
- private function getCurrentUserResponse($username)
- {
- $headers = [
- 'Content-Type' => 'application/json',
- ];
-
- $body = Utils::streamFor(json_encode([
- 'login' => $username,
- ]));
-
- return new Response(200, $headers, $body);
- }
-}
diff --git a/test/Github/Tests/Integration/CommitTest.php b/test/Github/Tests/Integration/CommitTest.php
deleted file mode 100644
index 2134bab2f65..00000000000
--- a/test/Github/Tests/Integration/CommitTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-client->api('repo')->commits()->all($username, $repo, ['sha' => $branch]);
- $commit = array_pop($commits);
-
- $this->assertArrayHasKey('url', $commit);
- $this->assertArrayHasKey('committer', $commit);
- $this->assertArrayHasKey('author', $commit);
- $this->assertArrayHasKey('commit', $commit);
- $this->assertArrayHasKey('sha', $commit);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveCommitBySha()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $commit = $this->client->api('repo')->commits()->show($username, $repo, '6df3adf5bd16745299c6429e163265daed430fa1');
-
- $this->assertArrayHasKey('url', $commit);
- $this->assertArrayHasKey('committer', $commit);
- $this->assertArrayHasKey('author', $commit);
- $this->assertArrayHasKey('commit', $commit);
- $this->assertArrayHasKey('sha', $commit);
- $this->assertArrayHasKey('files', $commit);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveCommitsForFile()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
- $branch = 'master';
-
- $commits = $this->client->api('repo')->commits()->all($username, $repo, ['sha' => $branch, 'path' => 'composer.json']);
- $commit = array_pop($commits);
-
- $this->assertArrayHasKey('url', $commit);
- $this->assertArrayHasKey('committer', $commit);
- $this->assertArrayHasKey('author', $commit);
- $this->assertArrayHasKey('commit', $commit);
- $this->assertArrayHasKey('sha', $commit);
- }
-}
diff --git a/test/Github/Tests/Integration/GistTest.php b/test/Github/Tests/Integration/GistTest.php
deleted file mode 100644
index deb079f57e6..00000000000
--- a/test/Github/Tests/Integration/GistTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-client->api('gists')->all();
- $gist = array_pop($gists);
-
- $this->assertArrayHasKey('url', $gist);
- $this->assertArrayHasKey('files', $gist);
- $this->assertArrayHasKey('comments', $gist);
- $this->assertArrayHasKey('created_at', $gist);
- $this->assertArrayHasKey('updated_at', $gist);
- $this->assertArrayHasKey('user', $gist);
- }
-
- /**
- * @test
- */
- public function shouldNotGetStarredListWithoutAuthorization()
- {
- $this->expectException(RuntimeException::class);
- $this->client->api('gists')->all('starred');
- }
-
- /**
- * @test
- */
- public function shouldRetrievePublicGistsList()
- {
- $gists = $this->client->api('gists')->all('public');
- $gist = array_pop($gists);
-
- $this->assertArrayHasKey('url', $gist);
- $this->assertArrayHasKey('files', $gist);
- $this->assertArrayHasKey('comments', $gist);
- $this->assertArrayHasKey('created_at', $gist);
- $this->assertArrayHasKey('updated_at', $gist);
- $this->assertArrayHasKey('user', $gist);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveGistById()
- {
- $id = 1;
-
- $gist = $this->client->api('gists')->show($id);
-
- $this->assertArrayHasKey('url', $gist);
- $this->assertArrayHasKey('files', $gist);
- $this->assertArrayHasKey('comments', $gist);
- $this->assertArrayHasKey('created_at', $gist);
- $this->assertArrayHasKey('updated_at', $gist);
- $this->assertArrayHasKey('user', $gist);
- $this->assertArrayHasKey('gistfile1.txt', $gist['files']);
- $this->assertEquals('schacon', $gist['user']['login']);
- }
-}
diff --git a/test/Github/Tests/Integration/IssueCommentTest.php b/test/Github/Tests/Integration/IssueCommentTest.php
deleted file mode 100644
index 0cb39a1f8e3..00000000000
--- a/test/Github/Tests/Integration/IssueCommentTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-client->api('issue')->comments()->all($username, $repo, $issue);
- $comment = array_pop($comments);
-
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldRetrieveCommentsForIssue
- */
- public function shouldRetrieveSingleComment($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $comment = $this->client->api('issue')->comments()->show($username, $repo, $commentId);
-
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
- }
-
- /**
- * @test
- */
- public function shouldCreateCommentForIssue()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
- $issue = 13;
- $params = ['body' => '%'];
-
- $comment = $this->client->api('issue')->comments()->create($username, $repo, $issue, $params);
-
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldCreateCommentForIssue
- */
- public function shouldUpdateCommentByCommentId($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
- $params = ['body' => 'test update'];
-
- $comment = $this->client->api('issue')->comments()->update($username, $repo, $commentId, $params);
-
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldUpdateCommentByCommentId
- */
- public function shouldRemoveCommentByCommentId($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $this->client->api('issue')->comments()->remove($username, $repo, $commentId);
- }
-}
diff --git a/test/Github/Tests/Integration/MarkdownTest.php b/test/Github/Tests/Integration/MarkdownTest.php
deleted file mode 100644
index 1dd956019fe..00000000000
--- a/test/Github/Tests/Integration/MarkdownTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-client->api('markdown');
-
- $input = 'Hello world github/linguist#1 **cool**, and #1!';
- $output = 'Hello world github/linguist#1 cool, and #1!
';
- $html = $api->render($input);
-
- $this->assertEquals($output, $html);
-
- $input = 'Hello world KnpLabs/KnpBundles#1 **cool**, and #1!';
- $output = 'Hello world KnpLabs/KnpBundles#1 cool, and #1!
';
- $html = $api->render($input, 'gfm', 'KnpLabs/KnpMenu');
-
- $this->assertEquals($output, $html);
- }
-}
diff --git a/test/Github/Tests/Integration/RateLimitTest.php b/test/Github/Tests/Integration/RateLimitTest.php
deleted file mode 100644
index b003e5b0604..00000000000
--- a/test/Github/Tests/Integration/RateLimitTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-client->api('rate_limit')->getRateLimits();
-
- $this->assertArrayHasKey('resources', $response);
- $this->assertArrayHasKey('resources', $response);
- $this->assertSame(['core' => ['limit' => 60]], $response['resources']);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveRateLimitsAndReturnLimitInstances()
- {
- $response = $this->client->api('rate_limit')->getLimits();
-
- $this->assertIsArray($response);
- $this->assertContainsOnlyInstancesOf(RateLimitResource::class, $response);
- $this->assertEquals(60, $response->getLimit('core')->getLimit());
- }
-}
diff --git a/test/Github/Tests/Integration/RepoCommentTest.php b/test/Github/Tests/Integration/RepoCommentTest.php
deleted file mode 100644
index 352dac4b7ff..00000000000
--- a/test/Github/Tests/Integration/RepoCommentTest.php
+++ /dev/null
@@ -1,128 +0,0 @@
-client->api('repo')->comments()->all($username, $repo);
- $comment = array_pop($comments);
-
- $this->assertArrayHasKey('line', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveCommentsForCommit()
- {
- $username = 'fabpot';
- $repo = 'Twig';
- $sha = '3506cfad1d946f4a87e8c55849a18044efe2d5dc';
-
- $comments = $this->client->api('repo')->comments()->all($username, $repo, $sha);
- $comment = array_pop($comments);
-
- $this->assertArrayHasKey('line', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('url', $comment);
- }
-
- /**
- * @test
- */
- public function shouldCreateCommentForCommit()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
- $sha = '22655813eb54e7d4e21545e396f919bcd245b50d';
- $params = ['body' => '%'];
-
- $comment = $this->client->api('repo')->comments()->create($username, $repo, $sha, $params);
-
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldCreateCommentForCommit
- */
- public function shouldShowCommentByCommentId($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $comment = $this->client->api('repo')->comments()->show($username, $repo, $commentId);
-
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldShowCommentByCommentId
- */
- public function shouldUpdateCommentByCommentId($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
- $params = ['body' => 'test update'];
-
- $comment = $this->client->api('repo')->comments()->update($username, $repo, $commentId, $params);
-
- $this->assertArrayHasKey('created_at', $comment);
- $this->assertArrayHasKey('updated_at', $comment);
- $this->assertArrayHasKey('url', $comment);
- $this->assertArrayHasKey('id', $comment);
- $this->assertArrayHasKey('body', $comment);
- $this->assertArrayHasKey('user', $comment);
-
- return $comment['id'];
- }
-
- /**
- * @test
- *
- * @depends shouldUpdateCommentByCommentId
- */
- public function shouldRemoveCommentByCommentId($commentId)
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $this->client->api('repo')->comments()->remove($username, $repo, $commentId);
- }
-}
diff --git a/test/Github/Tests/Integration/RepoTest.php b/test/Github/Tests/Integration/RepoTest.php
deleted file mode 100644
index 2d958e35713..00000000000
--- a/test/Github/Tests/Integration/RepoTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-client->addHeaders(
- ['Accept' => sprintf(
- 'application/vnd.github.%s.diff',
- $this->client->getApiVersion()
- )]
- );
-
- $diff = $this->client->api('pull_request')->show('KnpLabs', 'php-github-api', '92');
-
- $this->assertIsString($diff);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveRawBlob()
- {
- $api = $this->client->api('git_data')->blobs();
- $api->configure('raw');
-
- $contents = $api->show(
- 'KnpLabs',
- 'php-github-api',
- 'e50d5e946385cff052636e2f09f36b03d1c368f4'
- );
-
- $this->assertIsString($contents);
- $this->assertStringStartsWith('client->api('git_data')->blobs();
- $api->configure('raw');
-
- $contents = $api->show(
- 'KnpLabs',
- 'php-github-api',
- 'dc16d3e77fd4e40638cb722927ffe15fa85b1434'
- );
-
- $this->assertIsString($contents);
- $this->assertStringStartsWith('{', $contents);
- }
-
- /**
- * @test
- */
- public function shouldRetrieveContributorsList()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $contributors = $this->client->api('repo')->contributors($username, $repo);
- $contributor = array_pop($contributors);
-
- $this->assertArrayHasKey('url', $contributor);
- $this->assertArrayHasKey('gravatar_id', $contributor);
- $this->assertArrayHasKey('contributions', $contributor);
- $this->assertArrayHasKey('avatar_url', $contributor);
- $this->assertArrayHasKey('login', $contributor);
- $this->assertArrayHasKey('id', $contributor);
- }
-
- /**
- * @test
- */
- public function shouldShowRepo()
- {
- $username = 'KnpLabs';
- $repo = 'php-github-api';
-
- $repo = $this->client->api('repo')->show($username, $repo);
-
- $this->assertArrayHasKey('id', $repo);
- $this->assertArrayHasKey('name', $repo);
- $this->assertArrayHasKey('description', $repo);
- $this->assertArrayHasKey('url', $repo);
- $this->assertArrayHasKey('has_wiki', $repo);
- $this->assertArrayHasKey('has_issues', $repo);
- $this->assertArrayHasKey('forks', $repo);
- $this->assertArrayHasKey('updated_at', $repo);
- $this->assertArrayHasKey('created_at', $repo);
- $this->assertArrayHasKey('pushed_at', $repo);
- $this->assertArrayHasKey('open_issues', $repo);
- $this->assertArrayHasKey('ssh_url', $repo);
- $this->assertArrayHasKey('git_url', $repo);
- $this->assertArrayHasKey('svn_url', $repo);
- }
-}
diff --git a/test/Github/Tests/Integration/ResultPagerTest.php b/test/Github/Tests/Integration/ResultPagerTest.php
deleted file mode 100644
index 4dd24e37904..00000000000
--- a/test/Github/Tests/Integration/ResultPagerTest.php
+++ /dev/null
@@ -1,38 +0,0 @@
-client->search();
-
- $pager = $this->createPager();
- $users = $pager->fetch($searchApi, 'users', ['location:Kyiv']);
- $this->assertCount(10, $users);
- }
-
- private function createPager()
- {
- return new ResultPager($this->client);
- }
-}
diff --git a/test/Github/Tests/Mock/PaginatedResponse.php b/test/Github/Tests/Mock/PaginatedResponse.php
deleted file mode 100644
index 296adf86457..00000000000
--- a/test/Github/Tests/Mock/PaginatedResponse.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- */
-class PaginatedResponse extends Response
-{
- protected $loopCount;
-
- protected $content;
-
- public function __construct($loopCount, array $content = [])
- {
- $this->loopCount = $loopCount;
- $this->content = $content;
-
- parent::__construct(200, ['Content-Type' => 'application/json'], Utils::streamFor(json_encode($content)));
- }
-
- public function getHeader($header): array
- {
- if ($header === 'Link') {
- if ($this->loopCount > 1) {
- $header = [sprintf('; rel="next"', $this->loopCount)];
- } else {
- $header = ['; rel="prev"'];
- }
-
- $this->loopCount--;
-
- return $header;
- }
-
- return parent::getHeader($header);
- }
-
- public function hasHeader($header): bool
- {
- if ($header === 'Link') {
- return true;
- }
-
- return parent::hasHeader($header);
- }
-}
diff --git a/test/Github/Tests/ResultPagerTest.php b/test/Github/Tests/ResultPagerTest.php
deleted file mode 100644
index b898528483b..00000000000
--- a/test/Github/Tests/ResultPagerTest.php
+++ /dev/null
@@ -1,304 +0,0 @@
-
- * @author Mitchel Verschoof
- * @author Tobias Nyholm
- */
-class ResultPagerTest extends \PHPUnit\Framework\TestCase
-{
- use ExpectDeprecationTrait;
-
- public function provideFetchCases()
- {
- return [
- ['fetchAll'],
- ['fetchAllLazy'],
- ];
- }
-
- /**
- * @test provideFetchCases
- *
- * @dataProvider provideFetchCases
- */
- public function shouldGetAllResults(string $fetchMethod)
- {
- $amountLoops = 3;
- $content = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- $response = new PaginatedResponse($amountLoops, $content);
-
- // httpClient mock
- $httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->expects($this->exactly($amountLoops))
- ->method('sendRequest')
- ->will($this->returnValue($response));
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- // memberApi Mock
- $memberApi = new Members($client);
-
- $method = 'all';
- $parameters = ['netwerven'];
-
- // Run fetchAll on result paginator
- $paginator = new ResultPager($client);
-
- $result = $paginator->$fetchMethod($memberApi, $method, $parameters);
-
- if (is_array($result)) {
- $this->assertSame('fetchAll', $fetchMethod);
- } else {
- $result = iterator_to_array($result);
- }
-
- $this->assertCount($amountLoops * count($content), $result);
- }
-
- /**
- * @test
- *
- * response in a search api has different format:
- *
- * {
- * "total_count": 1,
- * "incomplete_results": false,
- * "items": []
- * }
- *
- * and we need to extract result from `items`
- */
- public function shouldGetAllSearchResults()
- {
- $amountLoops = 3;
-
- $content = [
- 'total_count' => 12,
- 'items' => [1, 2, 3, 4],
- ];
- $response = new PaginatedResponse($amountLoops, $content);
-
- // httpClient mock
- $httpClientMock = $this->getMockBuilder(ClientInterface::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->expects($this->exactly($amountLoops))
- ->method('sendRequest')
- ->willReturn($response);
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- $searchApi = new Search($client);
- $method = 'users';
- $paginator = new ResultPager($client);
- $result = $paginator->fetchAll($searchApi, $method, ['knplabs']);
-
- $this->assertCount($amountLoops * count($content['items']), $result);
- }
-
- /**
- * @test
- */
- public function shouldHandleEmptyContributorListWith204Header()
- {
- // Set up a 204 response with an empty body
- $response = new Response(204, [], '');
- $username = 'testuser';
- $reponame = 'testrepo';
-
- // Mock the HttpClient to return the empty response
- $httpClientMock = $this->getMockBuilder(HttpClient::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->method('sendRequest')
- ->willReturn($response);
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- $repoApi = new Repo($client);
-
- $paginator = $this->getMockBuilder(ResultPager::class)
- ->setConstructorArgs([$client]) // Pass the Client in the constructor
- ->onlyMethods(['fetchAll'])
- ->getMock();
- $paginator->expects($this->once())
- ->method('fetchAll')
- ->with($repoApi, 'contributors', [$username, $reponame])
- ->willReturn([]);
-
- $this->assertEquals([], $paginator->fetchAll($repoApi, 'contributors', [$username, $reponame]));
- }
-
- public function testFetch()
- {
- $result = ['foo'];
- $method = 'all';
- $parameters = ['baz'];
- $api = $this->getMockBuilder(Members::class)
- ->disableOriginalConstructor()
- ->onlyMethods(['all'])
- ->getMock();
- $api->expects($this->once())
- ->method('all')
- ->with(...$parameters)
- ->willReturn($result);
-
- $paginator = $this->getMockBuilder(ResultPager::class)
- ->disableOriginalConstructor()
- ->onlyMethods(['postFetch'])
- ->getMock();
-
- $paginator->expects($this->once())
- ->method('postFetch');
-
- $this->assertEquals($result, $paginator->fetch($api, $method, $parameters));
- }
-
- public function testEmptyFetch()
- {
- $parameters = ['username'];
- $api = $this->getMockBuilder(User::class)
- ->disableOriginalConstructor()
- ->onlyMethods(['events'])
- ->getMock();
- $api->expects($this->once())
- ->method('events')
- ->with(...$parameters)
- ->willReturn('');
-
- $paginator = $this->getMockBuilder(ResultPager::class)
- ->disableOriginalConstructor()
- ->onlyMethods(['postFetch'])
- ->getMock();
-
- $paginator->expects($this->once())
- ->method('postFetch');
-
- $this->assertEquals([], $paginator->fetch($api, 'events', $parameters));
- }
-
- public function testFetchAllPreserveKeys()
- {
- $content = [
- 'state' => 'success',
- 'statuses' => [
- ['description' => 'status 1', 'state' => 'success'],
- ['description' => 'status 2', 'state' => 'failure'],
- ],
- 'sha' => '43068834af7e501778708ed13106de95f782328c',
- ];
-
- $response = new Response(200, ['Content-Type' => 'application/json'], Utils::streamFor(json_encode($content)));
-
- // httpClient mock
- $httpClientMock = $this->getMockBuilder(HttpClient::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->method('sendRequest')
- ->willReturn($response);
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- $api = new Statuses($client);
- $paginator = new ResultPager($client);
- $result = $paginator->fetchAll($api, 'combined', ['knplabs', 'php-github-api', '43068834af7e501778708ed13106de95f782328c']);
-
- $this->assertArrayHasKey('state', $result);
- $this->assertArrayHasKey('statuses', $result);
- $this->assertCount(2, $result['statuses']);
- }
-
- public function testFetchAllWithoutKeys()
- {
- $content = [
- ['title' => 'issue 1'],
- ['title' => 'issue 2'],
- ['title' => 'issue 3'],
- ];
-
- $response = new PaginatedResponse(3, $content);
-
- // httpClient mock
- $httpClientMock = $this->getMockBuilder(HttpClient::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->expects($this->exactly(3))
- ->method('sendRequest')
- ->willReturn($response);
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- $api = new Issue($client);
- $paginator = new ResultPager($client);
- $result = $paginator->fetchAll($api, 'all', ['knplabs', 'php-github-api']);
-
- $this->assertCount(9, $result);
- }
-
- public function testFetchAll()
- {
- $content = [
- ['title' => 'issue 1'],
- ['title' => 'issue 2'],
- ['title' => 'issue 3'],
- ];
-
- $response = new PaginatedResponse(3, $content);
-
- // httpClient mock
- $httpClientMock = $this->getMockBuilder(HttpClient::class)
- ->onlyMethods(['sendRequest'])
- ->getMock();
- $httpClientMock
- ->expects($this->exactly(3))
- ->method('sendRequest')
- ->willReturn($response);
-
- $client = Client::createWithHttpClient($httpClientMock);
-
- $api = new Issue($client);
- $paginator = new ResultPager($client);
- $result = $paginator->fetchAll($api, 'all', ['knplabs', 'php-github-api']);
-
- $this->assertCount(9, $result);
- }
-
- /**
- * @group legacy
- */
- public function testPostFetchDeprecation()
- {
- $this->expectDeprecation('Since KnpLabs/php-github-api 3.2: The "Github\ResultPager::postFetch" method is deprecated and will be removed.');
-
- $clientMock = $this->createMock(Client::class);
- $clientMock->method('getLastResponse')->willReturn(new PaginatedResponse(3, []));
-
- $paginator = new ResultPager($clientMock);
- $paginator->postFetch();
- }
-}