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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?php /** * BaconQrCode * * @link http://github.com/Bacon/BaconQrCode For the canonical source repository * @copyright 2013 Ben 'DASPRiD' Scholzen * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License */
namespace BaconQrCode\Encoder;
use BaconQrCode\Common\ErrorCorrectionLevel; use BaconQrCode\Renderer\Text\Html; use BaconQrCode\Writer; use PHPUnit_Framework_TestCase as TestCase;
class HtmlTest extends TestCase { /** * @var Html */ protected $renderer;
/** * @var Writer */ protected $writer;
public function setUp() { $this->renderer = new Html(); $this->writer = new Writer($this->renderer); }
public function testBasicRender() { $content = 'foobar'; $expected = '<pre style="font-family: monospace; line-height: 0.65em; letter-spacing: -1px" class="">' . " \n" . " ███████ █████ ███████ \n" . " █ █ █ █ █ █ \n" . " █ ███ █ ██ █ ███ █ \n" . " █ ███ █ ███ █ ███ █ \n" . " █ ███ █ █ █ █ ███ █ \n" . " █ █ ██ █ █ \n" . " ███████ █ █ █ ███████ \n" . " █████ \n" . " ██ ██ █ ██ █ █ █ \n" . " ██ ██ █ █ ██ \n" . " ████████ █ ██ █ ██ \n" . " ██ █ █ \n" . " ██ ███ █ █ █ █ \n" . " █ ███ █ █ \n" . " ███████ ██ ██████ \n" . " █ █ ████ ██ \n" . " █ ███ █ ██ ██ ██ █ ██ \n" . " █ ███ █ ██ ██ █ ██ \n" . " █ ███ █ █ █ ██ ██ \n" . " █ █ ███ ███ ████ \n" . " ███████ ████ ██ \n" . " \n" . '</pre>' ;
$qrCode = Encoder::encode( $content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING ); $this->assertEquals($expected, $this->renderer->render($qrCode)); }
public function testSetStyle() { $content = 'foobar'; $qrCode = Encoder::encode( $content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING ); $this->renderer->setStyle('bar'); $this->assertEquals('bar', $this->renderer->getStyle()); $this->assertStringMatchesFormat('%astyle="bar"%a', $this->renderer->render($qrCode)); }
public function testSetClass() { $content = 'foobar'; $qrCode = Encoder::encode( $content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING ); $this->renderer->setClass('bar'); $this->assertEquals('bar', $this->renderer->getClass()); $this->assertStringMatchesFormat('%aclass="bar"%a', $this->renderer->render($qrCode)); } }
|