Skip to content

Commit

Permalink
test: Add a test case for RectRenderer defaulting x=0 and y=0 (#205)
Browse files Browse the repository at this point in the history
Adds a test case for the fix in #204
  • Loading branch information
meyfa authored Mar 16, 2023
1 parent ad47def commit f6d501c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Rasterization/Renderers/RectRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,25 @@ public function testDoesNotRenderIfHeightZero()

$this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-empty.png'));
}

public function testDefaultsXAndYToZero()
{
$obj = new RectRenderer();

$context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode');
$context->setStyle('fill', '#FFFFFF');
$context->setStyle('stroke', '#000000');
$context->setStyle('stroke-width', '5px');

$rasterizer = new SVGRasterizer('40px', '40px', null, 40, 40);
$obj->render($rasterizer, [
'x' => null,
'y' => null,
'width' => 20,
'height' => 16,
], $context);
$img = $rasterizer->finish();

$this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-x0y0.png'));
}
}
Binary file added tests/images/renderer-rect-x0y0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f6d501c

Please sign in to comment.