QRMarkupSVGTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. use chillerlan\Settings\SettingsContainerInterface;
  15. final class QRMarkupSVGTest extends QRMarkupTestAbstract{
  16. protected function getOutputInterface(
  17. SettingsContainerInterface|QROptions $options,
  18. QRMatrix $matrix,
  19. ):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. }