AlphaNumTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Class AlphaNumTest
  4. *
  5. * @created 24.11.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. namespace chillerlan\QRCodeTest\Data;
  12. use chillerlan\QRCode\Data\AlphaNum;
  13. use chillerlan\QRCode\Data\QRDataModeInterface;
  14. /**
  15. * Tests the AlphaNum class
  16. */
  17. final class AlphaNumTest extends DataInterfaceTestAbstract{
  18. protected const testData = '0 $%*+-./:';
  19. protected static function getDataModeInterface(string $data):QRDataModeInterface{
  20. return new AlphaNum($data);
  21. }
  22. /**
  23. * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase)
  24. *
  25. * @phpstan-return array<int, array{0: string, 1: bool}>
  26. */
  27. public static function stringValidateProvider():array{
  28. return [
  29. ['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
  30. ['abc', false],
  31. ['ÄÖÜ', false],
  32. [',', false],
  33. ['-', true],
  34. ['+', true],
  35. ['.', true],
  36. ['*', true],
  37. [':', true],
  38. ['/', true],
  39. ['\\', false],
  40. ];
  41. }
  42. }