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