EccLevelTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\QRCodeException;
  12. use chillerlan\QRCode\Common\{EccLevel, MaskPattern};
  13. use PHPUnit\Framework\TestCase;
  14. /**
  15. * EccLevel coverage test
  16. */
  17. final class EccLevelTest extends TestCase{
  18. public function testConstructInvalidEccException():void{
  19. $this->expectException(QRCodeException::class);
  20. $this->expectExceptionMessage('invalid ECC level');
  21. /** @phan-suppress-next-line PhanNoopNew */
  22. new EccLevel(69);
  23. }
  24. public function testToString():void{
  25. $ecc = new EccLevel(EccLevel::L);
  26. $this::assertSame('L', (string)$ecc);
  27. }
  28. public function testGetLevel():void{
  29. $ecc = new EccLevel(EccLevel::L);
  30. $this::assertSame(EccLevel::L, $ecc->getLevel());
  31. }
  32. public function testGetOrdinal():void{
  33. $ecc = new EccLevel(EccLevel::L);
  34. $this::assertSame(0, $ecc->getOrdinal());
  35. }
  36. public function testGetformatPattern():void{
  37. $ecc = new EccLevel(EccLevel::Q);
  38. $this::assertSame(0b010010010110100, $ecc->getformatPattern(new MaskPattern(4)));
  39. }
  40. public function getMaxBits():void{
  41. $ecc = new EccLevel(EccLevel::Q);
  42. $this::assertSame(4096, $ecc->getMaxBits()[21]);
  43. }
  44. }