QRFpdfTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 FPDF;
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\QRFpdf;
  14. use function class_exists;
  15. /**
  16. * Tests the QRFpdf output module
  17. */
  18. final class QRFpdfTest extends QROutputTestAbstract{
  19. protected string $FQN = QRFpdf::class;
  20. /**
  21. * @inheritDoc
  22. */
  23. protected function setUp():void{
  24. if(!class_exists(FPDF::class)){
  25. $this::markTestSkipped('FPDF not available');
  26. }
  27. parent::setUp();
  28. }
  29. public static function moduleValueProvider():array{
  30. return [
  31. 'valid: int' => [[123, 123, 123], true],
  32. 'valid: w/invalid extra element' => [[123, 123, 123, 'abc'], true],
  33. 'valid: numeric string' => [['123', '123', '123'], true],
  34. 'invalid: wrong type' => ['foo', false],
  35. 'invalid: array too short' => [[1, 2], false],
  36. 'invalid: contains non-number' => [[1, 'b', 3], false],
  37. ];
  38. }
  39. /**
  40. * @inheritDoc
  41. */
  42. public function testSetModuleValues():void{
  43. $this->options->moduleValues = [
  44. // data
  45. QRMatrix::M_DATA_DARK => [0, 0, 0],
  46. QRMatrix::M_DATA => [255, 255, 255],
  47. ];
  48. $this->outputInterface = new $this->FQN($this->options, $this->matrix);
  49. $this->outputInterface->dump();
  50. $this::assertTrue(true); // tricking the code coverage
  51. }
  52. public function testOutputGetResource():void{
  53. $this->options->returnResource = true;
  54. $this->outputInterface = new $this->FQN($this->options, $this->matrix);
  55. $this::assertInstanceOf(FPDF::class, $this->outputInterface->dump());
  56. }
  57. }