Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ jobs:
uses: ramsey/composer-install@v4

- name: Run tests
run: bin/phpunit --display-warnings --do-not-fail-on-warning
run: bin/phpunit --display-warnings

- name: Run Behat
if: matrix.php-version == '8.4'
run: php -d error_reporting='E_ALL & ~E_DEPRECATED' bin/behat --snippets-for

2 changes: 1 addition & 1 deletion features/bootstrap/fixtures/license-MIT-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 1 addition & 18 deletions features/bootstrap/fixtures/license-MIT-blue_plastic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/Render/LocalSvgRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,19 @@ private function renderSvg(string $render, array $parameters, string $style): Im
$render = \preg_replace('/\s+/', ' ', $render);
$render = \str_replace('> <', '><', $render);

$useInternalErrors = \libxml_use_internal_errors(true);

try {
$xml = new \SimpleXMLElement($render);
} catch (\Exception $e) {
\libxml_clear_errors();
\libxml_use_internal_errors($useInternalErrors);
throw new \RuntimeException('Generated string is not a valid XML: ' . $e->getMessage());
}

\libxml_clear_errors();
\libxml_use_internal_errors($useInternalErrors);

if ('svg' !== $xml->getName()) {
throw new \RuntimeException('Generated xml is not a SVG');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Render/SvgFlatRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SvgFlatRenderTest extends TestCase

protected function setUp(): void
{
$this->calculator = $this->createMock(TextSizeCalculatorInterface::class);
$this->calculator = $this->createStub(TextSizeCalculatorInterface::class);
$this->calculator->method('calculateWidth')->willReturn(20.0);
$this->render = new SvgFlatRender($this->calculator);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Render/SvgFlatSquareRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SvgFlatSquareRenderTest extends TestCase

protected function setUp(): void
{
$this->calculator = $this->createMock(TextSizeCalculatorInterface::class);
$this->calculator = $this->createStub(TextSizeCalculatorInterface::class);
$this->calculator->method('calculateWidth')->willReturn(20.0);
$this->render = new SvgFlatSquareRender($this->calculator);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Render/SvgForTheBadgeRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SvgForTheBadgeRendererTest extends TestCase

protected function setUp(): void
{
$this->calculator = $this->createMock(TextSizeCalculatorInterface::class);
$this->calculator = $this->createStub(TextSizeCalculatorInterface::class);
$this->calculator->method('calculateWidth')->willReturnCallback(static function (string $text): float {
$widths = [
'VERSION' => 53.0,
Expand Down
2 changes: 1 addition & 1 deletion tests/Render/SvgPlasticRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SvgPlasticRenderTest extends TestCase

protected function setUp(): void
{
$this->calculator = $this->createMock(TextSizeCalculatorInterface::class);
$this->calculator = $this->createStub(TextSizeCalculatorInterface::class);
$this->calculator->method('calculateWidth')->willReturn(20.0);
$this->render = new SvgPlasticRender($this->calculator);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Render/SvgSocialRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SvgSocialRenderTest extends TestCase

protected function setUp(): void
{
$this->calculator = $this->createMock(TextSizeCalculatorInterface::class);
$this->calculator = $this->createStub(TextSizeCalculatorInterface::class);
$this->calculator->method('calculateWidth')->willReturnCallback(static function (string $text): float {
$widths = [
'twitter' => 46.0,
Expand Down