QRGdImageTestAbstract.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. namespace chillerlan\QRCodeTest\Output;
  11. use chillerlan\QRCode\Data\QRMatrix;
  12. use chillerlan\QRCode\Output\QRGdImage;
  13. use const PHP_MAJOR_VERSION;
  14. /**
  15. * Tests the QRGdImage output module
  16. */
  17. abstract class QRGdImageTestAbstract extends QROutputTestAbstract{
  18. protected string $FQN = QRGdImage::class;
  19. /**
  20. * @inheritDoc
  21. */
  22. protected function setUp():void{
  23. if(!extension_loaded('gd')){
  24. $this::markTestSkipped('ext-gd not loaded');
  25. }
  26. parent::setUp();
  27. }
  28. /**
  29. * @inheritDoc
  30. */
  31. public function testSetModuleValues():void{
  32. $this->options->moduleValues = [
  33. // data
  34. QRMatrix::M_DATA | QRMatrix::IS_DARK => [0, 0, 0],
  35. QRMatrix::M_DATA => [255, 255, 255],
  36. ];
  37. $this->outputInterface = new $this->FQN($this->options, $this->matrix);
  38. $this->outputInterface->dump();
  39. $this::assertTrue(true); // tricking the code coverage
  40. }
  41. /**
  42. *
  43. */
  44. public function testOutputGetResource():void{
  45. $this->options->returnResource = true;
  46. $this->outputInterface = new $this->FQN($this->options, $this->matrix);
  47. $actual = $this->outputInterface->dump();
  48. /** @noinspection PhpFullyQualifiedNameUsageInspection */
  49. PHP_MAJOR_VERSION >= 8
  50. ? $this::assertInstanceOf(\GdImage::class, $actual)
  51. : $this::assertIsResource($actual);
  52. }
  53. }