QRStringTEXTTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. use chillerlan\Settings\SettingsContainerInterface;
  15. /**
  16. *
  17. */
  18. final class QRStringTEXTTest extends QROutputTestAbstract{
  19. protected function getOutputInterface(
  20. SettingsContainerInterface|QROptions $options,
  21. QRMatrix $matrix
  22. ):QROutputInterface{
  23. return new QRStringText($options, $matrix);
  24. }
  25. public static function moduleValueProvider():array{
  26. return [
  27. 'invalid: wrong type' => [[], false],
  28. 'valid: string' => ['abc', true],
  29. 'valid: zero length string' => ['', true],
  30. 'valid: empty string' => [' ', true],
  31. ];
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. public function testSetModuleValues():void{
  37. $this->options->moduleValues = [
  38. // data
  39. QRMatrix::M_DATA_DARK => 'A',
  40. QRMatrix::M_DATA => 'B',
  41. ];
  42. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  43. $data = $this->outputInterface->dump();
  44. $this::assertStringContainsString('A', $data);
  45. $this::assertStringContainsString('B', $data);
  46. }
  47. }