ECICharsetTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * ECICharsetTest.php
  4. *
  5. * @created 13.03.2023
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2023 smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeTest\Common;
  11. use chillerlan\QRCode\QRCodeException;
  12. use chillerlan\QRCode\Common\ECICharset;
  13. use PHPUnit\Framework\TestCase;
  14. final class ECICharsetTest extends TestCase{
  15. public static function invalidIdProvider():array{
  16. return [[-1], [1000000]];
  17. }
  18. /**
  19. * @dataProvider invalidIdProvider
  20. */
  21. public function testInvalidDataException(int $id):void{
  22. $this->expectException(QRCodeException::class);
  23. $this->expectExceptionMessage('invalid charset id:');
  24. /** @phan-suppress-next-line PhanNoopNew */
  25. new ECICharset($id);
  26. }
  27. public function encodingProvider():array{
  28. $params = [];
  29. foreach(ECICharset::MB_ENCODINGS as $id => $name){
  30. $params[] = [$id, $name];
  31. }
  32. return $params;
  33. }
  34. /**
  35. * @dataProvider encodingProvider
  36. */
  37. public function testGetName(int $id, ?string $name = null):void{
  38. $eciCharset = new ECICharset($id);
  39. $this::assertSame($id, $eciCharset->getID());
  40. $this::assertSame($name, $eciCharset->getName());
  41. }
  42. }