mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 19:34:31 +02:00
Use enums for LabelOptions
This commit is contained in:
parent
485b35fbd4
commit
71cd4057a7
23 changed files with 329 additions and 157 deletions
|
@ -41,6 +41,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Tests\Services\LabelSystem;
|
||||
|
||||
use App\Entity\LabelSystem\BarcodeType;
|
||||
use App\Entity\LabelSystem\LabelOptions;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Services\LabelSystem\BarcodeGenerator;
|
||||
|
@ -65,13 +66,13 @@ final class BarcodeGeneratorTest extends WebTestCase
|
|||
$part->setName('Test');
|
||||
|
||||
//Test that all barcodes types are supported
|
||||
foreach (LabelOptions::BARCODE_TYPES as $type) {
|
||||
foreach (BarcodeType::cases() as $type) {
|
||||
$options = new LabelOptions();
|
||||
$options->setBarcodeType($type);
|
||||
$content = $this->services->generateSVG($options, $part);
|
||||
|
||||
//When type is none, service must return null.
|
||||
if ('none' === $type) {
|
||||
if (BarcodeType::NONE === $type) {
|
||||
$this->assertNull($content);
|
||||
} else {
|
||||
$this->assertIsString($content);
|
||||
|
@ -85,13 +86,13 @@ final class BarcodeGeneratorTest extends WebTestCase
|
|||
$part->setName('Test');
|
||||
|
||||
//Test that all barcodes types are supported
|
||||
foreach (LabelOptions::BARCODE_TYPES as $type) {
|
||||
foreach (BarcodeType::cases() as $type) {
|
||||
$options = new LabelOptions();
|
||||
$options->setBarcodeType($type);
|
||||
$svg = $this->services->generateSVG($options, $part);
|
||||
|
||||
//When type is none, service must return null.
|
||||
if ('none' === $type) {
|
||||
if (BarcodeType::NONE === $type) {
|
||||
$this->assertNull($svg);
|
||||
} else {
|
||||
$this->assertStringContainsStringIgnoringCase('SVG', $svg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue