QRStringJSONTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. 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, QRStringJSON};
  15. use chillerlan\QRCodeTest\Traits\CssColorModuleValueProviderTrait;
  16. use chillerlan\Settings\SettingsContainerInterface;
  17. use PHPUnit\Framework\Attributes\Test;
  18. /**
  19. * Tests the QRStringJSON output class
  20. */
  21. final class QRStringJSONTest extends QROutputTestAbstract{
  22. use CssColorModuleValueProviderTrait;
  23. protected function getOutputInterface(
  24. SettingsContainerInterface|QROptions $options,
  25. QRMatrix $matrix,
  26. ):QROutputInterface{
  27. return new QRStringJSON($options, $matrix);
  28. }
  29. #[Test]
  30. public function setModuleValues():void{
  31. $this->options->moduleValues = [
  32. // data
  33. QRMatrix::M_DATA_DARK => '#AAA',
  34. QRMatrix::M_DATA => '#BBB',
  35. ];
  36. $this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
  37. $data = $this->outputInterface->dump();
  38. $this::assertStringContainsString('"layer":"data-dark","value":"#AAA"', $data);
  39. $this::assertStringContainsString('"layer":"data","value":"#BBB"', $data);
  40. }
  41. }