This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
/
Code25interleavedTest.php
230 lines (203 loc) · 8.22 KB
/
Code25interleavedTest.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ZendTest\Barcode\Object;
use Zend\Barcode;
/**
* @group Zend_Barcode
*/
class Code25interleavedTest extends TestCommon
{
protected function getBarcodeObject($options = null)
{
return new Barcode\Object\Code25interleaved($options);
}
public function testType()
{
$this->assertSame('code25interleaved', $this->object->getType());
}
public function testWithBearerBars()
{
$this->object->setWithBearerBars(1);
$this->assertSame(true, $this->object->getWithBearerBars());
$this->object->setWithBearerBars(true);
$this->assertSame(true, $this->object->getWithBearerBars());
}
public function testChecksum()
{
$this->assertSame(5, $this->object->getChecksum('0123456789'));
}
public function testSetText()
{
$this->object->setText('0123456789');
$this->assertSame('0123456789', $this->object->getRawText());
$this->assertSame('0123456789', $this->object->getText());
$this->assertSame('0123456789', $this->object->getTextToDisplay());
}
public function testSetTextWithSpaces()
{
$this->object->setText(' 0123456789 ');
$this->assertSame('0123456789', $this->object->getRawText());
$this->assertSame('0123456789', $this->object->getText());
$this->assertSame('0123456789', $this->object->getTextToDisplay());
}
public function testSetTextWithoutEvenNumberOfCharacters()
{
$this->object->setText('123456789');
$this->assertSame('123456789', $this->object->getRawText());
$this->assertSame('0123456789', $this->object->getText());
$this->assertSame('0123456789', $this->object->getTextToDisplay());
}
public function testSetTextWithChecksum()
{
$this->object->setText('123456789');
$this->object->setWithChecksum(true);
$this->assertSame('123456789', $this->object->getRawText());
$this->assertSame('1234567895', $this->object->getText());
$this->assertSame('123456789', $this->object->getTextToDisplay());
}
public function testSetTextWithoutEvenNumberOfCharactersWithChecksum()
{
$this->object->setText('123456789');
$this->object->setWithChecksum(true);
$this->assertSame('123456789', $this->object->getRawText());
$this->assertSame('1234567895', $this->object->getText());
$this->assertSame('123456789', $this->object->getTextToDisplay());
}
public function testSetTextWithChecksumDisplayed()
{
$this->object->setText('123456789');
$this->object->setWithChecksum(true);
$this->object->setWithChecksumInText(true);
$this->assertSame('123456789', $this->object->getRawText());
$this->assertSame('1234567895', $this->object->getText());
$this->assertSame('1234567895', $this->object->getTextToDisplay());
}
public function testSetTextWithoutEvenNumberOfCharactersWithChecksumDisplayed()
{
$this->object->setText('0123456789');
$this->object->setWithChecksum(true);
$this->object->setWithChecksumInText(true);
$this->assertSame('0123456789', $this->object->getRawText());
$this->assertSame('001234567895', $this->object->getText());
$this->assertSame('001234567895', $this->object->getTextToDisplay());
}
public function testBadTextAlwaysAllowed()
{
$this->object->setText('a');
$this->assertSame('0a', $this->object->getText());
}
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception\ExceptionInterface');
$this->object->setText('a');
$this->object->setWithChecksum(true);
$this->object->getText();
}
public function testCheckGoodParams()
{
$this->object->setText('0123456789');
$this->assertTrue($this->object->checkParams());
}
public function testCheckParamsWithLowRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception\ExceptionInterface');
$this->object->setText('0123456789');
$this->object->setBarThinWidth(21);
$this->object->setBarThickWidth(40);
$this->object->checkParams();
}
public function testCheckParamsWithHighRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception\ExceptionInterface');
$this->object->setText('0123456789');
$this->object->setBarThinWidth(20);
$this->object->setBarThickWidth(61);
$this->object->checkParams();
}
public function testGetKnownWidthWithoutOrientation()
{
$this->object->setText('0123456789');
$this->assertEquals(119, $this->object->getWidth());
$this->object->setWithQuietZones(false);
$this->assertEquals(99, $this->object->getWidth(true));
}
public function testCompleteGeneration()
{
$this->object->setText('0123456789');
$this->object->draw();
$instructions = $this->loadInstructionsFile('Int25_0123456789_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithStretchText()
{
$this->object->setText('0123456789');
$this->object->setStretchText(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_stretchtext_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithBorder()
{
$this->object->setText('0123456789');
$this->object->setWithBorder(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_border_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithBearerBars()
{
$this->object->setText('0123456789');
$this->object->setWithBearerBars(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_bearerbar_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithOrientation()
{
$this->object->setText('0123456789');
$this->object->setOrientation(60);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_oriented_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithStretchTextWithOrientation()
{
$this->object->setText('0123456789');
$this->object->setOrientation(60);
$this->object->setStretchText(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_stretchtext_oriented_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithBorderWithOrientation()
{
$this->object->setText('0123456789');
$this->object->setOrientation(60);
$this->object->setWithBorder(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_border_oriented_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
public function testCompleteGenerationWithBearerBarsWithOrientation()
{
$this->object->setText('0123456789');
$this->object->setOrientation(60);
$this->object->setWithBearerBars(true);
$this->object->draw();
$instructions = $this->loadInstructionsFile(
'Int25_0123456789_bearerbar_oriented_instructions');
$this->assertEquals($instructions, $this->object->getInstructions());
}
}