Documentation

HanziTest extends DataInterfaceTestAbstract
in package

FinalYes

Tests the Hanzi/GB2312 class

Table of Contents

Constants

testData  = '无可奈何燃花作香'

Properties

$dataMode  : QRDataModeInterface
$QRData  : QRData

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 random binary string is properly validated as false
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
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
getDataModeInterface()  : QRDataModeInterface
setUp()  : void

Constants

testData

protected mixed testData = '无可奈何燃花作香'

Properties

Methods

getMaxLengthForMode()

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
throws
QRCodeException
codeCoverageIgnore
Return values
int

hanziProvider()

lists all characters in the valid GB2312 range

public static hanziProvider() : Generator
Return values
Generator

maskPatternProvider()

public static maskPatternProvider() : array<string|int, array<string|int, int>>
Return values
array<string|int, array<string|int, int>>

maxLengthProvider()

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()

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

public static stringValidateProvider() : array<string|int, mixed>
Tags
phpstan-return

array<int, array{0: string, 1: bool}>

Return values
array<string|int, mixed>

testDecodeSegment()

Tests decoding a data segment from a given BitBuffer

public testDecodeSegment(int $version) : void
Parameters
$version : int
Attributes
#[DataProvider]
'versionBreakpointProvider'

testGetMinimumVersion()

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
Attributes
#[DataProvider]
'maxLengthProvider'

testGetMinimumVersionException()

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

public testGetMinimumVersionException() : void

testInitMatrix()

Tests initializing the data matrix

public testInitMatrix(int $pattern) : void
Parameters
$pattern : int
Attributes
#[DataProvider]
'maskPatternProvider'

testInvalidDataException()

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

public testInvalidDataException() : void

testInvalidDataOnEmptyException()

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

public testInvalidDataOnEmptyException() : void

testMaxLengthOverflowException()

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
Attributes
#[DataProvider]
'maxLengthProvider'

testValidateGB2312()

public testValidateGB2312(string $chr) : void
Parameters
$chr : string
Attributes
#[DataProvider]
'hanziProvider'
#[Group]
'slow'

testValidateString()

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

public testValidateString(string $string, bool $expected) : void
Parameters
$string : string
$expected : bool
Attributes
#[DataProvider]
'stringValidateProvider'

versionBreakpointProvider()

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

public static versionBreakpointProvider() : array<string|int, mixed>
Tags
phpstan-return

array<string, array{0: int}>

Return values
array<string|int, mixed>

        
On this page

Search results