forked from endroid/qr-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidatorTest.php
41 lines (35 loc) · 1.44 KB
/
ValidatorTest.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
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Tests;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Writer\Result\PngResult;
use PHPUnit\Framework\TestCase;
final class ValidatorTest extends TestCase
{
/**
* @testdox Can write $name and successfully validate result
*
* @dataProvider dataProvider
*/
public function testReadability(string $name, string $data): void
{
$result = Builder::create()
->data($data)
->validateResult(true)
->build()
;
$this->assertInstanceOf(PngResult::class, $result);
$this->assertEquals('image/png', $result->getMimeType());
}
public function dataProvider(): iterable
{
yield ['small data', 'Tiny'];
yield ['data containing spaces', 'This one has spaces'];
yield ['a large random character string', 'd2llMS9uU01BVmlvalM2YU9BUFBPTTdQMmJabHpqdndt'];
yield ['a URL containing query parameters', 'https://this.is.an/url?with=query&string=attached'];
yield ['a long number', '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'];
yield ['serialized data', '{"i":"serialized.data","v":1,"t":1,"d":"4AEPc9XuIQ0OjsZoSRWp9DRWlN6UyDvuMlyOYy8XjOw="}'];
yield ['special characters', 'Spëci&al ch@ract3rs'];
yield ['chinese characters', '有限公司'];
}
}