QRMatrixTest.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /**
  3. * Class QRMatrixTest
  4. *
  5. * @created 17.11.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeTest\Data;
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Version};
  13. use chillerlan\QRCode\Data\{QRCodeDataException, QRMatrix};
  14. use chillerlan\QRCode\Output\QRStringText;
  15. use PHPUnit\Framework\TestCase;
  16. use Generator;
  17. use function defined;
  18. /**
  19. * Tests the QRMatrix class
  20. */
  21. final class QRMatrixTest extends TestCase{
  22. private const version = 40;
  23. private QRMatrix $matrix;
  24. /**
  25. * invokes a QRMatrix object
  26. */
  27. protected function setUp():void{
  28. $this->matrix = new QRMatrix(
  29. new Version($this::version),
  30. new EccLevel(EccLevel::L)
  31. );
  32. }
  33. /**
  34. * Matrix debugging console output
  35. */
  36. public static function debugMatrix(QRMatrix $matrix):void{
  37. /** @noinspection PhpUndefinedConstantInspection - see phpunit.xml.dist */
  38. if(defined('TEST_IS_CI') && TEST_IS_CI === true){
  39. return;
  40. }
  41. $opt = new QROptions;
  42. $opt->eol = "\n";
  43. $opt->moduleValues = [
  44. // finder
  45. QRMatrix::M_FINDER_DARK => QRStringText::ansi8('██', 124), // dark (true)
  46. QRMatrix::M_FINDER => QRStringText::ansi8('░░', 124), // light (false)
  47. QRMatrix::M_FINDER_DOT => QRStringText::ansi8('██', 124), // finder dot, dark (true)
  48. // alignment
  49. QRMatrix::M_ALIGNMENT_DARK => QRStringText::ansi8('██', 2),
  50. QRMatrix::M_ALIGNMENT => QRStringText::ansi8('░░', 2),
  51. // timing
  52. QRMatrix::M_TIMING_DARK => QRStringText::ansi8('██', 184),
  53. QRMatrix::M_TIMING => QRStringText::ansi8('░░', 184),
  54. // format
  55. QRMatrix::M_FORMAT_DARK => QRStringText::ansi8('██', 200),
  56. QRMatrix::M_FORMAT => QRStringText::ansi8('░░', 200),
  57. // version
  58. QRMatrix::M_VERSION_DARK => QRStringText::ansi8('██', 21),
  59. QRMatrix::M_VERSION => QRStringText::ansi8('░░', 21),
  60. // data
  61. QRMatrix::M_DATA_DARK => QRStringText::ansi8('██', 166),
  62. QRMatrix::M_DATA => QRStringText::ansi8('░░', 166),
  63. // dark module
  64. QRMatrix::M_DARKMODULE => QRStringText::ansi8('██', 53),
  65. // separator
  66. QRMatrix::M_SEPARATOR => QRStringText::ansi8('░░', 219),
  67. // quiet zone
  68. QRMatrix::M_QUIETZONE => QRStringText::ansi8('░░', 195),
  69. // logo space
  70. QRMatrix::M_LOGO => QRStringText::ansi8('░░', 105),
  71. // empty
  72. QRMatrix::M_NULL => QRStringText::ansi8('░░', 231),
  73. ];
  74. $out = (new QRStringText($opt, $matrix))->dump();
  75. echo "\n\n".$out."\n\n";
  76. }
  77. /**
  78. * debugging shortcut - limit to a single version when using with matrixProvider
  79. *
  80. * @see QRMatrixTest::matrixProvider()
  81. */
  82. protected function dm(QRMatrix $matrix):void{
  83. // limit
  84. if($matrix->getVersion()->getVersionNumber() !== 7){
  85. return;
  86. }
  87. $this::debugMatrix($matrix);
  88. }
  89. /**
  90. * Validates the QRMatrix instance
  91. */
  92. public function testInstance():void{
  93. $this::assertInstanceOf(QRMatrix::class, $this->matrix);
  94. }
  95. /**
  96. * Tests if size() returns the actual matrix size/count
  97. */
  98. public function testSize():void{
  99. $this::assertCount($this->matrix->getSize(), $this->matrix->getMatrix(true));
  100. }
  101. /**
  102. * Tests if version() returns the current (given) version
  103. */
  104. public function testVersion():void{
  105. $this::assertSame($this::version, $this->matrix->getVersion()->getVersionNumber());
  106. }
  107. /**
  108. * Tests if eccLevel() returns the current (given) ECC level
  109. */
  110. public function testECC():void{
  111. $this::assertSame(EccLevel::L, $this->matrix->getEccLevel()->getLevel());
  112. }
  113. /**
  114. * Tests if maskPattern() returns the current (or default) mask pattern
  115. */
  116. public function testMaskPattern():void{
  117. // set via matrix evaluation
  118. $matrix = (new QRCode)->addByteSegment('testdata')->getQRMatrix();
  119. $this::assertInstanceOf(MaskPattern::class, $matrix->getMaskPattern());
  120. $this::assertSame(MaskPattern::PATTERN_100, $matrix->getMaskPattern()->getPattern());
  121. }
  122. /**
  123. * Tests the set(), get() and check() methods
  124. */
  125. public function testGetSetCheck():void{
  126. $this->matrix->set(10, 10, true, QRMatrix::M_LOGO);
  127. $this::assertSame(QRMatrix::M_LOGO_DARK, $this->matrix->get(10, 10));
  128. $this::assertTrue($this->matrix->check(10, 10));
  129. $this->matrix->set(20, 20, false, QRMatrix::M_LOGO);
  130. $this::assertSame(QRMatrix::M_LOGO, $this->matrix->get(20, 20));
  131. $this::assertFalse($this->matrix->check(20, 20));
  132. // get proper results when using a *_DARK constant
  133. $this->matrix->set(30, 30, true, QRMatrix::M_LOGO_DARK);
  134. $this::assertSame(QRMatrix::M_LOGO_DARK, $this->matrix->get(30, 30));
  135. $this->matrix->set(40, 40, false, QRMatrix::M_LOGO_DARK);
  136. $this::assertSame(QRMatrix::M_LOGO, $this->matrix->get(40, 40));
  137. // out of range
  138. $this::assertFalse($this->matrix->check(-1, -1));
  139. $this::assertSame(-1, $this->matrix->get(-1, -1));
  140. }
  141. /**
  142. * Version data provider for several pattern tests
  143. */
  144. public static function matrixProvider():Generator{
  145. $ecc = new EccLevel(EccLevel::L);
  146. for($i = 1; $i <= 40; $i++){
  147. yield 'version: '.$i => [new QRMatrix(new Version($i), $ecc)];
  148. }
  149. }
  150. /**
  151. * Tests setting the dark module and verifies its position
  152. *
  153. * @dataProvider matrixProvider
  154. */
  155. public function testSetDarkModule(QRMatrix $matrix):void{
  156. $matrix->setDarkModule();
  157. $this->dm($matrix);
  158. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(8, ($matrix->getSize() - 8)));
  159. }
  160. /**
  161. * Tests setting the finder patterns and verifies their positions
  162. *
  163. * @dataProvider matrixProvider
  164. */
  165. public function testSetFinderPattern(QRMatrix $matrix):void{
  166. $matrix->setFinderPattern();
  167. $this->dm($matrix);
  168. $this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, 0));
  169. $this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, ($matrix->getSize() - 1)));
  170. $this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(($matrix->getSize() - 1), 0));
  171. }
  172. /**
  173. * Tests the separator patterns and verifies their positions
  174. *
  175. * @dataProvider matrixProvider
  176. */
  177. public function testSetSeparators(QRMatrix $matrix):void{
  178. $matrix->setSeparators();
  179. $this->dm($matrix);
  180. $this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(7, 0));
  181. $this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(0, 7));
  182. $this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(0, ($matrix->getSize() - 8)));
  183. $this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(($matrix->getSize() - 8), 0));
  184. }
  185. /**
  186. * Tests the alignment patterns and verifies their positions - version 1 (no pattern) skipped
  187. *
  188. * @dataProvider matrixProvider
  189. */
  190. public function testSetAlignmentPattern(QRMatrix $matrix):void{
  191. $version = $matrix->getVersion();
  192. if($version->getVersionNumber() === 1){
  193. /** @noinspection PhpUnitTestFailedLineInspection */
  194. $this::markTestSkipped('N/A (Version 1 has no alignment pattern)');
  195. }
  196. $matrix
  197. ->setFinderPattern()
  198. ->setAlignmentPattern()
  199. ;
  200. $this->dm($matrix);
  201. $alignmentPattern = $version->getAlignmentPattern();
  202. foreach($alignmentPattern as $py){
  203. foreach($alignmentPattern as $px){
  204. // skip finder pattern
  205. if(!$matrix->checkTypeIn($px, $py, [QRMatrix::M_FINDER, QRMatrix::M_FINDER_DOT])){
  206. $this::assertSame(QRMatrix::M_ALIGNMENT_DARK, $matrix->get($px, $py));
  207. }
  208. }
  209. }
  210. }
  211. /**
  212. * Tests the timing patterns and verifies their positions
  213. *
  214. * @dataProvider matrixProvider
  215. */
  216. public function testSetTimingPattern(QRMatrix $matrix):void{
  217. $matrix
  218. ->setFinderPattern()
  219. ->setAlignmentPattern()
  220. ->setTimingPattern()
  221. ;
  222. $this->dm($matrix);
  223. $size = $matrix->getSize();
  224. for($i = 7; $i < ($size - 7); $i++){
  225. if(($i % 2) === 0){
  226. // skip alignment pattern
  227. if(!$matrix->checkTypeIn(6, $i, [QRMatrix::M_ALIGNMENT])){
  228. $this::assertSame(QRMatrix::M_TIMING_DARK, $matrix->get(6, $i));
  229. $this::assertSame(QRMatrix::M_TIMING_DARK, $matrix->get($i, 6));
  230. }
  231. }
  232. }
  233. }
  234. /**
  235. * Tests the version patterns and verifies their positions - version < 7 skipped
  236. *
  237. * @dataProvider matrixProvider
  238. */
  239. public function testSetVersionNumber(QRMatrix $matrix):void{
  240. if($matrix->getVersion()->getVersionNumber() < 7){
  241. /** @noinspection PhpUnitTestFailedLineInspection */
  242. $this::markTestSkipped('N/A (Version < 7)');
  243. }
  244. $matrix->setVersionNumber();
  245. $this->dm($matrix);
  246. $this::assertTrue($matrix->checkType(($matrix->getSize() - 9), 0, QRMatrix::M_VERSION));
  247. $this::assertTrue($matrix->checkType(($matrix->getSize() - 11), 5, QRMatrix::M_VERSION));
  248. $this::assertTrue($matrix->checkType(0, ($matrix->getSize() - 9), QRMatrix::M_VERSION));
  249. $this::assertTrue($matrix->checkType(5, ($matrix->getSize() - 11), QRMatrix::M_VERSION));
  250. }
  251. /**
  252. * Tests the format patterns and verifies their positions
  253. *
  254. * @dataProvider matrixProvider
  255. */
  256. public function testSetFormatInfo(QRMatrix $matrix):void{
  257. $matrix->setFormatInfo(new MaskPattern(MaskPattern::PATTERN_000));
  258. $this->dm($matrix);
  259. $this::assertTrue($matrix->checkType(8, 0, QRMatrix::M_FORMAT));
  260. $this::assertTrue($matrix->checkType(0, 8, QRMatrix::M_FORMAT));
  261. $this::assertTrue($matrix->checkType(($matrix->getSize() - 1), 8, QRMatrix::M_FORMAT));
  262. $this::assertTrue($matrix->checkType(($matrix->getSize() - 8), 8, QRMatrix::M_FORMAT));
  263. }
  264. /**
  265. * Tests the quiet zone pattern and verifies its position
  266. *
  267. * @dataProvider matrixProvider
  268. */
  269. public function testSetQuietZone(QRMatrix $matrix):void{
  270. $size = $matrix->getSize();
  271. $quietZoneSize = 5;
  272. $matrix->set(0, 0, true, QRMatrix::M_LOGO);
  273. $matrix->set(($size - 1), ($size - 1), true, QRMatrix::M_LOGO);
  274. $matrix->setQuietZone($quietZoneSize);
  275. $s = ($size + 2 * $quietZoneSize);
  276. $this::assertCount($s, $matrix->getMatrix(true));
  277. $this::assertCount($s, $matrix->getMatrix(true)[($size - 1)]);
  278. $size = $matrix->getSize();
  279. $this->dm($matrix);
  280. $this::assertTrue($matrix->checkType(0, 0, QRMatrix::M_QUIETZONE));
  281. $this::assertTrue($matrix->checkType(($size - 1), ($size - 1), QRMatrix::M_QUIETZONE));
  282. $s = ($size - 1 - $quietZoneSize);
  283. $this::assertSame(QRMatrix::M_LOGO_DARK, $matrix->get($quietZoneSize, $quietZoneSize));
  284. $this::assertSame(QRMatrix::M_LOGO_DARK, $matrix->get($s, $s));
  285. }
  286. /**
  287. * Tests if an exception is thrown in an attempt to create the quiet zone before data was written
  288. */
  289. public function testSetQuietZoneException():void{
  290. $this->expectException(QRCodeDataException::class);
  291. $this->expectExceptionMessage('use only after writing data');
  292. $this->matrix->setQuietZone(42);
  293. }
  294. /**
  295. * Tests rotating the matrix by 90 degrees CW
  296. *
  297. * @dataProvider matrixProvider
  298. */
  299. public function testRotate90(QRMatrix $matrix):void{
  300. $matrix->initFunctionalPatterns();
  301. // matrix size
  302. $size = $matrix->getSize();
  303. // quiet zone size
  304. $qz = (($size - $matrix->getVersion()->getDimension()) / 2);
  305. // initial dark module position
  306. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get((8 + $qz), ($size - 8 - $qz)));
  307. // first rotation
  308. $matrix->rotate90();
  309. $this->dm($matrix);
  310. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get((7 + $qz), (8 + $qz)));
  311. // second rotation
  312. $matrix->rotate90();
  313. $this->dm($matrix);
  314. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(($size - 9 - $qz), (7 + $qz)));
  315. // third rotation
  316. $matrix->rotate90();
  317. $this->dm($matrix);
  318. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(($size - 8 - $qz), ($size - 9 - $qz)));
  319. // fourth rotation
  320. $matrix->rotate90();
  321. $this->dm($matrix);
  322. $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get((8 + $qz), ($size - 8 - $qz)));
  323. }
  324. /**
  325. * Tests if the logo space is drawn square if one of the dimensions is omitted
  326. */
  327. public function testSetLogoSpaceOmitHeight():void{
  328. $o = new QROptions;
  329. $o->version = 2;
  330. $o->eccLevel = EccLevel::H;
  331. $o->addQuietzone = false;
  332. $o->addLogoSpace = true;
  333. $o->logoSpaceHeight = 5;
  334. $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
  335. $this::debugMatrix($matrix);
  336. $this::assertFalse($matrix->checkType(9, 9, QRMatrix::M_LOGO));
  337. $this::assertTrue($matrix->checkType(10, 10, QRMatrix::M_LOGO));
  338. $this::assertTrue($matrix->checkType(14, 14, QRMatrix::M_LOGO));
  339. $this::assertFalse($matrix->checkType(15, 15, QRMatrix::M_LOGO));
  340. }
  341. /**
  342. * Tests the auto orientation of the logo space
  343. */
  344. public function testSetLogoSpaceOrientation():void{
  345. $o = new QROptions;
  346. $o->version = 10;
  347. $o->eccLevel = EccLevel::H;
  348. $o->addQuietzone = false;
  349. $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
  350. // also testing size adjustment to uneven numbers
  351. $matrix->setLogoSpace(20, 14);
  352. $this::debugMatrix($matrix);
  353. // NW corner
  354. $this::assertFalse($matrix->checkType(17, 20, QRMatrix::M_LOGO));
  355. $this::assertTrue($matrix->checkType(18, 21, QRMatrix::M_LOGO));
  356. // SE corner
  357. $this::assertTrue($matrix->checkType(38, 35, QRMatrix::M_LOGO));
  358. $this::assertFalse($matrix->checkType(39, 36, QRMatrix::M_LOGO));
  359. }
  360. /**
  361. * Tests the manual positioning of the logo space
  362. */
  363. public function testSetLogoSpacePosition():void{
  364. $o = new QROptions;
  365. $o->version = 10;
  366. $o->eccLevel = EccLevel::H;
  367. $o->addQuietzone = true;
  368. $o->quietzoneSize = 10;
  369. $matrix = (new QRCode($o))->addByteSegment('testdata')->getQRMatrix();
  370. $matrix->setLogoSpace(21, 21, -10, -10);
  371. $this::debugMatrix($matrix);
  372. $this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get(9, 9));
  373. $this::assertSame(QRMatrix::M_LOGO, $matrix->get(10, 10));
  374. $this::assertSame(QRMatrix::M_LOGO, $matrix->get(20, 20));
  375. $this::assertNotSame(QRMatrix::M_LOGO, $matrix->get(21, 21));
  376. // I just realized that setLogoSpace() could be called multiple times
  377. // on the same instance, and I'm not going to do anything about it :P
  378. $matrix->setLogoSpace(21, 21, 45, 45);
  379. $this::debugMatrix($matrix);
  380. $this::assertNotSame(QRMatrix::M_LOGO, $matrix->get(54, 54));
  381. $this::assertSame(QRMatrix::M_LOGO, $matrix->get(55, 55));
  382. $this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get(67, 67));
  383. }
  384. /**
  385. * Tests whether an exception is thrown when an ECC level other than "H" is set when attempting to add logo space
  386. */
  387. public function testSetLogoSpaceInvalidEccException():void{
  388. $this->expectException(QRCodeDataException::class);
  389. $this->expectExceptionMessage('ECC level "H" required to add logo space');
  390. (new QRCode)->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(50, 50);
  391. }
  392. /**
  393. * Tests whether an exception is thrown when width or height exceed the matrix size
  394. */
  395. public function testSetLogoSpaceExceedsException():void{
  396. $this->expectException(QRCodeDataException::class);
  397. $this->expectExceptionMessage('logo dimensions exceed matrix size');
  398. $o = new QROptions;
  399. $o->version = 5;
  400. $o->eccLevel = EccLevel::H;
  401. (new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(69, 1);
  402. }
  403. /**
  404. * Tests whether an exception is thrown when the logo space size exceeds the maximum ECC capacity
  405. */
  406. public function testSetLogoSpaceMaxSizeException():void{
  407. $this->expectException(QRCodeDataException::class);
  408. $this->expectExceptionMessage('logo space exceeds the maximum error correction capacity');
  409. $o = new QROptions;
  410. $o->version = 5;
  411. $o->eccLevel = EccLevel::H;
  412. (new QRCode($o))->addByteSegment('testdata')->getQRMatrix()->setLogoSpace(37, 37);
  413. }
  414. /**
  415. * Tests flipping the value of a module
  416. */
  417. public function testFlip():void{
  418. $this->matrix->set(20, 20, true, QRMatrix::M_LOGO);
  419. // cover checkType()
  420. $this::assertTrue($this->matrix->checkType(20, 20, QRMatrix::M_LOGO));
  421. // verify the current state (dark)
  422. $this::assertSame(QRMatrix::M_LOGO_DARK, $this->matrix->get(20, 20));
  423. // flip
  424. $this->matrix->flip(20, 20);
  425. // verify flip
  426. $this::assertSame(QRMatrix::M_LOGO, $this->matrix->get(20, 20));
  427. // flip again
  428. $this->matrix->flip(20, 20);
  429. // verify flip
  430. $this::assertSame(QRMatrix::M_LOGO_DARK, $this->matrix->get(20, 20));
  431. }
  432. /**
  433. * Tests checking whether the M_TYPE of a module is not one of an array of M_TYPES
  434. */
  435. public function testCheckTypeIn():void{
  436. $this->matrix->set(10, 10, true, QRMatrix::M_QUIETZONE);
  437. $this::assertFalse($this->matrix->checkTypeIn(10, 10, [QRMatrix::M_DATA, QRMatrix::M_FINDER]));
  438. $this::assertTrue($this->matrix->checkTypeIn(10, 10, [QRMatrix::M_QUIETZONE, QRMatrix::M_FINDER]));
  439. }
  440. /**
  441. * Tests checking the adjacent modules
  442. */
  443. public function testCheckNeighbours():void{
  444. $this->matrix
  445. ->setFinderPattern()
  446. ->setAlignmentPattern()
  447. ;
  448. /*
  449. * center of finder pattern (surrounded by all dark)
  450. *
  451. * # # # # # # #
  452. * # #
  453. * # # # # #
  454. * # # 0 # #
  455. * # # # # #
  456. * # #
  457. * # # # # # # #
  458. */
  459. $this::assertSame(0b11111111, $this->matrix->checkNeighbours(3, 3));
  460. /*
  461. * center of alignment pattern (surrounded by all light)
  462. *
  463. * # # # # #
  464. * # #
  465. * # 0 #
  466. * # #
  467. * # # # # #
  468. */
  469. $this::assertSame(0b00000000, $this->matrix->checkNeighbours(30, 30));
  470. /*
  471. * top left light block of finder pattern
  472. *
  473. * # # #
  474. * # 0
  475. * # #
  476. */
  477. $this::assertSame(0b11010111, $this->matrix->checkNeighbours(1, 1));
  478. /*
  479. * bottom left light block of finder pattern
  480. *
  481. * # #
  482. * # 0
  483. * # # #
  484. */
  485. $this::assertSame(0b11110101, $this->matrix->checkNeighbours(1, 5));
  486. /*
  487. * top right light block of finder pattern
  488. *
  489. * # # #
  490. * 0 #
  491. * # #
  492. */
  493. $this::assertSame(0b01011111, $this->matrix->checkNeighbours(5, 1));
  494. /*
  495. * bottom right light block of finder pattern
  496. *
  497. * # #
  498. * 0 #
  499. * # # #
  500. */
  501. $this::assertSame(0b01111101, $this->matrix->checkNeighbours(5, 5));
  502. /*
  503. * M_TYPE check
  504. *
  505. * # # #
  506. * 0
  507. * X X X
  508. */
  509. $this::assertSame(0b00000111, $this->matrix->checkNeighbours(3, 1, QRMatrix::M_FINDER));
  510. $this::assertSame(0b01110000, $this->matrix->checkNeighbours(3, 1, QRMatrix::M_FINDER_DOT));
  511. }
  512. }