QRStringTextTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /**
  26. * @phpstan-return array<string, array{0: mixed, 1: bool}>
  27. */
  28. public static function moduleValueProvider():array{
  29. return [
  30. 'invalid: wrong type' => [[], false],
  31. 'valid: string' => ['abc', true],
  32. 'valid: zero length string' => ['', true],
  33. 'valid: empty string' => [' ', true],
  34. ];
  35. }
  36. /**
  37. * @inheritDoc
  38. */
  39. public function testSetModuleValues():void{
  40. $this->options->moduleValues = [
  41. // data
  42. QRMatrix::M_DATA_DARK => 'A',
  43. QRMatrix::M_DATA => 'B',
  44. ];
  45. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  46. $data = $this->outputInterface->dump();
  47. $this::assertStringContainsString('A', $data);
  48. $this::assertStringContainsString('B', $data);
  49. }
  50. }