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. use function str_repeat;
  15. class KanjiTest extends DatainterfaceTestAbstract{
  16. protected string $FQCN = Kanji::class;
  17. protected string $testdata = '茗荷茗荷茗荷茗荷茗荷';
  18. protected array $expected = [
  19. 128, 173, 85, 26, 95, 85, 70, 151,
  20. 213, 81, 165, 245, 84, 105, 125, 85,
  21. 26, 92, 0, 236, 17, 236, 17, 236,
  22. 17, 236, 17, 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. 195, 11, 221, 91, 141, 220, 163, 46,
  30. 165, 37, 163, 176, 79, 0, 64, 68,
  31. 96, 113, 54, 191
  32. ];
  33. public function testIllegalCharException1():void{
  34. $this->expectException(QRCodeDataException::class);
  35. $this->expectExceptionMessage('illegal char at 1 [16191]');
  36. $this->dataInterface->setData('ÃÃ');
  37. }
  38. public function testIllegalCharException2():void{
  39. $this->expectException(QRCodeDataException::class);
  40. $this->expectExceptionMessage('illegal char at 1');
  41. $this->dataInterface->setData('Ã');
  42. }
  43. public function testCodeLengthOverflowException():void{
  44. $this->expectException(QRCodeDataException::class);
  45. $this->expectExceptionMessage('code length overflow');
  46. $this->dataInterface->setData(str_repeat('荷', 1337));
  47. }
  48. }