2021-02-26 16:16:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Class KanjiTest
|
|
|
|
*
|
|
|
|
* @filesource KanjiTest.php
|
|
|
|
* @created 24.11.2017
|
|
|
|
* @package chillerlan\QRCodeTest\Data
|
|
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
|
|
* @copyright 2017 Smiley
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chillerlan\QRCodeTest\Data;
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
use chillerlan\QRCode\QROptions;
|
|
|
|
use chillerlan\QRCode\Data\{Kanji, QRCodeDataException, QRDataInterface};
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* Tests the Kanji class
|
|
|
|
*/
|
|
|
|
final class KanjiTest extends DatainterfaceTestAbstract{
|
|
|
|
|
|
|
|
/** @internal */
|
|
|
|
protected string $testdata = '茗荷茗荷茗荷茗荷茗荷';
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/** @internal */
|
|
|
|
protected array $expected = [
|
2021-02-26 16:16:17 +00:00
|
|
|
128, 173, 85, 26, 95, 85, 70, 151,
|
|
|
|
213, 81, 165, 245, 84, 105, 125, 85,
|
|
|
|
26, 92, 0, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
17, 236, 17, 236, 17, 236, 17, 236,
|
|
|
|
195, 11, 221, 91, 141, 220, 163, 46,
|
|
|
|
165, 37, 163, 176, 79, 0, 64, 68,
|
|
|
|
96, 113, 54, 191
|
|
|
|
];
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
protected function getDataInterfaceInstance(QROptions $options):QRDataInterface{
|
|
|
|
return new Kanji($options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests if an exception is thrown when an invalid character is encountered
|
|
|
|
*/
|
|
|
|
public function testIllegalCharException1():void{
|
2021-02-26 16:16:17 +00:00
|
|
|
$this->expectException(QRCodeDataException::class);
|
|
|
|
$this->expectExceptionMessage('illegal char at 1 [16191]');
|
|
|
|
|
|
|
|
$this->dataInterface->setData('ÃÃ');
|
|
|
|
}
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* Tests if an exception is thrown when an invalid character is encountered
|
|
|
|
*/
|
|
|
|
public function testIllegalCharException2():void{
|
2021-02-26 16:16:17 +00:00
|
|
|
$this->expectException(QRCodeDataException::class);
|
|
|
|
$this->expectExceptionMessage('illegal char at 1');
|
|
|
|
|
|
|
|
$this->dataInterface->setData('Ã');
|
|
|
|
}
|
2022-07-02 14:01:51 +00:00
|
|
|
|
2021-02-26 16:16:17 +00:00
|
|
|
}
|