QRStringJSONTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Class QRStringJSONTest
  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, QRStringJSON};
  14. use chillerlan\Settings\SettingsContainerInterface;
  15. final class QRStringJSONTest extends QROutputTestAbstract{
  16. use CssColorModuleValueProviderTrait;
  17. protected function getOutputInterface(
  18. SettingsContainerInterface|QROptions $options,
  19. QRMatrix $matrix,
  20. ):QROutputInterface{
  21. return new QRStringJSON($options, $matrix);
  22. }
  23. public function testSetModuleValues():void{
  24. $this->options->moduleValues = [
  25. // data
  26. QRMatrix::M_DATA_DARK => '#AAA',
  27. QRMatrix::M_DATA => '#BBB',
  28. ];
  29. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  30. $data = $this->outputInterface->dump();
  31. $this::assertStringContainsString('"layer":"data-dark","value":"#AAA"', $data);
  32. $this::assertStringContainsString('"layer":"data","value":"#BBB"', $data);
  33. }
  34. }