QRStringTEXTTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Class QRStringTEXTTest
  4. *
  5. * @created 11.12.2021
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2021 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\{QROutputInterface, QRStringText};
  14. /**
  15. *
  16. */
  17. final class QRStringTEXTTest extends QROutputTestAbstract{
  18. protected string $type = QROutputInterface::STRING_TEXT;
  19. protected function getOutputInterface(QROptions $options, QRMatrix $matrix):QROutputInterface{
  20. return new QRStringText($options, $matrix);
  21. }
  22. public static function moduleValueProvider():array{
  23. return [
  24. 'invalid: wrong type' => [[], false],
  25. 'valid: string' => ['abc', true],
  26. 'valid: zero length string' => ['', true],
  27. 'valid: empty string' => [' ', true],
  28. ];
  29. }
  30. /**
  31. * @inheritDoc
  32. */
  33. public function testSetModuleValues():void{
  34. $this->options->moduleValues = [
  35. // data
  36. QRMatrix::M_DATA_DARK => 'A',
  37. QRMatrix::M_DATA => 'B',
  38. ];
  39. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  40. $data = $this->outputInterface->dump();
  41. $this::assertStringContainsString('A', $data);
  42. $this::assertStringContainsString('B', $data);
  43. }
  44. }