This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
3 changed files
with
102 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CoverallsKit. | ||
* | ||
* (c) Noritaka Horio <holy.shared.design@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace coverallskit\spec; | ||
|
||
use coverallskit\Environment; | ||
use coverallskit\environment\Jenkins; | ||
|
||
|
||
describe(Jenkins::class, function() { | ||
describe('#getName', function() { | ||
it('return adaptor name', function() { | ||
$this->jenkins = new Jenkins(new Environment()); | ||
expect($this->jenkins->getName())->toBe('jenkins'); | ||
}); | ||
}); | ||
describe('#getBuildJobId', function() { | ||
it('return build job id', function() { | ||
$environment = new Environment([ | ||
'BUILD_NUMBER' => 101 | ||
]); | ||
$this->jenkins = new Jenkins($environment); | ||
expect($this->jenkins->getBuildJobId())->toBe(101); | ||
}); | ||
}); | ||
describe('#isSupported', function() { | ||
context('when jenkins enviroment', function() { | ||
beforeEach(function() { | ||
$environment = new Environment([ | ||
'JENKINS_URL' => 'http://example.com' | ||
]); | ||
$this->jenkins = new Jenkins($environment); | ||
}); | ||
it('return true', function() { | ||
expect($this->jenkins->isSupported())->toBeTrue(); | ||
}); | ||
}); | ||
context('when not jenkins enviroment', function() { | ||
beforeEach(function() { | ||
$environment = new Environment(); | ||
$this->jenkins = new Jenkins($environment); | ||
}); | ||
it('return false', function() { | ||
expect($this->jenkins->isSupported())->toBeFalse(); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CoverallsKit. | ||
* | ||
* (c) Noritaka Horio <holy.shared.design@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace coverallskit\environment; | ||
|
||
/** | ||
* Class Jenkins | ||
* @package coverallskit\environment | ||
*/ | ||
final class Jenkins extends AbstractAdaptor implements EnvironmentAdaptor | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'jenkins'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBuildJobId() | ||
{ | ||
return $this->environment->get('BUILD_NUMBER'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isSupported() | ||
{ | ||
$value = $this->environment->get('JENKINS_URL'); | ||
return $value !== null; | ||
} | ||
|
||
} |