. */ namespace App\Tests\Services\LabelSystem; use App\Entity\LabelSystem\LabelOptions; use App\Entity\Parts\Part; use App\Services\LabelSystem\BarcodeGenerator; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; final class BarcodeGeneratorTest extends WebTestCase { /** @var BarcodeGenerator */ protected $services; public function setUp(): void { self::bootKernel(); $this->services = self::$container->get(BarcodeGenerator::class); } public function testGetContent(): void { $part = new Part(); $part->setName('Test'); //Test that all barcodes types are supported foreach (LabelOptions::BARCODE_TYPES as $type) { $options = new LabelOptions(); $options->setBarcodeType($type); $content = $this->services->generateSVG($options, $part); //When type is none, service must return null. if ($type === 'none') { $this->assertNull($content); } else { $this->assertIsString($content); } } } public function testGenerateSVG(): void { $part = new Part(); $part->setName('Test'); //Test that all barcodes types are supported foreach (LabelOptions::BARCODE_TYPES as $type) { $options = new LabelOptions(); $options->setBarcodeType($type); $svg = $this->services->generateSVG($options, $part); //When type is none, service must return null. if ($type === "none") { $this->assertNull($svg); } else { $this->assertStringContainsStringIgnoringCase("SVG", $svg); } } } }