KanjiTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Class KanjiTest
  4. *
  5. * @created 24.11.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeTest\Data;
  11. use chillerlan\QRCode\Data\{Kanji, QRCodeDataException};
  12. /**
  13. * Tests the Kanji class
  14. */
  15. final class KanjiTest extends DatainterfaceTestAbstract{
  16. /** @internal */
  17. protected array $testdata = [Kanji::class, '茗荷茗荷茗荷茗荷茗荷'];
  18. /** @internal */
  19. protected array $expected = [
  20. 128, 173, 85, 26, 95, 85, 70, 151,
  21. 213, 81, 165, 245, 84, 105, 125, 85,
  22. 26, 92, 0, 236, 17, 236, 17, 236,
  23. 17, 236, 17, 236, 17, 236, 17, 236,
  24. 17, 236, 17, 236, 17, 236, 17, 236,
  25. 17, 236, 17, 236, 17, 236, 17, 236,
  26. 17, 236, 17, 236, 17, 236, 17, 236,
  27. 17, 236, 17, 236, 17, 236, 17, 236,
  28. 17, 236, 17, 236, 17, 236, 17, 236,
  29. 17, 236, 17, 236, 17, 236, 17, 236,
  30. 195, 11, 221, 91, 141, 220, 163, 46,
  31. 165, 37, 163, 176, 79, 0, 64, 68,
  32. 96, 113, 54, 191
  33. ];
  34. /**
  35. * Tests if an exception is thrown when an invalid character is encountered
  36. */
  37. public function testIllegalCharException1():void{
  38. $this->expectException(QRCodeDataException::class);
  39. $this->expectExceptionMessage('illegal char at 1 [16191]');
  40. $this->testdata = [Kanji::class, 'ÃÃ'];
  41. $this->setTestData();
  42. }
  43. /**
  44. * Tests if an exception is thrown when an invalid character is encountered
  45. */
  46. public function testIllegalCharException2():void{
  47. $this->expectException(QRCodeDataException::class);
  48. $this->expectExceptionMessage('illegal char at 1');
  49. $this->testdata = [Kanji::class, 'Ã'];
  50. $this->setTestData();
  51. }
  52. }