Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing #35

Closed
meyfa opened this issue Dec 30, 2017 · 1 comment
Closed

Unit testing #35

meyfa opened this issue Dec 30, 2017 · 1 comment
Assignees
Labels
enhancement Improvement to an existing feature tooling Related to test setup or continuous integration

Comments

@meyfa
Copy link
Owner

meyfa commented Dec 30, 2017

Intro

As it currently stands, this project has almost no unit tests, despite having the testing framework and CI set up. The time has come to change that.

The following list shall track the things that need to have tests added.

Task List

Base Classes

  • SVG\SVG
    • convertUnit (pt, pc, cm, mm, in, %, px; no unit; different parameter types)
    • convertAngleUnit
    • parseColor (named colors, nonexisting color names; HEX_6, HEX_6, RGB, RGBA, HSL, HSLA (all with overflow))
  • SVG\SVGImage
    • getDocument
    • toRasterImage (return type; width, height)
    • __toString (calls toXMLString)
    • toXMLString
    • fromString (return type)
    • fromFile

Nodes

  • SVG\Nodes\SVGNode
    • constructFromAttributes (constructs child class)
    • getName (returns static::TAG_NAME)
    • getStyle (existent entry; nonexistent entry)
    • setStyle (property is updated; value converted to string)
    • getValue
    • setValue
    • removeStyle (property is unset)
    • getAttribute (existent entry; nonexistent entry)
    • setAttribute (property is updated; value converted to string)
    • removeAttribute (property is unset)
    • getSerializableAttributes (returns $this->attributes)
    • getSerializableStyles (returns $this->styles)
    • getViewBox
  • SVG\Nodes\SVGNodeContainer
    • addChild (duplicate, self; removes from previous; adds, container styles ??)
    • removeChild (instance vs. index; removes, sets $parent; nonexistent child)
    • rasterize (display: none; calls children; ignores visibility)
    • getElementsByTagName
    • getElementsByClassName

Embedded

  • SVG\Nodes\Embedded\SVGImageElement
    • constructor attributes
    • getHref (both versions)
    • setHref (sets xlink:href)
    • attribute getters and setters
    • rasterize (calls render('image', ...); correct options; display, visibility)

Shapes

  • SVG\Nodes\Shapes\SVGCircle
    • constructor attributes
    • attribute getters and setters
    • rasterize (calls render('ellipse', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGEllipse
    • constructor attributes
    • attribute getters and setters
    • rasterize (calls render('ellipse', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGLine
    • constructor attributes
    • attribute getters and setters
    • rasterize (calls render('line', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGPath
    • constructor attributes
    • attribute getters and setters
    • rasterize (calls parser and approximator; calls render('polygon', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGPolygonalShape
    • constructor attributes
    • constructFromAttributes
    • addPoint (array vs. floats)
    • removePoint (removes; out of range behavior)
    • getPoint
    • setPoint
    • getSerializableAttributes (includes points correctly stringified)
  • SVG\Nodes\Shapes\SVGPolygon
    • constructor attributes
    • rasterize (calls render('polygon', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGPolyline
    • constructor attributes
    • rasterize (calls render('polygon', ...); correct options; display, visibility)
  • SVG\Nodes\Shapes\SVGRect
    • constructor attributes
    • attribute getters and setters
    • rasterize (calls render('rect', ...); correct options; display, visibility)

Structures

  • SVG\Nodes\Structures\SVGDefs
    • constructor attributes
    • rasterize (does not render children)
  • SVG\Nodes\Structures\SVGDocumentFragment
    • constructor attributes
    • attribute getters and setters
    • getComputedStyle (initial style if not explicit)
    • getSerializableAttributes (namespaces if root, xmlns: prefix, xlink (once!); width and height if not default)
    • getElementById
  • SVG\Nodes\Structures\SVGStyle
    • setType
    • getType
    • setCss
    • getCss

Rasterization

  • SVG\Rasterization\SVGRasterizer
    • getPathParser
    • getPathApproximator
    • getDocumentWidth, getDocumentHeight (pixel conversion; default value)
    • getWidth, getHeight
    • getScaleX, getScaleY (viewbox vs. no viewbox)
    • getOffsetX, getOffsetY (viewbox vs. no viewbox)
    • getViewBox
    • getImage (returns working image)

Path

  • SVG\Rasterization\Path\SVGArcApproximator
    • approximate
  • SVG\Rasterization\Path\SVGBezierApproximator
    • quadratic
    • cubic
  • SVG\Rasterization\Path\SVGPathApproximator
    • approximate (?)
  • SVG\Rasterization\Path\SVGPathParser
    • should split commands and arguments correctly
    • should support repeated commands
    • should treat repeated MoveTo like implicit LineTo
    • should abort on error
  • SVG\Rasterization\Path\SVGPolygonBuilder
    • constructor
    • build
    • getFirstPoint
    • getLastPoint
    • getPosition
    • addPoint
    • addPointRelative
    • addPoints

Renderers

  • SVG\Rasterization\Renderers\SVGRenderer
    • render (calls prepareRenderParams, renderFill (if needed), renderStroke (if needed); correct color conversion)

Reading

  • SVG\Reading\SVGReader
    • should return an SVGImage or null on error
    • should set all namespaces and attributes (including namespace prefixed ones)
    • should set styles (attributes and style properties)
    • should recurse into child nodes
    • should not fail for unknown nodes

Writing

  • SVG\Writing\SVGWriter
    • should include the XML declaration
    • should write opening and closing tags
    • should write attributes
    • should serialize styles correctly
    • should write child nodes for containers
    • should enclose SVGStyle content in CDATA
@meyfa meyfa added the enhancement Improvement to an existing feature label Dec 30, 2017
@meyfa meyfa self-assigned this Dec 30, 2017
@meyfa
Copy link
Owner Author

meyfa commented Mar 10, 2018

All key points in this issue are now covered by unit tests. While there certainly are even more things that could be tested (especially rasterization), those would be out of scope here. Closing this issue now.

@meyfa meyfa closed this as completed Mar 10, 2018
@meyfa meyfa added the tooling Related to test setup or continuous integration label Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature tooling Related to test setup or continuous integration
Projects
None yet
Development

No branches or pull requests

1 participant