ErrorCorrectionLevelTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * BaconQrCode
  4. *
  5. * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6. * @copyright 2013 Ben 'DASPRiD' Scholzen
  7. * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8. */
  9. namespace BaconQrCode\Common;
  10. use PHPUnit_Framework_TestCase as TestCase;
  11. class ErrorCorrectionLevelTest extends TestCase
  12. {
  13. public function testCreationThrowsNoException()
  14. {
  15. new ErrorCorrectionLevel(ErrorCorrectionLevel::M);
  16. new ErrorCorrectionLevel(ErrorCorrectionLevel::L);
  17. new ErrorCorrectionLevel(ErrorCorrectionLevel::H);
  18. new ErrorCorrectionLevel(ErrorCorrectionLevel::Q);
  19. }
  20. public function testBitsMatchConstants()
  21. {
  22. $this->assertEquals(0x0, ErrorCorrectionLevel::M);
  23. $this->assertEquals(0x1, ErrorCorrectionLevel::L);
  24. $this->assertEquals(0x2, ErrorCorrectionLevel::H);
  25. $this->assertEquals(0x3, ErrorCorrectionLevel::Q);
  26. }
  27. public function testInvalidErrorCorrectionLevelThrowsException()
  28. {
  29. $this->setExpectedException(
  30. 'BaconQrCode\Exception\UnexpectedValueException',
  31. 'Value not a const in enum BaconQrCode\Common\ErrorCorrectionLevel'
  32. );
  33. new ErrorCorrectionLevel(4);
  34. }
  35. }