phpOMS/tests/Utils/Barcode/DatamatrixTest.php
2023-05-19 02:37:35 +00:00

67 lines
1.4 KiB
PHP
Executable File

<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\tests\Utils\Barcode;
use phpOMS\Utils\Barcode\Datamatrix;
/**
* @internal
*/
final class DatamatrixTest extends \PHPUnit\Framework\TestCase
{
protected function setUp() : void
{
if (!\extension_loaded('gd')) {
$this->markTestSkipped(
'The GD extension is not available.'
);
}
}
/**
* @covers phpOMS\Utils\Barcode\Datamatrix<extended>
* @group framework
*/
public function testImagePng() : void
{
$path = __DIR__ . '/datamatrix.png';
if (\is_file($path)) {
\unlink($path);
}
$img = new Datamatrix('https://jingga.app', 200, 50);
$img->saveToPngFile($path);
self::assertFileExists($path);
}
/**
* @covers phpOMS\Utils\Barcode\Datamatrix<extended>
* @group framework
*/
public function testImageJpg() : void
{
$path = __DIR__ . '/datamatrix.jpg';
if (\is_file($path)) {
\unlink($path);
}
$img = new Datamatrix('https://jingga.app', 200, 50);
$img->saveToJpgFile($path);
self::assertFileExists($path);
}
}