. */ namespace App\Tests\Services\LabelSystem\Barcodes; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\Storelocation; use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; class BarcodeContentGeneratorTest extends KernelTestCase { /** @var BarcodeContentGenerator */ private $service; public function setUp(): void { self::bootKernel(); $this->service = self::$container->get(BarcodeContentGenerator::class); } public function Barcode1DDataProvider(): array { return [ ['P0000', Part::class], ['L0000', PartLot::class], ['S0000', Storelocation::class], ]; } public function Barcode2DDataProvider(): array { return [ ['/scan/part/0', Part::class], ['/scan/lot/0', PartLot::class], ['/scan/location/0', Storelocation::class] ]; } /** * @dataProvider Barcode1DDataProvider */ public function testGet1DBarcodeContent(string $expected, string $class): void { $this->assertSame($expected, $this->service->get1DBarcodeContent(new $class())); } /** * @dataProvider Barcode2DDataProvider */ public function testGetURLContent(string $expected, string $class): void { $url = $this->service->getURLContent(new $class()); //URL must be absolute... $this->assertStringStartsWith('http', $url); $this->assertStringEndsWith($expected, $url); } }