QRGdImageTestAbstract.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Class QRGdImageTestAbstract
  4. *
  5. * @created 24.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. *
  10. * @noinspection PhpComposerExtensionStubsInspection
  11. */
  12. namespace chillerlan\QRCodeTest\Output;
  13. use chillerlan\QRCode\Data\QRMatrix;
  14. use GdImage;
  15. use function extension_loaded;
  16. /**
  17. * Tests the QRGdImage output module
  18. */
  19. abstract class QRGdImageTestAbstract extends QROutputTestAbstract{
  20. use RGBArrayModuleValueProviderTrait;
  21. /**
  22. * @inheritDoc
  23. */
  24. protected function setUp():void{
  25. if(!extension_loaded('gd')){
  26. $this::markTestSkipped('ext-gd not loaded');
  27. }
  28. parent::setUp();
  29. }
  30. /**
  31. * @inheritDoc
  32. */
  33. public function testSetModuleValues():void{
  34. $this->options->moduleValues = [
  35. // data
  36. QRMatrix::M_DATA_DARK => [0, 0, 0],
  37. QRMatrix::M_DATA => [255, 255, 255],
  38. ];
  39. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  40. $this->outputInterface->dump();
  41. /** @phpstan-ignore-next-line */
  42. $this::assertTrue(true); // tricking the code coverage
  43. }
  44. public function testOutputGetResource():void{
  45. $this->options->returnResource = true;
  46. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  47. $this::assertInstanceOf(GdImage::class, $this->outputInterface->dump());
  48. }
  49. public function testBase64MimeType():void{
  50. $this->options->outputBase64 = true;
  51. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  52. $this::assertStringContainsString($this->outputInterface::MIME_TYPE, $this->outputInterface->dump());
  53. }
  54. }