mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-09-19 22:26:36 +00:00
more tests
This commit is contained in:
+1
-2
@@ -17,8 +17,7 @@
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite name="php-qrcode test suite">
|
||||
<file>tests/BitBufferTest.php</file>
|
||||
<file>tests/UtilTest.php</file>
|
||||
<directory suffix=".php">./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @filesource DataTest.php
|
||||
* @created 08.02.2016
|
||||
* @author Smiley <smiley@chillerlan.net>
|
||||
* @copyright 2015 Smiley
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCodeTest\Data;
|
||||
|
||||
use chillerlan\QRCode\BitBuffer;
|
||||
use chillerlan\QRCode\QRConst;
|
||||
use chillerlan\QRCode\Data\AlphaNum;
|
||||
use chillerlan\QRCode\Data\Byte;
|
||||
use chillerlan\QRCode\Data\Kanji;
|
||||
use chillerlan\QRCode\Data\Number;
|
||||
|
||||
class DataTest extends \PHPUnit_Framework_TestCase{
|
||||
|
||||
/**
|
||||
* @var \chillerlan\QRCode\BitBuffer
|
||||
*/
|
||||
protected $bitBuffer;
|
||||
|
||||
/**
|
||||
* @var \chillerlan\QRCode\Data\QRDataInterface
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
public function bitProvider(){
|
||||
return [
|
||||
[QRConst::MODE_NUMBER, Number::class, '1234567890'],
|
||||
[QRConst::MODE_ALPHANUM, AlphaNum::class, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'],
|
||||
[QRConst::MODE_BYTE, Byte::class, '#'],
|
||||
[QRConst::MODE_KANJI, Kanji::class, '茗荷'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function setUp(){
|
||||
$this->bitBuffer = new BitBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider bitProvider
|
||||
*/
|
||||
public function testMode($mode, $class, $data){
|
||||
$module = new $class($data);
|
||||
$this->assertEquals($mode, $module->mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider bitProvider
|
||||
*/
|
||||
public function testWrite($mode, $class, $data){
|
||||
$module = new $class($data);
|
||||
$module->write($this->bitBuffer);
|
||||
// todo...
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @filesource QRCodeTest.php
|
||||
* @created 08.02.2016
|
||||
* @author Smiley <smiley@chillerlan.net>
|
||||
* @copyright 2015 Smiley
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCodeTest;
|
||||
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\QRCode\Output\QRImage;
|
||||
use chillerlan\QRCode\Output\QRImageOptions;
|
||||
use chillerlan\QRCode\Output\QRString;
|
||||
use chillerlan\QRCode\Output\QRStringOptions;
|
||||
|
||||
class QRCodeTest extends \PHPUnit_Framework_TestCase{
|
||||
|
||||
public function testInstance(){
|
||||
$output = new QRString;
|
||||
$options = new QROptions;
|
||||
|
||||
$this->assertInstanceOf(QRString::class, $output);
|
||||
$this->assertInstanceOf(QROptions::class, $options);
|
||||
$this->assertInstanceOf(QRCode::class, new QRCode('data', $output, $options));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-1
@@ -7,9 +7,11 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCodeTest;
|
||||
|
||||
use chillerlan\QRCode\Util;
|
||||
|
||||
class UtilTest extends PHPUnit_Framework_TestCase{
|
||||
class UtilTest extends \PHPUnit_Framework_TestCase{
|
||||
|
||||
public function testIsNumber(){
|
||||
$this->assertEquals(true, Util::isNumber('1234567890'));
|
||||
@@ -21,6 +23,7 @@ class UtilTest extends PHPUnit_Framework_TestCase{
|
||||
$this->assertEquals(false, Util::isAlphaNum('#'));
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/24755772
|
||||
public function testIsKanji(){
|
||||
$this->assertEquals(true, Util::isKanji('茗荷'));
|
||||
$this->assertEquals(false, Util::isKanji(''));
|
||||
|
||||
Reference in New Issue
Block a user