QRImagickTest.php 1.8 KB

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