QRFpdfTest.php 1.6 KB

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