Skip to content

Commit

Permalink
Update QrCodeServiceTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Mar 1, 2024
1 parent a4a2c4d commit fe3b29e
Showing 1 changed file with 85 additions and 5 deletions.
90 changes: 85 additions & 5 deletions tests/Unit/Services/QrCodeServiceTest.php
Expand Up @@ -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()
Expand Down

0 comments on commit fe3b29e

Please sign in to comment.