KanjiTest.php 1.6 KB

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