QRImageTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Class QRImageTest
  4. *
  5. * @filesource QRImageTest.php
  6. * @created 24.12.2017
  7. * @package chillerlan\QRCodeTest\Output
  8. * @author Smiley <smiley@chillerlan.net>
  9. * @copyright 2017 Smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCodeTest\Output;
  13. use chillerlan\QRCode\{QRCode, Output\QRImage};
  14. class QRImageTest extends QROutputTestAbstract{
  15. protected string $FQCN = QRImage::class;
  16. public function types():array{
  17. return [
  18. 'png' => [QRCode::OUTPUT_IMAGE_PNG],
  19. 'gif' => [QRCode::OUTPUT_IMAGE_GIF],
  20. 'jpg' => [QRCode::OUTPUT_IMAGE_JPG],
  21. ];
  22. }
  23. /**
  24. * @dataProvider types
  25. */
  26. public function testImageOutput(string $type):void{
  27. $this->options->outputType = $type;
  28. $this->options->imageBase64 = false;
  29. $this->setOutputInterface();
  30. $this->outputInterface->dump($this::cachefile.$type);
  31. $img = $this->outputInterface->dump();
  32. if($type === QRCode::OUTPUT_IMAGE_JPG){ // jpeg encoding may cause different results
  33. $this->markAsRisky();
  34. }
  35. $this::assertSame($img, file_get_contents($this::cachefile.$type));
  36. }
  37. public function testSetModuleValues():void{
  38. $this->options->moduleValues = [
  39. // data
  40. 1024 => [0, 0, 0],
  41. 4 => [255, 255, 255],
  42. ];
  43. $this->setOutputInterface()->dump();
  44. $this::assertTrue(true); // tricking the code coverage
  45. }
  46. }