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