Skip to content

Commit

Permalink
Merge pull request #16 from jmleroux/patch-1
Browse files Browse the repository at this point in the history
Fix colorScheme
  • Loading branch information
liuggio committed Mar 15, 2016
2 parents e5f2886 + c4a5057 commit df9febd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

matrix:
allow_failures:
- php: 7.0
- php: hhvm

before_script:
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev --no-interaction install
before_install:
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
- composer selfupdate

install:
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --no-interaction install

script:
- bin/phpspec run --format=pretty
Expand Down
10 changes: 10 additions & 0 deletions spec/PUGX/Poser/BadgeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ function it_should_be_constructed_by_fromURI_factory_method_escaping_correctly_w
throw new Exception(sprintf("from[%s] wants[%s] having[%s]\n", $input, $assertInput, (string) $it));
}
}

function it_should_validate_available_color_schemes()
{
$colorSchemes = \PUGX\Poser\Badge::getColorNamesAvailable();

foreach ($colorSchemes as $colorScheme) {
$this->beConstructedWith('a', 'b', $colorScheme, 'svg');
$this->getHexColor()->shouldBeString();
}
}
}
4 changes: 1 addition & 3 deletions spec/PUGX/Poser/PoserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ function it_should_be_able_to_generate_an_svg_image_from_URI()
public function getMatchers()
{
return array(
'beAValidSVGImageContaining' => function($object, $subject, $status)
{

'beAValidSVGImageContaining' => function($object, $subject, $status) {
$regex = '/^<svg.*width="((.|\n)*)'.$subject.'((.|\n)*)'.$status.'((.|\n)*)<\/svg>$/';
$matches = array();

Expand Down
7 changes: 3 additions & 4 deletions spec/PUGX/Poser/Render/SvgFlatRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

namespace spec\PUGX\Poser\Render;

use PhpSpec\Exception\Exception;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use PUGX\Poser\Badge;
use PUGX\Poser\Calculator\GDTextSizeCalculator;
use PUGX\Poser\Calculator\TextSizeCalculatorInterface;

class SvgFlatRenderSpec extends ObjectBehavior
{
function let(TextSizeCalculatorInterface $calculator)
function let($calculator)
{
$calculator->beADoubleOf('\PUGX\Poser\Calculator\TextSizeCalculatorInterface');
$calculator->calculateWidth(Argument::any())->willReturn(20);
$this->beConstructedWith($calculator);
}
Expand Down Expand Up @@ -66,4 +65,4 @@ function it_should_render_a_license_mit_exactly_like_this_svg()
}


}
}
8 changes: 2 additions & 6 deletions spec/PUGX/Poser/Render/SvgFlatSquareRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

namespace spec\PUGX\Poser\Render;

use PhpSpec\Exception\Exception;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use PUGX\Poser\Badge;
use PUGX\Poser\Calculator\GDTextSizeCalculator;
use PUGX\Poser\Calculator\TextSizeCalculatorInterface;

class SvgFlatSquareRenderSpec extends ObjectBehavior
{
function let(TextSizeCalculatorInterface $calculator)
function let($calculator)
{
$calculator->beADoubleOf('\PUGX\Poser\Calculator\TextSizeCalculatorInterface');
$calculator->calculateWidth(Argument::any())->willReturn(20);
$this->beConstructedWith($calculator);
}
Expand Down Expand Up @@ -64,6 +62,4 @@ function it_should_render_a_license_mit_exactly_like_this_svg()
$badge = Badge::fromURI('license-MIT-blue.svg');
$this->render($badge)->__toString()->shouldBeLike($template);
}


}
7 changes: 3 additions & 4 deletions spec/PUGX/Poser/Render/SvgRenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

namespace spec\PUGX\Poser\Render;

use PhpSpec\Exception\Exception;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use PUGX\Poser\Badge;
use PUGX\Poser\Calculator\TextSizeCalculatorInterface;

class SvgRenderSpec extends ObjectBehavior
{
function let(TextSizeCalculatorInterface $calculator)
function let($calculator)
{
$calculator->beADoubleOf('\PUGX\Poser\Calculator\TextSizeCalculatorInterface');
$calculator->calculateWidth(Argument::any())->willReturn(20);
$this->beConstructedWith($calculator);
}
Expand All @@ -34,4 +33,4 @@ public function getMatchers()
}
);
}
}
}
4 changes: 2 additions & 2 deletions src/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class Badge
{
CONST DEFAULT_FORMAT = 'svg';
private static $colorScheme = array(
"brightgreen" => "4c1",
"brightgreen" => "44cc11",
"green" => "97CA00",
"yellow" => "dfb317",
"yellowgreen" => "a4a61d",
"orange" => "fe7d37",
"red" => "e05d44",
"blue" => "007ec6",
"grey" => "555",
"grey" => "555555",
"lightgray" => "9f9f9f"
);

Expand Down

0 comments on commit df9febd

Please sign in to comment.