EccLevelTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Class EccLevelTest
  4. *
  5. * @created 25.07.2022
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2022 smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeTest\Common;
  11. use chillerlan\QRCode\Common\EccLevel;
  12. use chillerlan\QRCode\Common\MaskPattern;
  13. use chillerlan\QRCode\QRCodeException;
  14. use PHPUnit\Framework\TestCase;
  15. /**
  16. * EccLevel coverage test
  17. */
  18. final class EccLevelTest extends TestCase{
  19. public function testConstructInvalidEccException():void{
  20. $this->expectException(QRCodeException::class);
  21. $this->expectExceptionMessage('invalid ECC level');
  22. /** @phan-suppress-next-line PhanNoopNew */
  23. new EccLevel(69);
  24. }
  25. public function testToString():void{
  26. $ecc = new EccLevel(EccLevel::L);
  27. $this::assertSame('L', (string)$ecc);
  28. }
  29. public function testGetLevel():void{
  30. $ecc = new EccLevel(EccLevel::L);
  31. $this::assertSame(EccLevel::L, $ecc->getLevel());
  32. }
  33. public function testGetOrdinal():void{
  34. $ecc = new EccLevel(EccLevel::L);
  35. $this::assertSame(0, $ecc->getOrdinal());
  36. }
  37. public function testGetformatPattern():void{
  38. $ecc = new EccLevel(EccLevel::Q);
  39. $this::assertSame(0b010010010110100, $ecc->getformatPattern(new MaskPattern(4)));
  40. }
  41. public function getMaxBits():void{
  42. $ecc = new EccLevel(EccLevel::Q);
  43. $this::assertSame(4096, $ecc->getMaxBits()[21]);
  44. }
  45. }