2021-02-26 16:16:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Class QRImageTest
|
|
|
|
*
|
|
|
|
* @filesource QRImageTest.php
|
|
|
|
* @created 24.12.2017
|
|
|
|
* @package chillerlan\QRCodeTest\Output
|
|
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
|
|
* @copyright 2017 Smiley
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chillerlan\QRCodeTest\Output;
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
use chillerlan\QRCode\{QRCode, QROptions};
|
|
|
|
use chillerlan\QRCode\Output\{QROutputInterface, QRImage};
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* Tests the QRImage output module
|
|
|
|
*/
|
2021-02-26 16:16:17 +00:00
|
|
|
class QRImageTest extends QROutputTestAbstract{
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
public function setUp():void{
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
if(!extension_loaded('gd')){
|
|
|
|
$this->markTestSkipped('ext-gd not loaded');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
protected function getOutputInterface(QROptions $options):QROutputInterface{
|
|
|
|
return new QRImage($options, $this->matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
public function types():array{
|
2021-02-26 16:16:17 +00:00
|
|
|
return [
|
|
|
|
'png' => [QRCode::OUTPUT_IMAGE_PNG],
|
|
|
|
'gif' => [QRCode::OUTPUT_IMAGE_GIF],
|
|
|
|
'jpg' => [QRCode::OUTPUT_IMAGE_JPG],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-07-02 14:01:51 +00:00
|
|
|
* @inheritDoc
|
2021-02-26 16:16:17 +00:00
|
|
|
*/
|
2022-07-02 14:01:51 +00:00
|
|
|
public function testSetModuleValues():void{
|
2021-02-26 16:16:17 +00:00
|
|
|
|
|
|
|
$this->options->moduleValues = [
|
|
|
|
// data
|
|
|
|
1024 => [0, 0, 0],
|
|
|
|
4 => [255, 255, 255],
|
|
|
|
];
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
$this->outputInterface = $this->getOutputInterface($this->options);
|
|
|
|
$this->outputInterface->dump();
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
$this::assertTrue(true); // tricking the code coverage
|
2021-02-26 16:16:17 +00:00
|
|
|
}
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* @phan-suppress PhanUndeclaredClassReference
|
|
|
|
*/
|
2021-02-26 16:16:17 +00:00
|
|
|
public function testOutputGetResource():void{
|
|
|
|
$this->options->returnResource = true;
|
2022-07-02 14:01:51 +00:00
|
|
|
$this->outputInterface = $this->getOutputInterface($this->options);
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
$actual = $this->outputInterface->dump();
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/** @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection */
|
|
|
|
\PHP_MAJOR_VERSION >= 8
|
|
|
|
? $this::assertInstanceOf(\GdImage::class, $actual)
|
|
|
|
: $this::assertIsResource($actual);
|
2021-02-26 16:16:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|