Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
holyshared committed Aug 23, 2015
2 parents 5bc2c19 + 9ffa97c commit f58773e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ php:
- 5.6
- 5.5
- hhvm
- hhvm-nightly
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
Expand All @@ -12,7 +11,5 @@ script:
after_script: composer coveralls
matrix:
fast_finish: true
allow_failures:
- php: hhvm-nightly
notifications:
email: false
56 changes: 56 additions & 0 deletions spec/environment/Jenkins.spec.php
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();
});
});
});
});
46 changes: 46 additions & 0 deletions src/environment/Jenkins.php
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;
}

}

0 comments on commit f58773e

Please sign in to comment.