QRImagickTest.php 1.6 KB

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