CssColorModuleValueProviderTrait.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * CssColorModuleValueProviderTrait.php
  4. *
  5. * @created 04.05.2024
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2024 smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. namespace chillerlan\QRCodeTest\Traits;
  12. /**
  13. * A data provider for use in tests that include CssColorModuleValueTrait
  14. *
  15. * @see \chillerlan\QRCode\Output\CssColorModuleValueTrait
  16. */
  17. trait CssColorModuleValueProviderTrait{
  18. public static function moduleValueProvider():array{
  19. return [
  20. 'invalid: wrong type' => [[], false],
  21. 'valid: hex color (3)' => ['#abc', true],
  22. 'valid: hex color (4)' => ['#abcd', true],
  23. 'valid: hex color (6)' => ['#aabbcc', true],
  24. 'valid: hex color (8)' => ['#aabbccdd', true],
  25. 'invalid: hex color (non-hex)' => ['#aabbcxyz', false],
  26. 'invalid: hex color (too short)' => ['#aa', false],
  27. 'invalid: hex color (5)' => ['#aabbc', false],
  28. 'invalid: hex color (7)' => ['#aabbccd', false],
  29. 'valid: rgb(...%)' => ['rgb(100.0%, 0.0%, 0.0%)', true],
  30. 'valid: rgba(...)' => [' rgba(255, 0, 0, 1.0) ', true],
  31. 'valid: hsl(...)' => ['hsl(120, 60%, 50%)', true],
  32. 'valid: hsla(...)' => ['hsla(120, 255, 191.25, 1.0)', true],
  33. 'invalid: rgba(non-numeric)' => ['rgba(255, 0, whatever, 0, 1.0)', false],
  34. 'invalid: rgba(extra-char)' => ['rgba(255, 0, 0, 1.0);', false],
  35. 'valid: csscolor' => ['purple', true],
  36. 'invalid: c5sc0lor' => ['c5sc0lor', false],
  37. ];
  38. }
  39. }