Skip to content

Commit

Permalink
recreate test images
Browse files Browse the repository at this point in the history
  • Loading branch information
2amjsouza committed Dec 8, 2023
1 parent 1cf57a5 commit 3b47b13
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 58 deletions.
58 changes: 0 additions & 58 deletions tests/unit/ColorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use BaconQrCode\Renderer\Color\Rgb;
use Da\QrCode\Contracts\ColorsInterface;
use Da\QrCode\Enums\Gradient;
use Da\QrCode\Factory\LaravelQrCodeFactory;
use Da\QrCode\QrCode;
use Da\QrCode\StyleManager;
use Da\QrCode\Writer\EpsWriter;
Expand Down Expand Up @@ -116,63 +115,6 @@ public function testGradientColors()
);
}

public function testFactoryCreateGradientQrCode()
{
$foreground = [
'r' => 255,
'g' => 0,
'b' => 0,
];
$foreground2 = [
'r' => 0,
'g' => 0,
'b' => 255,
'a' => 30,
];

$qrCode = LaravelQrCodeFactory::make(
'2am. Technologies',
null,
$foreground,
null,
null,
null,
$foreground2
)
->writeString();

$uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient.png'));

$this->assertEquals(
$this->normalizeString($qrCode),
$this->normalizeString($uri)
);

$qrCodeRadial = LaravelQrCodeFactory::make(
'2am. Technologies',
null,
$foreground,
null,
null,
null,
$foreground2,
null,
null,
null,
null,
null,
Gradient::GRADIENT_RADIAL
)
->writeString();

$uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient-radial.png'));

$this->assertEquals(
$this->normalizeString($qrCodeRadial),
$this->normalizeString($uri)
);
}

public function testInvalidForegroundColorShouldThrowException()
{
$this->expectException(\Exception::class);
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/LaravelQrCodeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,62 @@ public function testInvalidQrCodeFormatInvalidClass()
LaravelQrCodeFactory::make('2am. Technologies', PngWriter::class);
}

public function testCreateGradientQrCode()
{
$foreground = [
'r' => 255,
'g' => 0,
'b' => 0,
];
$foreground2 = [
'r' => 0,
'g' => 0,
'b' => 255,
'a' => 30,
];

$qrCode = LaravelQrCodeFactory::make(
'2am. Technologies',
null,
$foreground,
null,
null,
null,
$foreground2
)
->writeString();
file_put_contents(codecept_data_dir('blade/qrcode-gradient.png'), $qrCode);
$uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient.png'));

$this->assertEquals(
$this->normalizeString($qrCode),
$this->normalizeString($uri)
);

$qrCodeRadial = LaravelQrCodeFactory::make(
'2am. Technologies',
null,
$foreground,
null,
null,
null,
$foreground2,
null,
null,
null,
null,
null,
Gradient::GRADIENT_RADIAL
)
->writeString();
file_put_contents(codecept_data_dir('blade/qrcode-gradient-radial.png'), $qrCodeRadial);
$uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient-radial.png'));

$this->assertEquals(
$this->normalizeString($qrCodeRadial),
$this->normalizeString($uri)
);
}

protected function normalizeString($string)
{
Expand Down

0 comments on commit 3b47b13

Please sign in to comment.