UtilTest.php 971 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * @filesource UtilTest.php
  4. * @created 08.02.2016
  5. * @author Smiley <smiley@chillerlan.net>
  6. * @copyright 2015 Smiley
  7. * @license MIT
  8. */
  9. namespace chillerlan\QRCodeTest;
  10. use chillerlan\QRCode\Util;
  11. class UtilTest extends \PHPUnit_Framework_TestCase{
  12. public function testIsNumber(){
  13. $this->assertEquals(true, Util::isNumber('1234567890'));
  14. $this->assertEquals(false, Util::isNumber('abc'));
  15. }
  16. public function testIsAlphaNum(){
  17. $this->assertEquals(true, Util::isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'));
  18. $this->assertEquals(false, Util::isAlphaNum('#'));
  19. }
  20. // http://stackoverflow.com/a/24755772
  21. public function testIsKanji(){
  22. $this->assertEquals(true, Util::isKanji('茗荷'));
  23. $this->assertEquals(false, Util::isKanji(''));
  24. $this->assertEquals(false, Util::isKanji('ÃÃÃ')); // non-kanji
  25. $this->assertEquals(false, Util::isKanji('荷')); // kanji forced into byte mode due to length
  26. }
  27. }