QRStringTextTest.php 1.5 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. 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. use PHPUnit\Framework\Attributes\Test;
  17. /**
  18. * Tests the QRStringText output class
  19. */
  20. final class QRStringTextTest extends QROutputTestAbstract{
  21. protected function getOutputInterface(
  22. SettingsContainerInterface|QROptions $options,
  23. QRMatrix $matrix,
  24. ):QROutputInterface{
  25. return new QRStringText($options, $matrix);
  26. }
  27. /**
  28. * @phpstan-return array<string, array{0: mixed, 1: bool}>
  29. */
  30. public static function moduleValueProvider():array{
  31. return [
  32. 'invalid: wrong type' => [[], false],
  33. 'valid: string' => ['abc', true],
  34. 'valid: zero length string' => ['', true],
  35. 'valid: empty string' => [' ', true],
  36. ];
  37. }
  38. #[Test]
  39. public function setModuleValues():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. }