-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for --orgs and --users for gitlab (refs #24)
- Loading branch information
Showing
2 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,12 @@ | |
class GitlabClientTest extends TestCase { | ||
|
||
/** | ||
* Ensure client can find mborne/sample-composer | ||
* @return GitlabClient | ||
*/ | ||
public function testGitlabDotComAuthenticated(){ | ||
protected function createGitlabClient(){ | ||
$gitlabToken = getenv('SATIS_GITLAB_TOKEN'); | ||
if ( empty($gitlabToken) ){ | ||
$this->markTestSkipped("Missing SATIS_GITLAB_TOKEN for gitlab.com"); | ||
return; | ||
} | ||
|
||
$clientOptions = new ClientOptions(); | ||
|
@@ -31,12 +30,51 @@ public function testGitlabDotComAuthenticated(){ | |
->setToken($gitlabToken) | ||
; | ||
|
||
|
||
/* create client */ | ||
$client = ClientFactory::createClient( | ||
return ClientFactory::createClient( | ||
$clientOptions, | ||
new NullLogger() | ||
); | ||
} | ||
|
||
/** | ||
* Ensure client can find mborne/sample-composer by username | ||
*/ | ||
public function testGitlabDotComByUser(){ | ||
/* create client */ | ||
$client = $this->createGitlabClient(); | ||
$this->assertInstanceOf(GitlabClient::class,$client); | ||
|
||
/* search projects */ | ||
$findOptions = new FindOptions(); | ||
$findOptions->setUsers(array('mborne')); | ||
$projects = $client->find($findOptions); | ||
$projectsByName = array(); | ||
foreach ( $projects as $project ){ | ||
$projectsByName[$project->getName()] = $project; | ||
} | ||
/* check project found */ | ||
$this->assertArrayHasKey( | ||
'mborne/sample-composer', | ||
$projectsByName | ||
); | ||
|
||
$project = $projectsByName['mborne/sample-composer']; | ||
$composer = $client->getRawFile( | ||
$project, | ||
'composer.json', | ||
$project->getDefaultBranch() | ||
); | ||
$this->assertContains('[email protected]',$composer); | ||
} | ||
|
||
|
||
/** | ||
* Ensure client can find mborne/sample-composer with search | ||
*/ | ||
public function testGitlabDotComSearch(){ | ||
/* create client */ | ||
$client = $this->createGitlabClient(); | ||
$this->assertInstanceOf(GitlabClient::class,$client); | ||
|
||
/* search projects */ | ||
|