From c28cc2d196d64c3fa32a95c8baa2e0cba295db54 Mon Sep 17 00:00:00 2001 From: Niellles <10075507+Niellles@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:52:35 +0100 Subject: [PATCH 1/2] refactor: Make tests namespaces follow directory structure Change namespaces for test classes to comply with PSR-4. As per PSR-4 2.3.2 the namespace should follow the projects directory structure (https://www.php-fig.org/psr/psr-4/). --- tests/Nodes/Embedded/SVGImageTest.php | 4 +--- tests/Nodes/SVGNodeContainerTest.php | 4 +--- tests/Nodes/SVGNodeTest.php | 4 +--- tests/Nodes/Shapes/SVGCircleTest.php | 4 +--- tests/Nodes/Shapes/SVGEllipseTest.php | 4 +--- tests/Nodes/Shapes/SVGLineTest.php | 4 +--- tests/Nodes/Shapes/SVGPathTest.php | 4 +--- tests/Nodes/Shapes/SVGPolygonTest.php | 4 +--- tests/Nodes/Shapes/SVGPolygonalShapeTest.php | 4 +--- tests/Nodes/Shapes/SVGPolylineTest.php | 4 +--- tests/Nodes/Shapes/SVGRectTest.php | 4 +--- tests/Nodes/Structures/SVGDefsTest.php | 4 +--- tests/Nodes/Structures/SVGDocumentFragmentTest.php | 3 +-- tests/Nodes/Structures/SVGScriptTest.php | 4 +--- tests/Nodes/Structures/SVGStyleTest.php | 4 +--- tests/Nodes/Texts/SVGTextTest.php | 4 +--- tests/Rasterization/Path/ArcApproximatorTest.php | 6 ++---- tests/Rasterization/Path/BezierApproximatorTest.php | 4 +--- tests/Rasterization/Path/PathApproximatorTest.php | 3 +-- tests/Rasterization/Path/PathParserTest.php | 4 +--- tests/Rasterization/Path/PolygonBuilderTest.php | 4 +--- tests/Rasterization/Renderers/ImageRendererTest.php | 3 +-- tests/Rasterization/Renderers/MultiPassRendererTest.php | 4 +--- tests/Rasterization/Renderers/PolygonRendererTest.php | 3 +-- tests/Rasterization/Renderers/RectRendererTest.php | 3 +-- tests/Rasterization/SVGRasterizerTest.php | 3 +-- tests/Rasterization/Transform/TransformParserTest.php | 5 +---- tests/Rasterization/Transform/TransformTest.php | 4 +--- tests/Reading/AttributeRegistryTest.php | 5 +---- tests/Reading/LengthAttributeConverterTest.php | 4 +--- tests/Reading/NodeRegistryTest.php | 4 +--- tests/Reading/SVGReaderTest.php | 6 ++---- tests/Utilities/Colors/ColorLookupTest.php | 4 +--- tests/Utilities/Colors/ColorTest.php | 4 +--- tests/Utilities/SVGStyleParserTest.php | 6 ++---- tests/Utilities/Units/AngleTest.php | 4 +--- tests/Utilities/Units/LengthTest.php | 4 +--- tests/Writing/SVGWriterTest.php | 4 +--- 38 files changed, 41 insertions(+), 113 deletions(-) diff --git a/tests/Nodes/Embedded/SVGImageTest.php b/tests/Nodes/Embedded/SVGImageTest.php index 564f6e93..584cbb7f 100644 --- a/tests/Nodes/Embedded/SVGImageTest.php +++ b/tests/Nodes/Embedded/SVGImageTest.php @@ -1,8 +1,6 @@ Date: Sun, 10 Dec 2023 23:25:41 +0100 Subject: [PATCH 2/2] refactor: Replace FQN strings with ::class notation As of PHP 5.5 SomeClass::class represents SomeClass' FQN. As support for <7.3 (thus <5.5) was dropped in #182, this notation can now be used. --- .../Renderers/PathRendererImplementation.php | 4 +- src/Reading/AttributeRegistry.php | 6 +- src/Reading/NodeRegistry.php | 189 ++++++++++++------ tests/Nodes/Embedded/SVGImageTest.php | 4 +- tests/Nodes/SVGNodeContainerTest.php | 10 +- tests/Nodes/Shapes/SVGCircleTest.php | 4 +- tests/Nodes/Shapes/SVGEllipseTest.php | 4 +- tests/Nodes/Shapes/SVGLineTest.php | 4 +- tests/Nodes/Shapes/SVGPathTest.php | 8 +- tests/Nodes/Shapes/SVGPolygonTest.php | 6 +- tests/Nodes/Shapes/SVGPolylineTest.php | 6 +- tests/Nodes/Shapes/SVGRectTest.php | 4 +- tests/Nodes/Structures/SVGDefsTest.php | 7 +- .../Structures/SVGDocumentFragmentTest.php | 14 +- tests/Nodes/Structures/SVGScriptTest.php | 4 +- tests/Nodes/Structures/SVGStyleTest.php | 6 +- tests/Nodes/Texts/SVGTextTest.php | 4 +- .../Renderers/MultiPassRendererTest.php | 29 +-- .../Renderers/PolygonRendererTest.php | 5 +- .../Renderers/RectRendererTest.php | 23 ++- .../Renderers/TextRendererTest.php | 3 +- tests/Rasterization/SVGRasterizerTest.php | 3 +- tests/Reading/NodeRegistryTest.php | 7 +- tests/Reading/SVGReaderTest.php | 4 +- tests/SVGTest.php | 9 +- 25 files changed, 236 insertions(+), 131 deletions(-) diff --git a/src/Rasterization/Renderers/PathRendererImplementation.php b/src/Rasterization/Renderers/PathRendererImplementation.php index 397e1cbc..70b73e2b 100644 --- a/src/Rasterization/Renderers/PathRendererImplementation.php +++ b/src/Rasterization/Renderers/PathRendererImplementation.php @@ -59,7 +59,7 @@ public static function fillMultipath($image, array $subpaths, int $color, string imagesetthickness($image, 1); // Sort the edges by their maximum y value, descending (i.e., edges that extend further down are sorted first). - usort($edges, ['SVG\Rasterization\Renderers\PathRendererEdge', 'compareMaxY']); + usort($edges, [PathRendererEdge::class, 'compareMaxY']); // Now the maxY of the entire path is just the maxY of the edge sorted first. // Since there is no way to know which edge has the minY, we cannot do the same for that and have to compute // it during the loop instead. @@ -92,7 +92,7 @@ public static function fillMultipath($image, array $subpaths, int $color, string if (!empty($activeEdges)) { // Now sort the active edges from rightmost to leftmost (i.e., by x descending). - usort($activeEdges, ['SVG\Rasterization\Renderers\PathRendererEdge', 'compareX']); + usort($activeEdges, [PathRendererEdge::class, 'compareX']); $windingNumber = $evenOdd ? 0 : $activeEdges[0]->direction; diff --git a/src/Reading/AttributeRegistry.php b/src/Reading/AttributeRegistry.php index 09030583..9dc3c189 100644 --- a/src/Reading/AttributeRegistry.php +++ b/src/Reading/AttributeRegistry.php @@ -50,9 +50,9 @@ class AttributeRegistry * for SVG attribute to CSS property conversion. */ private static $styleConverters = [ - 'font-size' => 'SVG\Reading\LengthAttributeConverter', - 'letter-spacing' => 'SVG\Reading\LengthAttributeConverter', - 'word-spacing' => 'SVG\Reading\LengthAttributeConverter', + 'font-size' => LengthAttributeConverter::class, + 'letter-spacing' => LengthAttributeConverter::class, + 'word-spacing' => LengthAttributeConverter::class, ]; /** diff --git a/src/Reading/NodeRegistry.php b/src/Reading/NodeRegistry.php index c4ff1791..c9f0b2f3 100644 --- a/src/Reading/NodeRegistry.php +++ b/src/Reading/NodeRegistry.php @@ -2,8 +2,71 @@ namespace SVG\Reading; +use SVG\Nodes\Embedded\SVGForeignObject; +use SVG\Nodes\Embedded\SVGImage; +use SVG\Nodes\Filters\SVGFEBlend; +use SVG\Nodes\Filters\SVGFEColorMatrix; +use SVG\Nodes\Filters\SVGFEComponentTransfer; +use SVG\Nodes\Filters\SVGFEComposite; +use SVG\Nodes\Filters\SVGFEConvolveMatrix; +use SVG\Nodes\Filters\SVGFEDiffuseLighting; +use SVG\Nodes\Filters\SVGFEDisplacementMap; +use SVG\Nodes\Filters\SVGFEDistantLight; +use SVG\Nodes\Filters\SVGFEDropShadow; +use SVG\Nodes\Filters\SVGFEFlood; +use SVG\Nodes\Filters\SVGFEFuncA; +use SVG\Nodes\Filters\SVGFEFuncB; +use SVG\Nodes\Filters\SVGFEFuncG; +use SVG\Nodes\Filters\SVGFEFuncR; +use SVG\Nodes\Filters\SVGFEGaussianBlur; +use SVG\Nodes\Filters\SVGFEImage; +use SVG\Nodes\Filters\SVGFEMerge; +use SVG\Nodes\Filters\SVGFEMergeNode; +use SVG\Nodes\Filters\SVGFEMorphology; +use SVG\Nodes\Filters\SVGFEOffset; +use SVG\Nodes\Filters\SVGFEPointLight; +use SVG\Nodes\Filters\SVGFESpecularLighting; +use SVG\Nodes\Filters\SVGFESpotLight; +use SVG\Nodes\Filters\SVGFETile; +use SVG\Nodes\Filters\SVGFETurbulence; +use SVG\Nodes\Filters\SVGFilter; +use SVG\Nodes\Presentation\SVGAnimate; +use SVG\Nodes\Presentation\SVGAnimateMotion; +use SVG\Nodes\Presentation\SVGAnimateTransform; +use SVG\Nodes\Presentation\SVGLinearGradient; +use SVG\Nodes\Presentation\SVGMPath; +use SVG\Nodes\Presentation\SVGRadialGradient; +use SVG\Nodes\Presentation\SVGSet; +use SVG\Nodes\Presentation\SVGStop; +use SVG\Nodes\Presentation\SVGView; +use SVG\Nodes\Shapes\SVGCircle; +use SVG\Nodes\Shapes\SVGEllipse; +use SVG\Nodes\Shapes\SVGLine; +use SVG\Nodes\Shapes\SVGPath; +use SVG\Nodes\Shapes\SVGPolygon; +use SVG\Nodes\Shapes\SVGPolyline; +use SVG\Nodes\Shapes\SVGRect; +use SVG\Nodes\Structures\SVGClipPath; +use SVG\Nodes\Structures\SVGDefs; +use SVG\Nodes\Structures\SVGDocumentFragment; +use SVG\Nodes\Structures\SVGGroup; +use SVG\Nodes\Structures\SVGLinkGroup; +use SVG\Nodes\Structures\SVGMarker; +use SVG\Nodes\Structures\SVGMask; +use SVG\Nodes\Structures\SVGMetadata; +use SVG\Nodes\Structures\SVGPattern; +use SVG\Nodes\Structures\SVGScript; +use SVG\Nodes\Structures\SVGStyle; +use SVG\Nodes\Structures\SVGSwitch; +use SVG\Nodes\Structures\SVGSymbol; +use SVG\Nodes\Structures\SVGUse; use SVG\Nodes\SVGNode; use SVG\Nodes\SVGGenericNodeType; +use SVG\Nodes\Texts\SVGDesc; +use SVG\Nodes\Texts\SVGText; +use SVG\Nodes\Texts\SVGTextPath; +use SVG\Nodes\Texts\SVGTitle; +use SVG\Nodes\Texts\SVGTSpan; /** * This class contains a list of all known SVG node types, and enables dynamic @@ -15,74 +78,74 @@ class NodeRegistry * @var string[] $nodeTypes Map of tag names to fully-qualified class names. */ private static $nodeTypes = [ - 'foreignObject' => 'SVG\Nodes\Embedded\SVGForeignObject', - 'image' => 'SVG\Nodes\Embedded\SVGImage', + 'foreignObject' => SVGForeignObject::class, + 'image' => SVGImage::class, - 'feBlend' => 'SVG\Nodes\Filters\SVGFEBlend', - 'feColorMatrix' => 'SVG\Nodes\Filters\SVGFEColorMatrix', - 'feComponentTransfer' => 'SVG\Nodes\Filters\SVGFEComponentTransfer', - 'feComposite' => 'SVG\Nodes\Filters\SVGFEComposite', - 'feConvolveMatrix' => 'SVG\Nodes\Filters\SVGFEConvolveMatrix', - 'feDiffuseLighting' => 'SVG\Nodes\Filters\SVGFEDiffuseLighting', - 'feDisplacementMap' => 'SVG\Nodes\Filters\SVGFEDisplacementMap', - 'feDistantLight' => 'SVG\Nodes\Filters\SVGFEDistantLight', - 'feDropShadow' => 'SVG\Nodes\Filters\SVGFEDropShadow', - 'feFlood' => 'SVG\Nodes\Filters\SVGFEFlood', - 'feFuncA' => 'SVG\Nodes\Filters\SVGFEFuncA', - 'feFuncB' => 'SVG\Nodes\Filters\SVGFEFuncB', - 'feFuncG' => 'SVG\Nodes\Filters\SVGFEFuncG', - 'feFuncR' => 'SVG\Nodes\Filters\SVGFEFuncR', - 'feGaussianBlur' => 'SVG\Nodes\Filters\SVGFEGaussianBlur', - 'feImage' => 'SVG\Nodes\Filters\SVGFEImage', - 'feMerge' => 'SVG\Nodes\Filters\SVGFEMerge', - 'feMergeNode' => 'SVG\Nodes\Filters\SVGFEMergeNode', - 'feMorphology' => 'SVG\Nodes\Filters\SVGFEMorphology', - 'feOffset' => 'SVG\Nodes\Filters\SVGFEOffset', - 'fePointLight' => 'SVG\Nodes\Filters\SVGFEPointLight', - 'feSpecularLighting' => 'SVG\Nodes\Filters\SVGFESpecularLighting', - 'feSpotLight' => 'SVG\Nodes\Filters\SVGFESpotLight', - 'feTile' => 'SVG\Nodes\Filters\SVGFETile', - 'feTurbulence' => 'SVG\Nodes\Filters\SVGFETurbulence', - 'filter' => 'SVG\Nodes\Filters\SVGFilter', + 'feBlend' => SVGFEBlend::class, + 'feColorMatrix' => SVGFEColorMatrix::class, + 'feComponentTransfer' => SVGFEComponentTransfer::class, + 'feComposite' => SVGFEComposite::class, + 'feConvolveMatrix' => SVGFEConvolveMatrix::class, + 'feDiffuseLighting' => SVGFEDiffuseLighting::class, + 'feDisplacementMap' => SVGFEDisplacementMap::class, + 'feDistantLight' => SVGFEDistantLight::class, + 'feDropShadow' => SVGFEDropShadow::class, + 'feFlood' => SVGFEFlood::class, + 'feFuncA' => SVGFEFuncA::class, + 'feFuncB' => SVGFEFuncB::class, + 'feFuncG' => SVGFEFuncG::class, + 'feFuncR' => SVGFEFuncR::class, + 'feGaussianBlur' => SVGFEGaussianBlur::class, + 'feImage' => SVGFEImage::class, + 'feMerge' => SVGFEMerge::class, + 'feMergeNode' => SVGFEMergeNode::class, + 'feMorphology' => SVGFEMorphology::class, + 'feOffset' => SVGFEOffset::class, + 'fePointLight' => SVGFEPointLight::class, + 'feSpecularLighting' => SVGFESpecularLighting::class, + 'feSpotLight' => SVGFESpotLight::class, + 'feTile' => SVGFETile::class, + 'feTurbulence' => SVGFETurbulence::class, + 'filter' => SVGFilter::class, - 'animate' => 'SVG\Nodes\Presentation\SVGAnimate', - 'animateMotion' => 'SVG\Nodes\Presentation\SVGAnimateMotion', - 'animateTransform' => 'SVG\Nodes\Presentation\SVGAnimateTransform', - 'linearGradient' => 'SVG\Nodes\Presentation\SVGLinearGradient', - 'mpath' => 'SVG\Nodes\Presentation\SVGMPath', - 'radialGradient' => 'SVG\Nodes\Presentation\SVGRadialGradient', - 'set' => 'SVG\Nodes\Presentation\SVGSet', - 'stop' => 'SVG\Nodes\Presentation\SVGStop', - 'view' => 'SVG\Nodes\Presentation\SVGView', + 'animate' => SVGAnimate::class, + 'animateMotion' => SVGAnimateMotion::class, + 'animateTransform' => SVGAnimateTransform::class, + 'linearGradient' => SVGLinearGradient::class, + 'mpath' => SVGMPath::class, + 'radialGradient' => SVGRadialGradient::class, + 'set' => SVGSet::class, + 'stop' => SVGStop::class, + 'view' => SVGView::class, - 'circle' => 'SVG\Nodes\Shapes\SVGCircle', - 'ellipse' => 'SVG\Nodes\Shapes\SVGEllipse', - 'line' => 'SVG\Nodes\Shapes\SVGLine', - 'path' => 'SVG\Nodes\Shapes\SVGPath', - 'polygon' => 'SVG\Nodes\Shapes\SVGPolygon', - 'polyline' => 'SVG\Nodes\Shapes\SVGPolyline', - 'rect' => 'SVG\Nodes\Shapes\SVGRect', + 'circle' => SVGCircle::class, + 'ellipse' => SVGEllipse::class, + 'line' => SVGLine::class, + 'path' => SVGPath::class, + 'polygon' => SVGPolygon::class, + 'polyline' => SVGPolyline::class, + 'rect' => SVGRect::class, - 'clipPath' => 'SVG\Nodes\Structures\SVGClipPath', - 'defs' => 'SVG\Nodes\Structures\SVGDefs', - 'svg' => 'SVG\Nodes\Structures\SVGDocumentFragment', - 'g' => 'SVG\Nodes\Structures\SVGGroup', - 'a' => 'SVG\Nodes\Structures\SVGLinkGroup', - 'marker' => 'SVG\Nodes\Structures\SVGMarker', - 'mask' => 'SVG\Nodes\Structures\SVGMask', - 'metadata' => 'SVG\Nodes\Structures\SVGMetadata', - 'pattern' => 'SVG\Nodes\Structures\SVGPattern', - 'script' => 'SVG\Nodes\Structures\SVGScript', - 'style' => 'SVG\Nodes\Structures\SVGStyle', - 'switch' => 'SVG\Nodes\Structures\SVGSwitch', - 'symbol' => 'SVG\Nodes\Structures\SVGSymbol', - 'use' => 'SVG\Nodes\Structures\SVGUse', + 'clipPath' => SVGClipPath::class, + 'defs' => SVGDefs::class, + 'svg' => SVGDocumentFragment::class, + 'g' => SVGGroup::class, + 'a' => SVGLinkGroup::class, + 'marker' => SVGMarker::class, + 'mask' => SVGMask::class, + 'metadata' => SVGMetadata::class, + 'pattern' => SVGPattern::class, + 'script' => SVGScript::class, + 'style' => SVGStyle::class, + 'switch' => SVGSwitch::class, + 'symbol' => SVGSymbol::class, + 'use' => SVGUse::class, - 'desc' => 'SVG\Nodes\Texts\SVGDesc', - 'text' => 'SVG\Nodes\Texts\SVGText', - 'textPath' => 'SVG\Nodes\Texts\SVGTextPath', - 'title' => 'SVG\Nodes\Texts\SVGTitle', - 'tspan' => 'SVG\Nodes\Texts\SVGTSpan', + 'desc' => SVGDesc::class, + 'text' => SVGText::class, + 'textPath' => SVGTextPath::class, + 'title' => SVGTitle::class, + 'tspan' => SVGTSpan::class, ]; /** diff --git a/tests/Nodes/Embedded/SVGImageTest.php b/tests/Nodes/Embedded/SVGImageTest.php index 584cbb7f..fc4af259 100644 --- a/tests/Nodes/Embedded/SVGImageTest.php +++ b/tests/Nodes/Embedded/SVGImageTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Embedded; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Embedded\SVGImage * @covers :: @@ -181,7 +183,7 @@ public function testRasterize() { $obj = new SVGImage('test-href', 10, 10, 100, 100); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/SVGNodeContainerTest.php b/tests/Nodes/SVGNodeContainerTest.php index 6e95e977..4b7fa9f1 100644 --- a/tests/Nodes/SVGNodeContainerTest.php +++ b/tests/Nodes/SVGNodeContainerTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes; +use SVG\Rasterization\SVGRasterizer; + class SVGNodeContainerSubclass extends SVGNodeContainer { const TAG_NAME = 'test_subclass'; @@ -131,10 +133,10 @@ public function testRasterize() { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -263,7 +265,7 @@ public function testGetContainerStyleForNode() { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); $this->assertCount(0, $obj->getContainerStyleForNode($mockChild)); @@ -276,7 +278,7 @@ public function testGetContainerStyleByPattern() { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); $this->assertCount(0, $obj->getContainerStyleByPattern('/^(\d+)?\.\d+$/')); diff --git a/tests/Nodes/Shapes/SVGCircleTest.php b/tests/Nodes/Shapes/SVGCircleTest.php index 80f3c97d..db79ae45 100644 --- a/tests/Nodes/Shapes/SVGCircleTest.php +++ b/tests/Nodes/Shapes/SVGCircleTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGCircle * @covers :: @@ -116,7 +118,7 @@ public function testRasterize() { $obj = new SVGCircle(37, 42, 100); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGEllipseTest.php b/tests/Nodes/Shapes/SVGEllipseTest.php index 3ccb3a22..f8ebd1f4 100644 --- a/tests/Nodes/Shapes/SVGEllipseTest.php +++ b/tests/Nodes/Shapes/SVGEllipseTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGEllipse * @covers :: @@ -144,7 +146,7 @@ public function testRasterize() { $obj = new SVGEllipse(37, 42, 100, 200); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGLineTest.php b/tests/Nodes/Shapes/SVGLineTest.php index 6fc57718..72b19a29 100644 --- a/tests/Nodes/Shapes/SVGLineTest.php +++ b/tests/Nodes/Shapes/SVGLineTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGLine * @covers :: @@ -144,7 +146,7 @@ public function testRasterize() { $obj = new SVGLine(11, 12, 13, 14); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPathTest.php b/tests/Nodes/Shapes/SVGPathTest.php index 108765fa..fdf3663d 100644 --- a/tests/Nodes/Shapes/SVGPathTest.php +++ b/tests/Nodes/Shapes/SVGPathTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGPath * @covers :: @@ -69,7 +71,7 @@ public function testRasterizeWithNull() { $obj = new SVGPath(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -86,7 +88,7 @@ public function testRasterize() $obj = new SVGPath(self::$sampleDescription); // setup mocks - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -132,7 +134,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolygonTest.php b/tests/Nodes/Shapes/SVGPolygonTest.php index 0090c5f9..4eaca8c1 100644 --- a/tests/Nodes/Shapes/SVGPolygonTest.php +++ b/tests/Nodes/Shapes/SVGPolygonTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGPolygon * @covers :: @@ -40,7 +42,7 @@ public function testRasterize() $obj = new SVGPolygon($points); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -92,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolylineTest.php b/tests/Nodes/Shapes/SVGPolylineTest.php index e27fb7a7..bf250693 100644 --- a/tests/Nodes/Shapes/SVGPolylineTest.php +++ b/tests/Nodes/Shapes/SVGPolylineTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGPolyline * @covers :: @@ -40,7 +42,7 @@ public function testRasterize() $obj = new SVGPolyline($points); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -92,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGRectTest.php b/tests/Nodes/Shapes/SVGRectTest.php index 8661a2de..0100b187 100644 --- a/tests/Nodes/Shapes/SVGRectTest.php +++ b/tests/Nodes/Shapes/SVGRectTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Shapes; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Shapes\SVGRect * @covers :: @@ -200,7 +202,7 @@ public function testRasterize() $obj->setAttribute('rx', 15); $obj->setAttribute('ry', 25); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDefsTest.php b/tests/Nodes/Structures/SVGDefsTest.php index ed2c401b..531a28b7 100644 --- a/tests/Nodes/Structures/SVGDefsTest.php +++ b/tests/Nodes/Structures/SVGDefsTest.php @@ -2,6 +2,9 @@ namespace SVG\Nodes\Structures; +use SVG\Nodes\SVGNode; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Structures\SVGDefs * @covers :: @@ -27,10 +30,10 @@ public function testRasterize() { $obj = new SVGDefs(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDocumentFragmentTest.php b/tests/Nodes/Structures/SVGDocumentFragmentTest.php index 1e99001b..7bc5ca84 100644 --- a/tests/Nodes/Structures/SVGDocumentFragmentTest.php +++ b/tests/Nodes/Structures/SVGDocumentFragmentTest.php @@ -3,6 +3,8 @@ namespace SVG\Nodes\Structures; use AssertGD\GDSimilarityConstraint; +use SVG\Nodes\SVGNode; +use SVG\Nodes\SVGNodeContainer; /** * @coversDefaultClass \SVG\Nodes\Structures\SVGDocumentFragment @@ -210,14 +212,14 @@ public function testGetElementById() $obj = new SVGDocumentFragment(); $obj->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(SVGNode::class) )->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $expected = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $expected = $this->getMockForAbstractClass(SVGNode::class) ->setAttribute('id', 'foobar') ) // @@ -226,9 +228,9 @@ public function testGetElementById() ); $obj->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(SVGNode::class) ->setAttribute('id', 'foobar') ) // diff --git a/tests/Nodes/Structures/SVGScriptTest.php b/tests/Nodes/Structures/SVGScriptTest.php index aefb042c..322a6a8d 100644 --- a/tests/Nodes/Structures/SVGScriptTest.php +++ b/tests/Nodes/Structures/SVGScriptTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Structures; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Structures\SVGScript * @@ -30,7 +32,7 @@ public function testRasterize() { $obj = new SVGScript(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGStyleTest.php b/tests/Nodes/Structures/SVGStyleTest.php index 1d1e9c29..c04b67b3 100644 --- a/tests/Nodes/Structures/SVGStyleTest.php +++ b/tests/Nodes/Structures/SVGStyleTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Structures; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Structures\SVGStyle * @@ -42,7 +44,7 @@ public function testGetType() public function testSetType() { $obj = new SVGStyle(); - $this->assertInstanceOf('SVG\Nodes\Structures\SVGStyle', $obj->setType('test-type')); + $this->assertInstanceOf(SVGStyle::class, $obj->setType('test-type')); $this->assertEquals('test-type', $obj->getAttribute('type')); @@ -56,7 +58,7 @@ public function testRasterize() { $obj = new SVGStyle(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Texts/SVGTextTest.php b/tests/Nodes/Texts/SVGTextTest.php index e459632c..9cc1f695 100644 --- a/tests/Nodes/Texts/SVGTextTest.php +++ b/tests/Nodes/Texts/SVGTextTest.php @@ -2,6 +2,8 @@ namespace SVG\Nodes\Texts; +use SVG\Rasterization\SVGRasterizer; + /** * @coversDefaultClass \SVG\Nodes\Texts\SVGText * @covers :: @@ -19,7 +21,7 @@ public function testRasterizeShouldHaveDefaultFontSize() $obj = new SVGText('foo', 10, 10); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Rasterization/Renderers/MultiPassRendererTest.php b/tests/Rasterization/Renderers/MultiPassRendererTest.php index 3e2c0205..05ff9f61 100644 --- a/tests/Rasterization/Renderers/MultiPassRendererTest.php +++ b/tests/Rasterization/Renderers/MultiPassRendererTest.php @@ -2,6 +2,9 @@ namespace SVG\Rasterization\Renderers; +use SVG\Nodes\SVGNode; +use SVG\Rasterization\Transform\Transform; + /** * @requires extension gd * @covers \SVG\Rasterization\Renderers\MultiPassRenderer @@ -34,13 +37,13 @@ private function isGdImage() public function testRenderShouldCallPrepare() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should call prepareRenderParams with correct arguments - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->expects($this->once())->method('prepareRenderParams')->with( $this->identicalTo(self::$sampleOptions), - $this->isInstanceOf('\SVG\Rasterization\Transform\Transform') + $this->isInstanceOf(Transform::class) )->willReturn(self::$sampleParams); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -50,11 +53,11 @@ public function testRenderShouldCallPrepare() public function testRenderShouldCallRenderFill() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should call renderFill with correct fill color $node->setStyle('fill', '#AAAAAA'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -65,7 +68,7 @@ public function testRenderShouldCallRenderFill() // should not call renderFill with 'fill: none' style $node->setStyle('fill', 'none'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderFill'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -76,12 +79,12 @@ public function testRenderShouldCallRenderFill() public function testRenderShouldCallRenderStroke() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should call renderStroke with correct stroke color and width $node->setStyle('stroke', '#BBBBBB'); $node->setStyle('stroke-width', '2px'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderStroke')->with( $this->isGdImage(), @@ -93,7 +96,7 @@ public function testRenderShouldCallRenderStroke() // should not call renderStroke with 'stroke: none' style $node->setStyle('stroke', 'none'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderStroke'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -104,13 +107,13 @@ public function testRenderShouldCallRenderStroke() public function testRenderShouldRespectFillOpacity() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should use fill-opacity for the alpha value (try with a few different notations) foreach (['0.5', '.5', '50%', ' 0.5 ', ' 50% '] as $fillOpacity) { $node->setStyle('fill', '#AAAAAA'); $node->setStyle('fill-opacity', $fillOpacity); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -126,14 +129,14 @@ public function testRenderShouldRespectFillOpacity() public function testRenderShouldRespectStrokeOpacity() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should use stroke-opacity for the alpha value (try with a few different notations) foreach (['0.5', '.5', '50%', ' 0.5 ', ' 50% '] as $strokeOpacity) { $node->setStyle('stroke', '#BBBBBB'); $node->setStyle('stroke-opacity', $strokeOpacity); $node->setStyle('stroke-width', '2px'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderStroke')->with( $this->isGdImage(), diff --git a/tests/Rasterization/Renderers/PolygonRendererTest.php b/tests/Rasterization/Renderers/PolygonRendererTest.php index 7aaf69d7..ee1587f9 100644 --- a/tests/Rasterization/Renderers/PolygonRendererTest.php +++ b/tests/Rasterization/Renderers/PolygonRendererTest.php @@ -3,6 +3,7 @@ namespace SVG\Rasterization\Renderers; use AssertGD\GDSimilarityConstraint; +use SVG\Nodes\SVGNode; use SVG\Rasterization\SVGRasterizer; /** @@ -21,7 +22,7 @@ public function testShouldNotFailForTooFewPoints() $obj = new PolygonRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -54,7 +55,7 @@ public function testShouldRespectFillRule() { $obj = new PolygonRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); diff --git a/tests/Rasterization/Renderers/RectRendererTest.php b/tests/Rasterization/Renderers/RectRendererTest.php index 92ceb28b..783b9c13 100644 --- a/tests/Rasterization/Renderers/RectRendererTest.php +++ b/tests/Rasterization/Renderers/RectRendererTest.php @@ -3,6 +3,7 @@ namespace SVG\Rasterization\Renderers; use AssertGD\GDSimilarityConstraint; +use SVG\Nodes\SVGNode; use SVG\Rasterization\SVGRasterizer; /** @@ -17,7 +18,7 @@ public function testShouldRenderStroke() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -36,7 +37,7 @@ public function testShouldRenderStrokeThick() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '3px'); @@ -55,7 +56,7 @@ public function testShouldRenderStrokeAlpha() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke-width', '3px'); @@ -74,7 +75,7 @@ public function testShouldRenderFill() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -92,7 +93,7 @@ public function testShouldRenderFillAlpha() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke', 'none'); @@ -110,7 +111,7 @@ public function testShouldRenderStrokeAndFill() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'rgba(255, 255, 255, 0.5)'); $context->setStyle('stroke', 'rgba(0, 0, 0, 0.5)'); $context->setStyle('stroke-width', '5px'); @@ -129,7 +130,7 @@ public function testShouldRenderStrokeRounded() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -149,7 +150,7 @@ public function testShouldRenderFillRounded() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -168,7 +169,7 @@ public function testDoesNotRenderIfWidthZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -188,7 +189,7 @@ public function testDoesNotRenderIfHeightZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -208,7 +209,7 @@ public function testDefaultsXAndYToZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FFFFFF'); $context->setStyle('stroke', '#000000'); $context->setStyle('stroke-width', '5px'); diff --git a/tests/Rasterization/Renderers/TextRendererTest.php b/tests/Rasterization/Renderers/TextRendererTest.php index 88a6ef6c..3ded455d 100644 --- a/tests/Rasterization/Renderers/TextRendererTest.php +++ b/tests/Rasterization/Renderers/TextRendererTest.php @@ -3,6 +3,7 @@ namespace SVG\Rasterization\Renderers; use AssertGD\GDSimilarityConstraint; +use SVG\Nodes\SVGNode; use SVG\Rasterization\SVGRasterizer; /** @@ -17,7 +18,7 @@ public function testShouldNotFailWithoutRegisteredFont() { $obj = new TextRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $rasterizer = new SVGRasterizer('40px', '80px', null, 4, 8); $obj->render($rasterizer, [ diff --git a/tests/Rasterization/SVGRasterizerTest.php b/tests/Rasterization/SVGRasterizerTest.php index 1afa3677..b1bd2650 100644 --- a/tests/Rasterization/SVGRasterizerTest.php +++ b/tests/Rasterization/SVGRasterizerTest.php @@ -4,6 +4,7 @@ use AssertGD\GDSimilarityConstraint; use Exception; +use SVG\Nodes\SVGNode; /** * @requires extension gd @@ -210,7 +211,7 @@ public function testRenderWithNoSuchRenderId() $this->expectException('\InvalidArgumentException'); $obj = new SVGRasterizer(10, 20, [], 100, 200); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->render('invalid_render_id', ['option' => 'value'], $mockChild); } diff --git a/tests/Reading/NodeRegistryTest.php b/tests/Reading/NodeRegistryTest.php index e15f7057..1a36d5da 100644 --- a/tests/Reading/NodeRegistryTest.php +++ b/tests/Reading/NodeRegistryTest.php @@ -2,6 +2,9 @@ namespace SVG\Reading; +use SVG\Nodes\Shapes\SVGRect; +use SVG\Nodes\SVGGenericNodeType; + /** * @covers \SVG\Reading\NodeRegistry * @@ -12,12 +15,12 @@ class NodeRegistryTest extends \PHPUnit\Framework\TestCase public function testShouldConstructKnownTypes() { $result = NodeRegistry::create('rect'); - $this->assertInstanceOf('SVG\Nodes\Shapes\SVGRect', $result); + $this->assertInstanceOf(SVGRect::class, $result); } public function testShouldUseGenericTypeForOthers() { $result = NodeRegistry::create('div'); - $this->assertInstanceOf('SVG\Nodes\SVGGenericNodeType', $result); + $this->assertInstanceOf(SVGGenericNodeType::class, $result); } } diff --git a/tests/Reading/SVGReaderTest.php b/tests/Reading/SVGReaderTest.php index d31a1bd8..4abe476a 100644 --- a/tests/Reading/SVGReaderTest.php +++ b/tests/Reading/SVGReaderTest.php @@ -2,6 +2,8 @@ namespace SVG\Reading; +use SVG\SVG; + /** * @covers \SVG\Reading\SVGReader * @@ -77,7 +79,7 @@ public function testShouldReturnAnImageOrNull() // should return an instance of SVG $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xml); - $this->assertInstanceOf('\SVG\SVG', $result); + $this->assertInstanceOf(SVG::class, $result); // should return null when parsing fails $result = $svgReader->parseString(''); diff --git a/tests/SVGTest.php b/tests/SVGTest.php index c62c41e1..6b65656b 100644 --- a/tests/SVGTest.php +++ b/tests/SVGTest.php @@ -2,6 +2,7 @@ namespace SVG; +use SVG\Nodes\Structures\SVGDocumentFragment; use SVG\SVG; /** @@ -54,7 +55,7 @@ public function testGetDocument() $doc = $image->getDocument(); // should be instanceof the correct class - $docFragClass = '\SVG\Nodes\Structures\SVGDocumentFragment'; + $docFragClass = SVGDocumentFragment::class; $this->assertInstanceOf($docFragClass, $doc); // should be set to root @@ -118,7 +119,7 @@ public function testFromString() $doc = $image->getDocument(); // should return an instance of SVG - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(SVG::class, $image); // should have correct width and height $this->assertSame('37', $doc->getWidth()); @@ -127,7 +128,7 @@ public function testFromString() // should succeed without xml declaration $image = SVG::fromString($this->xmlNoDeclaration); $doc = $image->getDocument(); - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(SVG::class, $image); $this->assertSame('37', $doc->getWidth()); $this->assertSame('42', $doc->getHeight()); } @@ -139,6 +140,6 @@ public function testFromFile() { $image = SVG::fromFile(__DIR__ . '/php_test.svg'); - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(SVG::class, $image); } }