-
-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathBuilderTest.php
57 lines (49 loc) · 1.68 KB
/
BuilderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Tests;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\Label\Font\OpenSans;
use Endroid\QrCode\Label\LabelAlignment;
use Endroid\QrCode\RoundBlockSizeMode;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Writer\Result\PngResult;
use Endroid\QrCode\Writer\SvgWriter;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
final class BuilderTest extends TestCase
{
#[TestDox('Write advanced example via builder')]
public function testBuilder(): void
{
$builder = new Builder(
writer: new PngWriter(),
writerOptions: [],
data: 'Custom QR code contents',
encoding: new Encoding('UTF-8'),
errorCorrectionLevel: ErrorCorrectionLevel::High,
size: 300,
margin: 10,
roundBlockSizeMode: RoundBlockSizeMode::Margin,
labelText: 'This is the label',
labelFont: new OpenSans(20),
labelAlignment: LabelAlignment::Center
);
$result = $builder->build();
$this->assertInstanceOf(PngResult::class, $result);
$this->assertEquals('image/png', $result->getMimeType());
}
#[TestDox('Builder defaults can be overridden')]
public function testBuilderOverrideOptions(): void
{
$builder = new Builder(
writer: new SvgWriter()
);
$result = $builder->build(
writer: new PngWriter()
);
$this->assertInstanceOf(PngResult::class, $result);
$this->assertEquals('image/png', $result->getMimeType());
}
}