diff --git a/tests/Unit/Services/QrCodeServiceTest.php b/tests/Unit/Services/QrCodeServiceTest.php index a725ad08c..b4f6bb87c 100644 --- a/tests/Unit/Services/QrCodeServiceTest.php +++ b/tests/Unit/Services/QrCodeServiceTest.php @@ -54,15 +54,95 @@ public function sizeMax(): void } /** - * resolveRoundBlockSize() should return \Endroid\QrCode\RoundBlockSizeMode::None - * if config('urlhub.qrcode_round_block_size') set `false`. - * * @test + * @group u-actions */ - public function resolveRoundBlockSizeShouldReturnRoundBlockSizeModeNone(): void + public function resolveSize(): void { - config(['urlhub.qrcode_round_block_size' => false]); + $size = $this->getQrCode()->resolveSize(); + $this->assertGreaterThanOrEqual(QrCodeService::MIN_SIZE, $size); + $this->assertLessThanOrEqual(QrCodeService::MAX_SIZE, $size); + } + + /** + * @test + * @group u-actions + */ + public function resolveMargin(): void + { + config(['urlhub.qrcode_margin' => -1]); + $this->assertSame(0, $this->getQrCode()->resolveMargin()); + + config(['urlhub.qrcode_margin' => 0]); + $this->assertSame(0, $this->getQrCode()->resolveMargin()); + + config(['urlhub.qrcode_margin' => 1]); + $this->assertSame(1, $this->getQrCode()->resolveMargin()); + } + + /** + * @test + * @group u-actions + */ + public function resolveWriter(): void + { + config(['urlhub.qrcode_format' => 'svg']); + $this->assertInstanceOf( + \Endroid\QrCode\Writer\SvgWriter::class, + $this->getQrCode()->resolveWriter() + ); + + config(['urlhub.qrcode_format' => 'png']); + $this->assertInstanceOf( + \Endroid\QrCode\Writer\PngWriter::class, + $this->getQrCode()->resolveWriter() + ); + } + + /** + * @test + * @group u-actions + */ + public function resolveErrorCorrection(): void + { + config(['urlhub.qrcode_error_correction' => 'l']); + $this->assertSame( + \Endroid\QrCode\ErrorCorrectionLevel::Low, + $this->getQrCode()->resolveErrorCorrection() + ); + config(['urlhub.qrcode_error_correction' => 'm']); + $this->assertSame( + \Endroid\QrCode\ErrorCorrectionLevel::Medium, + $this->getQrCode()->resolveErrorCorrection() + ); + + config(['urlhub.qrcode_error_correction' => 'q']); + $this->assertSame( + \Endroid\QrCode\ErrorCorrectionLevel::Quartile, + $this->getQrCode()->resolveErrorCorrection() + ); + + config(['urlhub.qrcode_error_correction' => 'h']); + $this->assertSame( + \Endroid\QrCode\ErrorCorrectionLevel::High, + $this->getQrCode()->resolveErrorCorrection() + ); + } + + /** + * @test + * @group u-actions + */ + public function resolveRoundBlockSize(): void + { + config(['urlhub.qrcode_round_block_size' => true]); + $this->assertSame( + \Endroid\QrCode\RoundBlockSizeMode::Margin, + $this->getQrCode()->resolveRoundBlockSize() + ); + + config(['urlhub.qrcode_round_block_size' => false]); $this->assertSame( \Endroid\QrCode\RoundBlockSizeMode::None, $this->getQrCode()->resolveRoundBlockSize()