QRInterventionImageTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Class QRInterventionImageTest
  4. *
  5. * @created 04.05.2024
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2024 smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. namespace chillerlan\QRCodeTest\Output;
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\QRInterventionImage;
  14. use chillerlan\QRCode\Output\QROutputInterface;
  15. use chillerlan\QRCode\QROptions;
  16. use chillerlan\Settings\SettingsContainerInterface;
  17. use Intervention\Image\Interfaces\ImageInterface;
  18. use function extension_loaded;
  19. /**
  20. * Tests the QRInterventionImage output module
  21. */
  22. class QRInterventionImageTest extends QROutputTestAbstract{
  23. use CssColorModuleValueProviderTrait;
  24. protected function setUp():void{
  25. if(!extension_loaded('gd')){
  26. $this::markTestSkipped('ext-gd not loaded');
  27. }
  28. parent::setUp();
  29. }
  30. protected function getOutputInterface(
  31. SettingsContainerInterface|QROptions $options,
  32. QRMatrix $matrix,
  33. ):QROutputInterface{
  34. return new QRInterventionImage($options, $matrix);
  35. }
  36. public function testSetModuleValues():void{
  37. $this->options->moduleValues = [
  38. // data
  39. QRMatrix::M_DATA_DARK => '#4A6000',
  40. QRMatrix::M_DATA => '#ECF9BE',
  41. ];
  42. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  43. $this->outputInterface->dump();
  44. /** @phpstan-ignore-next-line */
  45. $this::assertTrue(true); // tricking the code coverage
  46. }
  47. public function testOutputGetResource():void{
  48. $this->options->returnResource = true;
  49. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  50. $this::assertInstanceOf(ImageInterface::class, $this->outputInterface->dump());
  51. }
  52. }