AlphaNumTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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, QRDataModeInterface};
  13. /**
  14. * Tests the AlphaNum class
  15. */
  16. final class AlphaNumTest extends DataInterfaceTestAbstract{
  17. protected const testData = '0 $%*+-./:';
  18. protected static function getDataModeInterface(string $data):QRDataModeInterface{
  19. return new AlphaNum($data);
  20. }
  21. /**
  22. * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase)
  23. *
  24. * @phpstan-return array<int, array{0: string, 1: bool}>
  25. */
  26. public static function stringValidateProvider():array{
  27. return [
  28. ['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
  29. ['abc', false],
  30. ['ÄÖÜ', false],
  31. [',', false],
  32. ['-', true],
  33. ['+', true],
  34. ['.', true],
  35. ['*', true],
  36. [':', true],
  37. ['/', true],
  38. ['\\', false],
  39. ];
  40. }
  41. }