blob: 24fdc3ce6b7b202214c74a8fb61efa694ab955db (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
/**
* Class QRMarkupTest
*
* @filesource QRMarkupTest.php
* @created 24.12.2017
* @package chillerlan\QRCodeTest\Output
* @author Smiley <[email protected]>
* @copyright 2017 Smiley
* @license MIT
*/
namespace chillerlan\QRCodeTest\Output;
use chillerlan\QRCode\{QRCode, Output\QRMarkup};
class QRMarkupTest extends QROutputTestAbstract{
protected $FQCN = QRMarkup::class;
public function types(){
return [
'html' => [QRCode::OUTPUT_MARKUP_HTML],
'svg' => [QRCode::OUTPUT_MARKUP_SVG],
];
}
/**
* @dataProvider types
* @param $type
*/
public function testMarkupOutputFile($type){
$this->options->outputType = $type;
$this->options->cachefile = $this::cachefile.$type;
$this->setOutputInterface();
$data = $this->outputInterface->dump();
$this->assertSame($data, file_get_contents($this->options->cachefile));
}
/**
* @dataProvider types
* @param $type
*/
public function testMarkupOutput($type){
$this->options->imageBase64 = false;
$this->options->outputType = $type;
$this->setOutputInterface();
$expected = explode($this->options->eol, file_get_contents($this::cachefile.$type));
// cut off the doctype & head
array_shift($expected);
if($type === QRCode::OUTPUT_MARKUP_HTML){
// cut off the </body> tag
array_pop($expected);
}
$expected = implode($this->options->eol, $expected);
$this->assertSame(trim($expected), trim($this->outputInterface->dump()));
}
public function testSetModuleValues(){
$this->options->imageBase64 = false;
$this->options->moduleValues = [
// data
1024 => '#4A6000',
4 => '#ECF9BE',
];
$this->setOutputInterface();
$data = $this->outputInterface->dump();
$this->assertStringContainsString('#4A6000', $data);
$this->assertStringContainsString('#ECF9BE', $data);
}
}
|