KanjiTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\QROptions;
  14. use chillerlan\QRCode\Data\{Kanji, QRCodeDataException, QRDataInterface};
  15. /**
  16. * Tests the Kanji class
  17. */
  18. final class KanjiTest extends DatainterfaceTestAbstract{
  19. /** @internal */
  20. protected string $testdata = '茗荷茗荷茗荷茗荷茗荷';
  21. /** @internal */
  22. protected array $expected = [
  23. 128, 173, 85, 26, 95, 85, 70, 151,
  24. 213, 81, 165, 245, 84, 105, 125, 85,
  25. 26, 92, 0, 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. 17, 236, 17, 236, 17, 236, 17, 236,
  33. 195, 11, 221, 91, 141, 220, 163, 46,
  34. 165, 37, 163, 176, 79, 0, 64, 68,
  35. 96, 113, 54, 191
  36. ];
  37. /**
  38. * @inheritDoc
  39. * @internal
  40. */
  41. protected function getDataInterfaceInstance(QROptions $options):QRDataInterface{
  42. return new Kanji($options);
  43. }
  44. /**
  45. * Tests if an exception is thrown when an invalid character is encountered
  46. */
  47. public function testIllegalCharException1():void{
  48. $this->expectException(QRCodeDataException::class);
  49. $this->expectExceptionMessage('illegal char at 1 [16191]');
  50. $this->dataInterface->setData('ÃÃ');
  51. }
  52. /**
  53. * Tests if an exception is thrown when an invalid character is encountered
  54. */
  55. public function testIllegalCharException2():void{
  56. $this->expectException(QRCodeDataException::class);
  57. $this->expectExceptionMessage('illegal char at 1');
  58. $this->dataInterface->setData('Ã');
  59. }
  60. }