QRMarkupSVGTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Class QRMarkupSVGTest
  4. *
  5. * @created 11.12.2021
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2021 smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeTest\Output;
  11. use chillerlan\QRCode\QROptions;
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\{QRMarkupSVG, QROutputInterface};
  14. /**
  15. *
  16. */
  17. final class QRMarkupSVGTest extends QRMarkupTestAbstract{
  18. protected string $type = QROutputInterface::MARKUP_SVG;
  19. protected function getOutputInterface(QROptions $options, QRMatrix $matrix):QROutputInterface{
  20. return new QRMarkupSVG($options, $matrix);
  21. }
  22. public static function moduleValueProvider():array{
  23. return [
  24. // css colors from parent
  25. 'valid: hex color (3)' => ['#abc', true],
  26. 'valid: hex color (4)' => ['#abcd', true],
  27. 'valid: hex color (6)' => ['#aabbcc', true],
  28. 'valid: hex color (8)' => ['#aabbccdd', true],
  29. 'invalid: hex color (non-hex)' => ['#aabbcxyz', false],
  30. 'invalid: hex color (too short)' => ['#aa', false],
  31. 'invalid: hex color (5)' => ['#aabbc', false],
  32. 'invalid: hex color (7)' => ['#aabbccd', false],
  33. 'valid: rgb(...%)' => ['rgb(100.0%, 0.0%, 0.0%)', true],
  34. 'valid: rgba(...)' => [' rgba(255, 0, 0, 1.0) ', true],
  35. 'valid: hsl(...)' => ['hsl(120, 60%, 50%)', true],
  36. 'valid: hsla(...)' => ['hsla(120, 255, 191.25, 1.0)', true],
  37. 'invalid: rgba(non-numeric)' => ['rgba(255, 0, whatever, 0, 1.0)', false],
  38. 'invalid: rgba(extra-char)' => ['rgba(255, 0, 0, 1.0);', false],
  39. 'valid: csscolor' => ['purple', true],
  40. 'invalid: c5sc0lor' => ['c5sc0lor', false],
  41. // SVG
  42. 'valid: url(#id)' => ['url(#fillGradient)', true],
  43. 'invalid: url(link)' => ['url(https://example.com/noop)', false],
  44. ];
  45. }
  46. }