QRGdImageTestAbstract.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. declare(strict_types=1);
  13. namespace chillerlan\QRCodeTest\Output;
  14. use chillerlan\QRCode\Data\QRMatrix;
  15. use GdImage;
  16. use function extension_loaded;
  17. /**
  18. * Tests the QRGdImage output module
  19. */
  20. abstract class QRGdImageTestAbstract extends QROutputTestAbstract{
  21. use RGBArrayModuleValueProviderTrait;
  22. protected function setUp():void{
  23. if(!extension_loaded('gd')){
  24. $this::markTestSkipped('ext-gd not loaded');
  25. }
  26. parent::setUp();
  27. }
  28. public function testSetModuleValues():void{
  29. $this->options->moduleValues = [
  30. // data
  31. QRMatrix::M_DATA_DARK => [0, 0, 0],
  32. QRMatrix::M_DATA => [255, 255, 255],
  33. ];
  34. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  35. $this->outputInterface->dump();
  36. /** @phpstan-ignore-next-line */
  37. $this::assertTrue(true); // tricking the code coverage
  38. }
  39. public function testOutputGetResource():void{
  40. $this->options->returnResource = true;
  41. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  42. $this::assertInstanceOf(GdImage::class, $this->outputInterface->dump());
  43. }
  44. public function testBase64MimeType():void{
  45. $this->options->outputBase64 = true;
  46. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  47. $this::assertStringContainsString($this->outputInterface::MIME_TYPE, $this->outputInterface->dump());
  48. }
  49. }