QRFpdfTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. namespace chillerlan\QRCodeTest\Output;
  11. use chillerlan\QRCode\QROptions;
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface};
  14. use chillerlan\Settings\SettingsContainerInterface;
  15. use FPDF;
  16. use function class_exists;
  17. /**
  18. * Tests the QRFpdf output module
  19. */
  20. final class QRFpdfTest extends QROutputTestAbstract{
  21. use RGBArrayModuleValueProviderTrait;
  22. /**
  23. * @inheritDoc
  24. */
  25. protected function setUp():void{
  26. if(!class_exists(FPDF::class)){
  27. $this::markTestSkipped('FPDF not available');
  28. }
  29. parent::setUp();
  30. }
  31. protected function getOutputInterface(
  32. SettingsContainerInterface|QROptions $options,
  33. QRMatrix $matrix
  34. ):QROutputInterface{
  35. return new QRFpdf($options, $matrix);
  36. }
  37. /**
  38. * @inheritDoc
  39. */
  40. public function testSetModuleValues():void{
  41. $this->options->moduleValues = [
  42. // data
  43. QRMatrix::M_DATA_DARK => [0, 0, 0],
  44. QRMatrix::M_DATA => [255, 255, 255],
  45. ];
  46. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  47. $this->outputInterface->dump();
  48. /** @phpstan-ignore-next-line */
  49. $this::assertTrue(true); // tricking the code coverage
  50. }
  51. public function testOutputGetResource():void{
  52. $this->options->returnResource = true;
  53. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  54. $this::assertInstanceOf(FPDF::class, $this->outputInterface->dump());
  55. }
  56. }