QRFpdfTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Class QRFpdfTest
  4. *
  5. * @created 03.06.2020
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2020 smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. namespace chillerlan\QRCodeTest\Output;
  12. use chillerlan\QRCode\QROptions;
  13. use chillerlan\QRCode\Data\QRMatrix;
  14. use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface};
  15. use chillerlan\QRCodeTest\Traits\RGBArrayModuleValueProviderTrait;
  16. use chillerlan\Settings\SettingsContainerInterface;
  17. use FPDF;
  18. use function class_exists;
  19. /**
  20. * Tests the QRFpdf output module
  21. */
  22. final class QRFpdfTest extends QROutputTestAbstract{
  23. use RGBArrayModuleValueProviderTrait;
  24. protected function setUp():void{
  25. if(!class_exists(FPDF::class)){
  26. $this::markTestSkipped('FPDF not available');
  27. }
  28. parent::setUp();
  29. }
  30. protected function getOutputInterface(
  31. SettingsContainerInterface|QROptions $options,
  32. QRMatrix $matrix,
  33. ):QROutputInterface{
  34. return new QRFpdf($options, $matrix);
  35. }
  36. public function testSetModuleValues():void{
  37. $this->options->moduleValues = [
  38. // data
  39. QRMatrix::M_DATA_DARK => [0, 0, 0],
  40. QRMatrix::M_DATA => [255, 255, 255],
  41. ];
  42. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  43. $this->outputInterface->dump();
  44. /** @phpstan-ignore-next-line */
  45. $this::assertTrue(true); // tricking the code coverage
  46. }
  47. public function testOutputGetResource():void{
  48. $this->options->returnResource = true;
  49. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  50. $this::assertInstanceOf(FPDF::class, $this->outputInterface->dump());
  51. }
  52. }