QRStringTextTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. final class QRStringTextTest extends QROutputTestAbstract{
  16. protected function getOutputInterface(
  17. SettingsContainerInterface|QROptions $options,
  18. QRMatrix $matrix,
  19. ):QROutputInterface{
  20. return new QRStringText($options, $matrix);
  21. }
  22. /**
  23. * @phpstan-return array<string, array{0: mixed, 1: bool}>
  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. 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. }