NumberTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Class NumberTest
  4. *
  5. * @filesource NumberTest.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\{Number, QRCodeDataException, QRDataInterface};
  15. /**
  16. * Tests the Number class
  17. */
  18. final class NumberTest extends DatainterfaceTestAbstract{
  19. /** @internal */
  20. protected string $testdata = '0123456789';
  21. /** @internal */
  22. protected array $expected = [
  23. 16, 40, 12, 86, 106, 105, 0, 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. 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. 201, 141, 102, 116, 238, 162, 239, 230,
  34. 222, 37, 79, 192, 42, 109, 188, 72,
  35. 89, 63, 168, 151
  36. ];
  37. /**
  38. * @inheritDoc
  39. * @internal
  40. */
  41. protected function getDataInterfaceInstance(QROptions $options):QRDataInterface{
  42. return new Number($options);
  43. }
  44. /**
  45. * Tests if an exception is thrown when an invalid character is encountered
  46. */
  47. public function testGetCharCodeException():void{
  48. $this->expectException(QRCodeDataException::class);
  49. $this->expectExceptionMessage('illegal char: "#" [35]');
  50. $this->dataInterface->setData('#');
  51. }
  52. }