QRInterventionImageTest.php 1.7 KB

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