mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-16 08:45:45 +00:00
updated tests
This commit is contained in:
+20
-5
@@ -16,8 +16,9 @@ use chillerlan\QRCode\Data\AlphaNum;
|
||||
use chillerlan\QRCode\Data\Byte;
|
||||
use chillerlan\QRCode\Data\Kanji;
|
||||
use chillerlan\QRCode\Data\Number;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataTest extends \PHPUnit_Framework_TestCase{
|
||||
class DataTest extends TestCase{
|
||||
|
||||
/**
|
||||
* @var \chillerlan\QRCode\BitBuffer
|
||||
@@ -29,7 +30,7 @@ class DataTest extends \PHPUnit_Framework_TestCase{
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
public function bitProvider(){
|
||||
public function bitProviderMode(){
|
||||
return [
|
||||
[QRConst::MODE_NUMBER, Number::class, '123456789'],
|
||||
[QRConst::MODE_NUMBER, Number::class, '1234567890'],
|
||||
@@ -45,20 +46,34 @@ class DataTest extends \PHPUnit_Framework_TestCase{
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider bitProvider
|
||||
* @dataProvider bitProviderMode
|
||||
*/
|
||||
public function testMode($mode, $class, $data){
|
||||
$this->module = new $class($data);
|
||||
$this->assertEquals($mode, $this->module->mode);
|
||||
}
|
||||
|
||||
|
||||
public function bitProviderWrite(){
|
||||
return [
|
||||
[Number::class, '123456789', [30, 220, 140, 84]],
|
||||
[Number::class, '1234567890', [30, 220, 140, 84, 0]],
|
||||
[Number::class, '12345678901', [30, 220, 140, 84, 8]],
|
||||
[AlphaNum::class, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', [57, 168, 165, 66, 174, 22, 122, 230, 95, 172, 81, 149, 180, 38, 178, 220, 28, 58, 11, 196, 88, 231, 40, 102, 87, 60, 237, 94, 99, 227, 108]],
|
||||
[Byte::class, '#\\', [35, 92]],
|
||||
[Kanji::class, '茗荷', [236, 100, 74, 18, 238]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider bitProvider
|
||||
* @dataProvider bitProviderWrite
|
||||
*/
|
||||
public function testWrite($mode, $class, $data){
|
||||
public function testWrite($class, $data, $expected){
|
||||
$this->bitBuffer->clear();
|
||||
$this->module = new $class($data);
|
||||
$this->module->write($this->bitBuffer);
|
||||
|
||||
$this->assertSame($expected, $this->bitBuffer->buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user