QRGdImageTestAbstract.php 1.6 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. * @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. $this::assertTrue(true); // tricking the code coverage
  42. }
  43. public function testOutputGetResource():void{
  44. $this->options->returnResource = true;
  45. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  46. $this::assertInstanceOf(GdImage::class, $this->outputInterface->dump());
  47. }
  48. public function testBase64MimeType():void{
  49. $this->options->outputBase64 = true;
  50. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  51. $this::assertStringContainsString($this->outputInterface::MIME_TYPE, $this->outputInterface->dump());
  52. }
  53. }