QRGdImageTestAbstract.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 PHPUnit\Framework\Attributes\{RequiresPhpExtension, Test};
  17. use GdImage;
  18. /**
  19. * Tests the QRGdImage output classes
  20. */
  21. #[RequiresPhpExtension('gd')]
  22. abstract class QRGdImageTestAbstract extends QROutputTestAbstract{
  23. use RGBArrayModuleValueProviderTrait;
  24. #[Test]
  25. public function setModuleValues():void{
  26. $this->options->moduleValues = [
  27. // data
  28. QRMatrix::M_DATA_DARK => [0, 0, 0],
  29. QRMatrix::M_DATA => [255, 255, 255],
  30. ];
  31. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  32. $this->outputInterface->dump();
  33. /** @phpstan-ignore-next-line */
  34. $this::assertTrue(true); // tricking the code coverage
  35. }
  36. #[Test]
  37. public function outputGetResource():void{
  38. $this->options->returnResource = true;
  39. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  40. $this::assertInstanceOf(GdImage::class, $this->outputInterface->dump());
  41. }
  42. #[Test]
  43. public function base64MimeType():void{
  44. $this->options->outputBase64 = true;
  45. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  46. $this::assertStringContainsString($this->outputInterface::MIME_TYPE, $this->outputInterface->dump());
  47. }
  48. }