QRMatrixTest.php 18 KB

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