function it_should_render_a_license_mit_exactly_like_this_svg() { $template = <<<EOF <svg xmlns="http://www.w3.org/2000/svg" width="40" height="20"> <linearGradient id="b" x2="0" y2="100%"> <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> <stop offset="1" stop-opacity=".1"/> </linearGradient> <mask id="a"> <rect width="40" height="20" rx="3" fill="#fff"/> </mask> <g mask="url(#a)"> <rect width="20" height="20" fill="#555"/> <rect x="20" width="20" height="20" fill="#007ec6"/> <rect width="40" height="20" fill="url(#b)"/> </g> <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> <text x="11" y="15" fill="#010101" fill-opacity=".3">license</text> <text x="11" y="14">license</text> <text x="29" y="15" fill="#010101" fill-opacity=".3">MIT</text> <text x="29" y="14">MIT</text> </g> </svg> EOF; $badge = Badge::fromURI('license-MIT-blue.svg'); $this->render($badge)->__toString()->shouldBeLike($template); }
function it_should_not_render_non_svg_xml($calculator) { $templatesDir = __DIR__ . '/../../../Fixtures/xml_template'; $this->beConstructedWith($calculator, $templatesDir); $badge = Badge::fromURI('version-stable-97CA00.svg'); $this->shouldThrow(new \RuntimeException('Generated xml is not a SVG'))->duringRender($badge); }
function it_should_render_a_license_mit_exactly_like_this_svg() { $fixture = __DIR__ . '/../../../Fixtures/flat.svg'; $template = file_get_contents($fixture); $badge = Badge::fromURI('license-MIT-blue.svg'); $this->render($badge)->__toString()->shouldBeLike($template); }
function it_should_be_constructed_by_fromURI_factory_method_escaping_correctly_with_dashes() { $this->beConstructedWith('a', 'b', '97CA00', 'svg'); $input = 'I--m--liuggio-b-97CA00.svg'; $assertInput = 'I-m-liuggio-b-97CA00.svg'; $it = \PUGX\Poser\Badge::fromURI($input); if ((string) $it !== $assertInput) { throw new Exception(sprintf("from[%s] wants[%s] having[%s]\n", $input, $assertInput, (string) $it)); } }
function it_should_render_a_svg() { $badge = Badge::fromURI('version-stable-97CA00.svg'); $this->render($badge)->shouldBeAValidSVGImage(); }
/** * Generate and Render a badge according to the format from an URI, * eg license-MIT-blue.svg or I_m-liuggio-yellow.svg. * * @param $string * @return Image */ public function generateFromURI($string) { $badge = Badge::fromURI($string); return $this->getRenderFor($badge->getFormat())->render($badge); }