QRImagickTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\Output\{QROutputInterface, QRImagick};
  19. /**
  20. * Tests the QRImagick output module
  21. */
  22. class QRImagickTest extends QROutputTestAbstract{
  23. /**
  24. * @inheritDoc
  25. * @internal
  26. */
  27. public function setUp():void{
  28. if(!extension_loaded('imagick')){
  29. $this->markTestSkipped('ext-imagick not loaded');
  30. /** @noinspection PhpUnreachableStatementInspection */
  31. return;
  32. }
  33. parent::setUp();
  34. }
  35. /**
  36. * @inheritDoc
  37. * @internal
  38. */
  39. protected function getOutputInterface(QROptions $options):QROutputInterface{
  40. return new QRImagick($options, $this->matrix);
  41. }
  42. /**
  43. * @inheritDoc
  44. * @internal
  45. */
  46. public function types():array{
  47. return [
  48. 'imagick' => [QRCode::OUTPUT_IMAGICK],
  49. ];
  50. }
  51. /**
  52. * @inheritDoc
  53. */
  54. public function testSetModuleValues():void{
  55. $this->options->moduleValues = [
  56. // data
  57. 1024 => '#4A6000',
  58. 4 => '#ECF9BE',
  59. ];
  60. $this->outputInterface = $this->getOutputInterface($this->options);
  61. $this->outputInterface->dump();
  62. $this::assertTrue(true); // tricking the code coverage
  63. }
  64. public function testOutputGetResource():void{
  65. $this->options->returnResource = true;
  66. $this->outputInterface = $this->getOutputInterface($this->options);
  67. $this::assertInstanceOf(Imagick::class, $this->outputInterface->dump());
  68. }
  69. }