QRImageTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Output\QRImage;
  14. use chillerlan\QRCode\QRCode;
  15. class QRImageTest extends QROutputTestAbstract{
  16. protected $FQCN = QRImage::class;
  17. public function types(){
  18. return [
  19. [QRCode::OUTPUT_IMAGE_PNG],
  20. [QRCode::OUTPUT_IMAGE_GIF],
  21. [QRCode::OUTPUT_IMAGE_JPG],
  22. ];
  23. }
  24. /**
  25. * @dataProvider types
  26. * @param $type
  27. */
  28. public function testImageOutput($type){
  29. $this->options->outputType = $type;
  30. $this->options->cachefile = $this::cachefile.$type;
  31. $this->setOutputInterface();
  32. $this->outputInterface->dump();
  33. $this->options->cachefile = null;
  34. $this->options->imageBase64 = false;
  35. $this->setOutputInterface();
  36. $img = $this->outputInterface->dump();
  37. if($type === QRCode::OUTPUT_IMAGE_JPG){ // jpeg encoding may cause different results
  38. $this->markAsRisky();
  39. }
  40. $this->assertSame($img, file_get_contents($this::cachefile.$type));
  41. }
  42. }