| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * Class QRImageTest
- *
- * @created 24.12.2017
- * @author Smiley <smiley@chillerlan.net>
- * @copyright 2017 Smiley
- * @license MIT
- */
- namespace chillerlan\QRCodeTest\Output;
- use chillerlan\QRCode\Data\QRMatrix;
- use chillerlan\QRCode\{QRCode, QROptions};
- use chillerlan\QRCode\Output\{QROutputInterface, QRImage};
- use const PHP_MAJOR_VERSION;
- /**
- * Tests the QRImage output module
- */
- final class QRImageTest extends QROutputTestAbstract{
- /**
- * @inheritDoc
- */
- protected function setUp():void{
- if(!extension_loaded('gd')){
- $this->markTestSkipped('ext-gd not loaded');
- }
- parent::setUp();
- }
- /**
- * @inheritDoc
- */
- protected function getOutputInterface(QROptions $options):QROutputInterface{
- return new QRImage($options, $this->matrix);
- }
- /**
- * @inheritDoc
- */
- public function types():array{
- return [
- 'png' => [QRCode::OUTPUT_IMAGE_PNG],
- 'gif' => [QRCode::OUTPUT_IMAGE_GIF],
- 'jpg' => [QRCode::OUTPUT_IMAGE_JPG],
- ];
- }
- /**
- * @inheritDoc
- */
- public function testSetModuleValues():void{
- $this->options->moduleValues = [
- // data
- QRMatrix::M_DATA | QRMatrix::IS_DARK => [0, 0, 0],
- QRMatrix::M_DATA => [255, 255, 255],
- ];
- $this->outputInterface = $this->getOutputInterface($this->options);
- $this->outputInterface->dump();
- $this::assertTrue(true); // tricking the code coverage
- }
- /**
- *
- */
- public function testOutputGetResource():void{
- $this->options->returnResource = true;
- $this->outputInterface = $this->getOutputInterface($this->options);
- $actual = $this->outputInterface->dump();
- /** @noinspection PhpFullyQualifiedNameUsageInspection */
- PHP_MAJOR_VERSION >= 8
- ? $this::assertInstanceOf(\GdImage::class, $actual)
- : $this::assertIsResource($actual);
- }
- }
|