From 9b93f7b64f7afedceb62144ae7d0c2abaa87ae22 Mon Sep 17 00:00:00 2001 From: MBorne Date: Sat, 24 Nov 2018 17:21:06 +0100 Subject: [PATCH] travis - add auth token for GITHUB --- README.md | 7 +++++-- tests/Git/GithubClientTest.php | 32 +++++++++++++++++++------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4106a4d..2a1c2bd 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,11 @@ satis-gitlab is licensed under the MIT License - see the [LICENSE](LICENSE) file ## Testing ```bash -SATIS_GITLAB_TOKEN=YouGitlabToken make test +export SATIS_GITLAB_TOKEN=YouGitlabToken +export SATIS_GITHUB_TOKEN=YouGithubToken + +make test # or simply composer install -SATIS_GITLAB_TOKEN=YouGitlabToken phpunit +phpunit ``` diff --git a/tests/Git/GithubClientTest.php b/tests/Git/GithubClientTest.php index b9dd5c1..21da3b0 100644 --- a/tests/Git/GithubClientTest.php +++ b/tests/Git/GithubClientTest.php @@ -17,19 +17,33 @@ class GithubClientTest extends TestCase { /** - * Ensure client can find mborne's projects + * @return GithubClient */ - public function testUserRepositories(){ + protected function createGithubClient(){ + $token = getenv('SATIS_GITHUB_TOKEN'); + if ( empty($token) ){ + $this->markTestSkipped("Missing SATIS_GITHUB_TOKEN for github.com"); + } + $clientOptions = new ClientOptions(); $clientOptions - ->setUrl('https://api.github.com') + ->setUrl('https://github.com') + ->setToken($token) ; /* create client */ - $client = ClientFactory::createClient( + return ClientFactory::createClient( $clientOptions, new NullLogger() ); + } + + /** + * Ensure client can find mborne's projects + */ + public function testUserRepositories(){ + /* create client */ + $client = $this->createGithubClient(); $this->assertInstanceOf(GithubClient::class,$client); /* search projects */ @@ -69,16 +83,8 @@ public function testUserRepositories(){ * Ensure client can find mborne's projects with composer.json file */ public function testFilterFile(){ - $clientOptions = new ClientOptions(); - $clientOptions - ->setUrl('https://api.github.com') - ; - /* create client */ - $client = ClientFactory::createClient( - $clientOptions, - new NullLogger() - ); + $client = $this->createGithubClient(); $this->assertInstanceOf(GithubClient::class,$client); /* search projects */