PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / bacon / bacon-qr-code / test / Encoder / EncoderTest.php
ameliabooking / vendor / bacon / bacon-qr-code / test / Encoder Last commit date
EncoderTest.php 8 months ago MaskUtilTest.php 8 months ago MatrixUtilTest.php 8 months ago
EncoderTest.php
488 lines
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCodeTest\Encoder;
5
6 use BaconQrCode\Common\BitArray;
7 use BaconQrCode\Common\ErrorCorrectionLevel;
8 use BaconQrCode\Common\Mode;
9 use BaconQrCode\Common\Version;
10 use BaconQrCode\Encoder\Encoder;
11 use BaconQrCode\Exception\WriterException;
12 use PHPUnit\Framework\TestCase;
13 use ReflectionClass;
14 use ReflectionMethod;
15 use SplFixedArray;
16
17 final class EncoderTest extends TestCase
18 {
19 /**
20 * @var ReflectionMethod[]
21 */
22 protected $methods = [];
23
24 public function setUp() : void
25 {
26 // Hack to be able to test protected methods
27 $reflection = new ReflectionClass(Encoder::class);
28
29 foreach ($reflection->getMethods(ReflectionMethod::IS_STATIC) as $method) {
30 $method->setAccessible(true);
31 $this->methods[$method->getName()] = $method;
32 }
33 }
34
35 public function testGetAlphanumericCode() : void
36 {
37 // The first ten code points are numbers.
38 for ($i = 0; $i < 10; ++$i) {
39 $this->assertSame($i, $this->methods['getAlphanumericCode']->invoke(null, ord('0') + $i));
40 }
41
42 // The next 26 code points are capital alphabet letters.
43 for ($i = 10; $i < 36; ++$i) {
44 // The first ten code points are numbers
45 $this->assertSame($i, $this->methods['getAlphanumericCode']->invoke(null, ord('A') + $i - 10));
46 }
47
48 // Others are symbol letters.
49 $this->assertSame(36, $this->methods['getAlphanumericCode']->invoke(null, ord(' ')));
50 $this->assertSame(37, $this->methods['getAlphanumericCode']->invoke(null, ord('$')));
51 $this->assertSame(38, $this->methods['getAlphanumericCode']->invoke(null, ord('%')));
52 $this->assertSame(39, $this->methods['getAlphanumericCode']->invoke(null, ord('*')));
53 $this->assertSame(40, $this->methods['getAlphanumericCode']->invoke(null, ord('+')));
54 $this->assertSame(41, $this->methods['getAlphanumericCode']->invoke(null, ord('-')));
55 $this->assertSame(42, $this->methods['getAlphanumericCode']->invoke(null, ord('.')));
56 $this->assertSame(43, $this->methods['getAlphanumericCode']->invoke(null, ord('/')));
57 $this->assertSame(44, $this->methods['getAlphanumericCode']->invoke(null, ord(':')));
58
59 // Should return -1 for other letters.
60 $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord('a')));
61 $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord('#')));
62 $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord("\0")));
63 }
64
65 public function testChooseMode() : void
66 {
67 // Numeric mode
68 $this->assertSame(Mode::NUMERIC(), $this->methods['chooseMode']->invoke(null, '0'));
69 $this->assertSame(Mode::NUMERIC(), $this->methods['chooseMode']->invoke(null, '0123456789'));
70
71 // Alphanumeric mode
72 $this->assertSame(Mode::ALPHANUMERIC(), $this->methods['chooseMode']->invoke(null, 'A'));
73 $this->assertSame(
74 Mode::ALPHANUMERIC(),
75 $this->methods['chooseMode']->invoke(null, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:')
76 );
77
78 // 8-bit byte mode
79 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, 'a'));
80 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, '#'));
81 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, ''));
82
83 // AIUE in Hiragana in SHIFT-JIS
84 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\x8\xa\x8\xa\x8\xa\x8\xa6"));
85
86 // Nihon in Kanji in SHIFT-JIS
87 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\x9\xf\x9\x7b"));
88
89 // Sou-Utso-Byou in Kanji in SHIFT-JIS
90 $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\xe\x4\x9\x5\x9\x61"));
91 }
92
93 public function testEncode() : void
94 {
95 $qrCode = Encoder::encode('ABCDEF', ErrorCorrectionLevel::H());
96 $expected = "<<\n"
97 . " mode: ALPHANUMERIC\n"
98 . " ecLevel: H\n"
99 . " version: 1\n"
100 . " maskPattern: 0\n"
101 . " matrix:\n"
102 . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n"
103 . " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n"
104 . " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n"
105 . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n"
106 . " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n"
107 . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n"
108 . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n"
109 . " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n"
110 . " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n"
111 . " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n"
112 . " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n"
113 . " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n"
114 . " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n"
115 . " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n"
116 . " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n"
117 . " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n"
118 . " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n"
119 . " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n"
120 . " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n"
121 . " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n"
122 . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n"
123 . ">>\n";
124
125 $this->assertSame($expected, (string) $qrCode);
126 }
127
128 public function testSimpleUtf8Eci() : void
129 {
130 $qrCode = Encoder::encode('hello', ErrorCorrectionLevel::H(), 'utf-8');
131 $expected = "<<\n"
132 . " mode: BYTE\n"
133 . " ecLevel: H\n"
134 . " version: 1\n"
135 . " maskPattern: 3\n"
136 . " matrix:\n"
137 . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n"
138 . " 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1\n"
139 . " 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n"
140 . " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1\n"
141 . " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n"
142 . " 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1\n"
143 . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n"
144 . " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0\n"
145 . " 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0\n"
146 . " 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0\n"
147 . " 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 1 1\n"
148 . " 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0\n"
149 . " 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0\n"
150 . " 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 0 1\n"
151 . " 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0\n"
152 . " 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 0 1\n"
153 . " 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0\n"
154 . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 0\n"
155 . " 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0\n"
156 . " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n"
157 . " 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n"
158 . ">>\n";
159
160 $this->assertSame($expected, (string) $qrCode);
161 }
162
163 public function testAppendModeInfo() : void
164 {
165 $bits = new BitArray();
166 $this->methods['appendModeInfo']->invoke(null, Mode::NUMERIC(), $bits);
167 $this->assertSame(' ...X', (string) $bits);
168 }
169
170 public function testAppendLengthInfo() : void
171 {
172 // 1 letter (1/1), 10 bits.
173 $bits = new BitArray();
174 $this->methods['appendLengthInfo']->invoke(
175 null,
176 1,
177 Version::getVersionForNumber(1),
178 Mode::NUMERIC(),
179 $bits
180 );
181 $this->assertSame(' ........ .X', (string) $bits);
182
183 // 2 letters (2/1), 11 bits.
184 $bits = new BitArray();
185 $this->methods['appendLengthInfo']->invoke(
186 null,
187 2,
188 Version::getVersionForNumber(10),
189 Mode::ALPHANUMERIC(),
190 $bits
191 );
192 $this->assertSame(' ........ .X.', (string) $bits);
193
194 // 255 letters (255/1), 16 bits.
195 $bits = new BitArray();
196 $this->methods['appendLengthInfo']->invoke(
197 null,
198 255,
199 Version::getVersionForNumber(27),
200 Mode::BYTE(),
201 $bits
202 );
203 $this->assertSame(' ........ XXXXXXXX', (string) $bits);
204
205 // 512 letters (1024/2), 12 bits.
206 $bits = new BitArray();
207 $this->methods['appendLengthInfo']->invoke(
208 null,
209 512,
210 Version::getVersionForNumber(40),
211 Mode::KANJI(),
212 $bits
213 );
214 $this->assertSame(' ..X..... ....', (string) $bits);
215 }
216
217 public function testAppendBytes() : void
218 {
219 // Should use appendNumericBytes.
220 // 1 = 01 = 0001 in 4 bits.
221 $bits = new BitArray();
222 $this->methods['appendBytes']->invoke(
223 null,
224 '1',
225 Mode::NUMERIC(),
226 $bits,
227 Encoder::DEFAULT_BYTE_MODE_ECODING
228 );
229 $this->assertSame(' ...X', (string) $bits);
230
231 // Should use appendAlphaNumericBytes.
232 // A = 10 = 0xa = 001010 in 6 bits.
233 $bits = new BitArray();
234 $this->methods['appendBytes']->invoke(
235 null,
236 'A',
237 Mode::ALPHANUMERIC(),
238 $bits,
239 Encoder::DEFAULT_BYTE_MODE_ECODING
240 );
241 $this->assertSame(' ..X.X.', (string) $bits);
242
243 // Should use append8BitBytes.
244 // 0x61, 0x62, 0x63
245 $bits = new BitArray();
246 $this->methods['appendBytes']->invoke(
247 null,
248 'abc',
249 Mode::BYTE(),
250 $bits,
251 Encoder::DEFAULT_BYTE_MODE_ECODING
252 );
253 $this->assertSame(' .XX....X .XX...X. .XX...XX', (string) $bits);
254
255 // Should use appendKanjiBytes.
256 // 0x93, 0x5f
257 $bits = new BitArray();
258 $this->methods['appendBytes']->invoke(
259 null,
260 "\x93\x5f",
261 Mode::KANJI(),
262 $bits,
263 Encoder::DEFAULT_BYTE_MODE_ECODING
264 );
265 $this->assertSame(' .XX.XX.. XXXXX', (string) $bits);
266
267 // Lower letters such as 'a' cannot be encoded in alphanumeric mode.
268 $this->expectException(WriterException::class);
269 $this->methods['appendBytes']->invoke(
270 null,
271 'a',
272 Mode::ALPHANUMERIC(),
273 $bits,
274 Encoder::DEFAULT_BYTE_MODE_ECODING
275 );
276 }
277
278 public function testTerminateBits() : void
279 {
280 $bits = new BitArray();
281 $this->methods['terminateBits']->invoke(null, 0, $bits);
282 $this->assertSame('', (string) $bits);
283
284 $bits = new BitArray();
285 $this->methods['terminateBits']->invoke(null, 1, $bits);
286 $this->assertSame(' ........', (string) $bits);
287
288 $bits = new BitArray();
289 $bits->appendBits(0, 3);
290 $this->methods['terminateBits']->invoke(null, 1, $bits);
291 $this->assertSame(' ........', (string) $bits);
292
293 $bits = new BitArray();
294 $bits->appendBits(0, 5);
295 $this->methods['terminateBits']->invoke(null, 1, $bits);
296 $this->assertSame(' ........', (string) $bits);
297
298 $bits = new BitArray();
299 $bits->appendBits(0, 8);
300 $this->methods['terminateBits']->invoke(null, 1, $bits);
301 $this->assertSame(' ........', (string) $bits);
302
303 $bits = new BitArray();
304 $this->methods['terminateBits']->invoke(null, 2, $bits);
305 $this->assertSame(' ........ XXX.XX..', (string) $bits);
306
307 $bits = new BitArray();
308 $bits->appendBits(0, 1);
309 $this->methods['terminateBits']->invoke(null, 3, $bits);
310 $this->assertSame(' ........ XXX.XX.. ...X...X', (string) $bits);
311 }
312
313 public function testGetNumDataBytesAndNumEcBytesForBlockId() : void
314 {
315 // Version 1-H.
316 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
317 ->invoke(null, 26, 9, 1, 0);
318 $this->assertSame(9, $numDataBytes);
319 $this->assertSame(17, $numEcBytes);
320
321 // Version 3-H. 2 blocks.
322 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
323 ->invoke(null, 70, 26, 2, 0);
324 $this->assertSame(13, $numDataBytes);
325 $this->assertSame(22, $numEcBytes);
326 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
327 ->invoke(null, 70, 26, 2, 1);
328 $this->assertSame(13, $numDataBytes);
329 $this->assertSame(22, $numEcBytes);
330
331 // Version 7-H. (4 + 1) blocks.
332 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
333 ->invoke(null, 196, 66, 5, 0);
334 $this->assertSame(13, $numDataBytes);
335 $this->assertSame(26, $numEcBytes);
336 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
337 ->invoke(null, 196, 66, 5, 4);
338 $this->assertSame(14, $numDataBytes);
339 $this->assertSame(26, $numEcBytes);
340
341 // Version 40-H. (20 + 61) blocks.
342 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
343 ->invoke(null, 3706, 1276, 81, 0);
344 $this->assertSame(15, $numDataBytes);
345 $this->assertSame(30, $numEcBytes);
346 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
347 ->invoke(null, 3706, 1276, 81, 20);
348 $this->assertSame(16, $numDataBytes);
349 $this->assertSame(30, $numEcBytes);
350 list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']
351 ->invoke(null, 3706, 1276, 81, 80);
352 $this->assertSame(16, $numDataBytes);
353 $this->assertSame(30, $numEcBytes);
354 }
355
356 public function testInterleaveWithEcBytes() : void
357 {
358 $dataBytes = SplFixedArray::fromArray([32, 65, 205, 69, 41, 220, 46, 128, 236], false);
359 $in = new BitArray();
360
361 foreach ($dataBytes as $dataByte) {
362 $in->appendBits($dataByte, 8);
363 }
364
365 $outBits = $this->methods['interleaveWithEcBytes']->invoke(null, $in, 26, 9, 1);
366 $expected = SplFixedArray::fromArray([
367 // Data bytes.
368 32, 65, 205, 69, 41, 220, 46, 128, 236,
369 // Error correction bytes.
370 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61,
371 ], false);
372
373 $out = $outBits->toBytes(0, count($expected));
374
375 $this->assertEquals($expected, $out);
376 }
377
378 public function testAppendNumericBytes() : void
379 {
380 // 1 = 01 = 0001 in 4 bits.
381 $bits = new BitArray();
382 $this->methods['appendNumericBytes']->invoke(null, '1', $bits);
383 $this->assertSame(' ...X', (string) $bits);
384
385 // 12 = 0xc = 0001100 in 7 bits.
386 $bits = new BitArray();
387 $this->methods['appendNumericBytes']->invoke(null, '12', $bits);
388 $this->assertSame(' ...XX..', (string) $bits);
389
390 // 123 = 0x7b = 0001111011 in 10 bits.
391 $bits = new BitArray();
392 $this->methods['appendNumericBytes']->invoke(null, '123', $bits);
393 $this->assertSame(' ...XXXX. XX', (string) $bits);
394
395 // 1234 = "123" + "4" = 0001111011 + 0100 in 14 bits.
396 $bits = new BitArray();
397 $this->methods['appendNumericBytes']->invoke(null, '1234', $bits);
398 $this->assertSame(' ...XXXX. XX.X..', (string) $bits);
399
400 // Empty
401 $bits = new BitArray();
402 $this->methods['appendNumericBytes']->invoke(null, '', $bits);
403 $this->assertSame('', (string) $bits);
404 }
405
406 public function testAppendAlphanumericBytes() : void
407 {
408 $bits = new BitArray();
409 $this->methods['appendAlphanumericBytes']->invoke(null, 'A', $bits);
410 $this->assertSame(' ..X.X.', (string) $bits);
411
412 $bits = new BitArray();
413 $this->methods['appendAlphanumericBytes']->invoke(null, 'AB', $bits);
414 $this->assertSame(' ..XXX..X X.X', (string) $bits);
415
416 $bits = new BitArray();
417 $this->methods['appendAlphanumericBytes']->invoke(null, 'ABC', $bits);
418 $this->assertSame(' ..XXX..X X.X..XX. .', (string) $bits);
419
420 // Empty
421 $bits = new BitArray();
422 $this->methods['appendAlphanumericBytes']->invoke(null, '', $bits);
423 $this->assertSame('', (string) $bits);
424
425 // Invalid data
426 $this->expectException(WriterException::class);
427 $bits = new BitArray();
428 $this->methods['appendAlphanumericBytes']->invoke(null, 'abc', $bits);
429 }
430
431 public function testAppend8BitBytes() : void
432 {
433 // 0x61, 0x62, 0x63
434 $bits = new BitArray();
435 $this->methods['append8BitBytes']->invoke(null, 'abc', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING);
436 $this->assertSame(' .XX....X .XX...X. .XX...XX', (string) $bits);
437
438 // Empty
439 $bits = new BitArray();
440 $this->methods['append8BitBytes']->invoke(null, '', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING);
441 $this->assertSame('', (string) $bits);
442 }
443
444 public function testAppendKanjiBytes() : void
445 {
446 // Numbers are from page 21 of JISX0510:2004
447 $bits = new BitArray();
448 $this->methods['appendKanjiBytes']->invoke(null, "\x93\x5f", $bits);
449 $this->assertSame(' .XX.XX.. XXXXX', (string) $bits);
450
451 $this->methods['appendKanjiBytes']->invoke(null, "\xe4\xaa", $bits);
452 $this->assertSame(' .XX.XX.. XXXXXXX. X.X.X.X. X.', (string) $bits);
453 }
454
455 public function testGenerateEcBytes() : void
456 {
457 // Numbers are from http://www.swetake.com/qr/qr3.html and
458 // http://www.swetake.com/qr/qr9.html
459 $dataBytes = SplFixedArray::fromArray([32, 65, 205, 69, 41, 220, 46, 128, 236], false);
460 $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17);
461 $expected = SplFixedArray::fromArray(
462 [42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61],
463 false
464 );
465 $this->assertEquals($expected, $ecBytes);
466
467 $dataBytes = SplFixedArray::fromArray(
468 [67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214],
469 false
470 );
471 $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 18);
472 $expected = SplFixedArray::fromArray(
473 [175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187],
474 false
475 );
476 $this->assertEquals($expected, $ecBytes);
477
478 // High-order zero coefficient case.
479 $dataBytes = SplFixedArray::fromArray([32, 49, 205, 69, 42, 20, 0, 236, 17], false);
480 $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17);
481 $expected = SplFixedArray::fromArray(
482 [0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213],
483 false
484 );
485 $this->assertEquals($expected, $ecBytes);
486 }
487 }
488