QRImagickTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Class QRImagickTest
  4. *
  5. * @created 04.07.2018
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2018 smiley
  8. * @license MIT
  9. *
  10. * @noinspection PhpUndefinedClassInspection
  11. * @noinspection PhpComposerExtensionStubsInspection
  12. */
  13. namespace chillerlan\QRCodeTest\Output;
  14. use Imagick;
  15. use chillerlan\QRCode\{QRCode, QROptions};
  16. use chillerlan\QRCode\Output\{QROutputInterface, QRImagick};
  17. /**
  18. * Tests the QRImagick output module
  19. */
  20. class QRImagickTest extends QROutputTestAbstract{
  21. /**
  22. * @inheritDoc
  23. * @internal
  24. */
  25. public function setUp():void{
  26. if(!extension_loaded('imagick')){
  27. $this->markTestSkipped('ext-imagick not loaded');
  28. /** @noinspection PhpUnreachableStatementInspection */
  29. return;
  30. }
  31. parent::setUp();
  32. }
  33. /**
  34. * @inheritDoc
  35. * @internal
  36. */
  37. protected function getOutputInterface(QROptions $options):QROutputInterface{
  38. return new QRImagick($options, $this->matrix);
  39. }
  40. /**
  41. * @inheritDoc
  42. * @internal
  43. */
  44. public function types():array{
  45. return [
  46. 'imagick' => [QRCode::OUTPUT_IMAGICK],
  47. ];
  48. }
  49. /**
  50. * @inheritDoc
  51. */
  52. public function testSetModuleValues():void{
  53. $this->options->moduleValues = [
  54. // data
  55. 1024 => '#4A6000',
  56. 4 => '#ECF9BE',
  57. ];
  58. $this->outputInterface = $this->getOutputInterface($this->options);
  59. $this->outputInterface->dump();
  60. $this::assertTrue(true); // tricking the code coverage
  61. }
  62. public function testOutputGetResource():void{
  63. $this->options->returnResource = true;
  64. $this->outputInterface = $this->getOutputInterface($this->options);
  65. $this::assertInstanceOf(Imagick::class, $this->outputInterface->dump());
  66. }
  67. }