# Documentation

Menu

## HanziTest extends DataInterfaceTestAbstract
in package

FinalYes
HanziTest.php : 20

Tests the Hanzi/GB2312 class

### Table of Contents

#### Properties

$dataMode : QRDataModeInterface
$FQN : string
$QRData : QRData
$testdata : string
$MAX_LENGTH : array<string|int, array<string|int, array<string|int, int>>>
  ISO/IEC 18004:2000 Tables 7-11 - Number of symbol characters and input data capacity for versions 1 to 40

#### Methods

getMaxLengthForMode() : int
  the maximum character count for the given $mode and $eccLevel
hanziProvider() : Generator
  lists all characters in the valid GB2312 range
maskPatternProvider() : array<string|int, array<string|int, int>>
maxLengthProvider() : Generator
  Generates test data for each data mode:
stringValidateProvider() : array<string|int, mixed>
  isGB2312() should pass on Hanzi/GB2312 characters and fail on everything else
testBinaryStringInvalid() : void
  Tests if a binary string is properly validated as false
testDataModeInstance() : void
  Verifies the QRDataModeInterface instance
testDecodeSegment() : void
  Tests decoding a data segment from a given BitBuffer
testGetMinimumVersion() : void
  Tests getting the minimum QR version for the given data
testGetMinimumVersionException() : void
  Tests if an exception is thrown when the data exceeds the maximum version while auto-detecting
testInitMatrix() : void
  Tests initializing the data matrix
testInstance() : void
  Verifies the QRData instance
testInvalidDataException() : void
  Tests if an exception is thrown when an invalid character is encountered
testInvalidDataOnEmptyException() : void
  Tests if an exception is thrown if the given string is empty
testMaxLength() : void
testMaxLengthOverflowException() : void
  Tests if an exception is thrown on data overflow
testValidateGB2312() : void
testValidateString() : void
  Tests if a string is properly validated for the respective data mode
versionBreakpointProvider() : array<string|int, mixed>
  returns versions within the version breakpoints 1-9, 10-26 and 27-40
setUp() : void

### Properties

#### $dataMode

DataInterfaceTestAbstract.php : 36
`protected QRDataModeInterface $dataMode`

#### $FQN

HanziTest.php : 22
`protected static string $FQN = \chillerlan\QRCode\Data\Hanzi::class`

#### $QRData

DataInterfaceTestAbstract.php : 35
`protected QRData $QRData`

#### $testdata

HanziTest.php : 23
`protected static string $testdata = '无可奈何燃花作香'`

#### $MAX_LENGTH

QRMaxLengthTrait.php : 28

ISO/IEC 18004:2000 Tables 7-11 - Number of symbol characters and input data capacity for versions 1 to 40

`private static array<string|int, array<string|int, array<string|int, int>>> $MAX_LENGTH = [ // v => [NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H ], KANJI => [L, M, Q, H ]] 1 => [[41, 34, 27, 17], [25, 20, 16, 10], [17, 14, 11, 7], [10, 8, 7, 4]], 2 => [[77, 63, 48, 34], [47, 38, 29, 20], [32, 26, 20, 14], [20, 16, 12, 8]], 3 => [[127, 101, 77, 58], [77, 61, 47, 35], [53, 42, 32, 24], [32, 26, 20, 15]], 4 => [[187, 149, 111, 82], [114, 90, 67, 50], [78, 62, 46, 34], [48, 38, 28, 21]], 5 => [[255, 202, 144, 106], [154, 122, 87, 64], [106, 84, 60, 44], [65, 52, 37, 27]], 6 => [[322, 255, 178, 139], [195, 154, 108, 84], [134, 106, 74, 58], [82, 65, 45, 36]], 7 => [[370, 293, 207, 154], [224, 178, 125, 93], [154, 122, 86, 64], [95, 75, 53, 39]], 8 => [[461, 365, 259, 202], [279, 221, 157, 122], [192, 152, 108, 84], [118, 93, 66, 52]], 9 => [[552, 432, 312, 235], [335, 262, 189, 143], [230, 180, 130, 98], [141, 111, 80, 60]], 10 => [[652, 513, 364, 288], [395, 311, 221, 174], [271, 213, 151, 119], [167, 131, 93, 74]], 11 => [[772, 604, 427, 331], [468, 366, 259, 200], [321, 251, 177, 137], [198, 155, 109, 85]], 12 => [[883, 691, 489, 374], [535, 419, 296, 227], [367, 287, 203, 155], [226, 177, 125, 96]], 13 => [[1022, 796, 580, 427], [619, 483, 352, 259], [425, 331, 241, 177], [262, 204, 149, 109]], 14 => [[1101, 871, 621, 468], [667, 528, 376, 283], [458, 362, 258, 194], [282, 223, 159, 120]], 15 => [[1250, 991, 703, 530], [758, 600, 426, 321], [520, 412, 292, 220], [320, 254, 180, 136]], 16 => [[1408, 1082, 775, 602], [854, 656, 470, 365], [586, 450, 322, 250], [361, 277, 198, 154]], 17 => [[1548, 1212, 876, 674], [938, 734, 531, 408], [644, 504, 364, 280], [397, 310, 224, 173]], 18 => [[1725, 1346, 948, 746], [1046, 816, 574, 452], [718, 560, 394, 310], [442, 345, 243, 191]], 19 => [[1903, 1500, 1063, 813], [1153, 909, 644, 493], [792, 624, 442, 338], [488, 384, 272, 208]], 20 => [[2061, 1600, 1159, 919], [1249, 970, 702, 557], [858, 666, 482, 382], [528, 410, 297, 235]], 21 => [[2232, 1708, 1224, 969], [1352, 1035, 742, 587], [929, 711, 509, 403], [572, 438, 314, 248]], 22 => [[2409, 1872, 1358, 1056], [1460, 1134, 823, 640], [1003, 779, 565, 439], [618, 480, 348, 270]], 23 => [[2620, 2059, 1468, 1108], [1588, 1248, 890, 672], [1091, 857, 611, 461], [672, 528, 376, 284]], 24 => [[2812, 2188, 1588, 1228], [1704, 1326, 963, 744], [1171, 911, 661, 511], [721, 561, 407, 315]], 25 => [[3057, 2395, 1718, 1286], [1853, 1451, 1041, 779], [1273, 997, 715, 535], [784, 614, 440, 330]], 26 => [[3283, 2544, 1804, 1425], [1990, 1542, 1094, 864], [1367, 1059, 751, 593], [842, 652, 462, 365]], 27 => [[3517, 2701, 1933, 1501], [2132, 1637, 1172, 910], [1465, 1125, 805, 625], [902, 692, 496, 385]], 28 => [[3669, 2857, 2085, 1581], [2223, 1732, 1263, 958], [1528, 1190, 868, 658], [940, 732, 534, 405]], 29 => [[3909, 3035, 2181, 1677], [2369, 1839, 1322, 1016], [1628, 1264, 908, 698], [1002, 778, 559, 430]], 30 => [[4158, 3289, 2358, 1782], [2520, 1994, 1429, 1080], [1732, 1370, 982, 742], [1066, 843, 604, 457]], 31 => [[4417, 3486, 2473, 1897], [2677, 2113, 1499, 1150], [1840, 1452, 1030, 790], [1132, 894, 634, 486]], 32 => [[4686, 3693, 2670, 2022], [2840, 2238, 1618, 1226], [1952, 1538, 1112, 842], [1201, 947, 684, 518]], 33 => [[4965, 3909, 2805, 2157], [3009, 2369, 1700, 1307], [2068, 1628, 1168, 898], [1273, 1002, 719, 553]], 34 => [[5253, 4134, 2949, 2301], [3183, 2506, 1787, 1394], [2188, 1722, 1228, 958], [1347, 1060, 756, 590]], 35 => [[5529, 4343, 3081, 2361], [3351, 2632, 1867, 1431], [2303, 1809, 1283, 983], [1417, 1113, 790, 605]], 36 => [[5836, 4588, 3244, 2524], [3537, 2780, 1966, 1530], [2431, 1911, 1351, 1051], [1496, 1176, 832, 647]], 37 => [[6153, 4775, 3417, 2625], [3729, 2894, 2071, 1591], [2563, 1989, 1423, 1093], [1577, 1224, 876, 673]], 38 => [[6479, 5039, 3599, 2735], [3927, 3054, 2181, 1658], [2699, 2099, 1499, 1139], [1661, 1292, 923, 701]], 39 => [[6743, 5313, 3791, 2927], [4087, 3220, 2298, 1774], [2809, 2213, 1579, 1219], [1729, 1362, 972, 750]], 40 => [[7089, 5596, 3993, 3057], [4296, 3391, 2420, 1852], [2953, 2331, 1663, 1273], [1817, 1435, 1024, 784]], ]`

##### Tags

see
  http://www.qrcode.com/en/about/version.html

### Methods

#### getMaxLengthForMode()

QRMaxLengthTrait.php : 81

the maximum character count for the given $mode and $eccLevel

`public static getMaxLengthForMode(int $mode, Version $version, EccLevel $eccLevel) : int`

##### Parameters

$mode : int
$version : Version
$eccLevel : EccLevel

##### Tags

todo:

  this methood is only used in unit tests (incl. MAX_LENGTH table)

throws
  QRCodeException
codeCoverageIgnore

##### Return values

int

#### hanziProvider()

HanziTest.php : 42

lists all characters in the valid GB2312 range

`public static hanziProvider() : Generator`

##### Return values

Generator

#### maskPatternProvider()

DataInterfaceTestAbstract.php : 61
`public static maskPatternProvider() : array<string|int, array<string|int, int>>`

##### Return values

array<string|int, array<string|int, int>>

#### maxLengthProvider()

DataInterfaceTestAbstract.php : 142

Generates test data for each data mode:

`public static maxLengthProvider() : Generator`

- version
- ECC level
- a string that contains the maximum amount of characters for the given mode
- a string that contains characters for the given mode and that exceeds the maximum length by one/two character(s)
- the maximum allowed character length

##### Tags

throws
  Exception

##### Return values

Generator

#### stringValidateProvider()

HanziTest.php : 28

isGB2312() should pass on Hanzi/GB2312 characters and fail on everything else

`public static stringValidateProvider() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### testBinaryStringInvalid()

DataInterfaceTestAbstract.php : 98

Tests if a binary string is properly validated as false

`public testBinaryStringInvalid() : void`

##### Tags

see
  https://github.com/chillerlan/php-qrcode/issues/182

#### testDataModeInstance()

DataInterfaceTestAbstract.php : 54

Verifies the QRDataModeInterface instance

`public testDataModeInstance() : void`

#### testDecodeSegment()

DataInterfaceTestAbstract.php : 115

Tests decoding a data segment from a given BitBuffer

`public testDecodeSegment(int $version) : void`

##### Parameters

$version : int

##### Tags

dataProvider

  versionBreakpointProvider

#### testGetMinimumVersion()

DataInterfaceTestAbstract.php : 191

Tests getting the minimum QR version for the given data

`public testGetMinimumVersion(Version $version, EccLevel $eccLevel, string $str) : void`

##### Parameters

$version : Version
$eccLevel : EccLevel
$str : string

##### Tags

dataProvider

  maxLengthProvider

#### testGetMinimumVersionException()

DataInterfaceTestAbstract.php : 229

Tests if an exception is thrown when the data exceeds the maximum version while auto-detecting

`public testGetMinimumVersionException() : void`

#### testInitMatrix()

DataInterfaceTestAbstract.php : 70

Tests initializing the data matrix

`public testInitMatrix(int $pattern) : void`

##### Parameters

$pattern : int

##### Tags

dataProvider

  maskPatternProvider

#### testInstance()

DataInterfaceTestAbstract.php : 47

Verifies the QRData instance

`public testInstance() : void`

#### testInvalidDataException()

DataInterfaceTestAbstract.php : 239

Tests if an exception is thrown when an invalid character is encountered

`public testInvalidDataException() : void`

#### testInvalidDataOnEmptyException()

DataInterfaceTestAbstract.php : 250

Tests if an exception is thrown if the given string is empty

`public testInvalidDataOnEmptyException() : void`

#### testMaxLength()

DataInterfaceTestAbstract.php : 174
`public testMaxLength(Version $version, EccLevel $eccLevel, string $str) : void`

##### Parameters

$version : Version
$eccLevel : EccLevel
$str : string

##### Tags

dataProvider

  maxLengthProvider

#### testMaxLengthOverflowException()

DataInterfaceTestAbstract.php : 214

Tests if an exception is thrown on data overflow

`public testMaxLengthOverflowException(Version $version, EccLevel $eccLevel, string $str, string $str1) : void`

##### Parameters

$version : Version
$eccLevel : EccLevel
$str : string
$str1 : string

##### Tags

dataProvider

  maxLengthProvider

#### testValidateGB2312()

HanziTest.php : 64
`public testValidateGB2312(string $chr) : void`

##### Parameters

$chr : string

##### Tags

group

  slow

dataProvider

  hanziProvider

#### testValidateString()

DataInterfaceTestAbstract.php : 88

Tests if a string is properly validated for the respective data mode

`public testValidateString(string $string, bool $expected) : void`

##### Parameters

$string : string
$expected : bool

##### Tags

dataProvider

  stringValidateProvider

#### versionBreakpointProvider()

DataInterfaceTestAbstract.php : 106

returns versions within the version breakpoints 1-9, 10-26 and 27-40

`public static versionBreakpointProvider() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### setUp()

DataInterfaceTestAbstract.php : 40
`protected setUp() : void`

## Search results