QRGdImageTestAbstract.php 1.6 KB

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