TestAlgorithm.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/6/24
  6. * Time: 上午1:20
  7. */
  8. define('APP_ID', 'test');
  9. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  10. require_once(BASE_ROOT_PATH . '/global.php');
  11. require_once(BASE_CORE_PATH . '/lrlz.php');
  12. require_once(BASE_ROOT_PATH . '/fooder.php');
  13. require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
  14. use PHPUnit\Framework\TestCase;
  15. class TestAlgorithm extends TestCase
  16. {
  17. public function testSearch()
  18. {
  19. $mobiles = array('13911129897','13951129867','13916129867','13918129867','13911179867','13911109867');
  20. sort($mobiles);
  21. $ret = algorithm::bsearch('13911109867',$mobiles);
  22. $ret = $mobiles[$ret];
  23. $x = $mobiles[0];
  24. }
  25. public function testEncrypt()
  26. {
  27. $x = encrypt('123456','55668899');
  28. $y = decrypt($x,'55668899');
  29. }
  30. public function testEqual()
  31. {
  32. $a = '1a';
  33. $r1 = $a == 1;
  34. $r2 = 1 == $a;
  35. $r3 = $a === 1;
  36. $r4 = 1 === $a;
  37. $r5 = '0' === 0;
  38. $t = intval($a);
  39. }
  40. public function testInArray()
  41. {
  42. $a = '1a';
  43. $b = [1,2,3,4,5];
  44. $t = in_array($a,$b);
  45. }
  46. public function testArrayKeyExists()
  47. {
  48. $a = '1a';
  49. $b = [1 => 2,3 => 4];
  50. $t = array_key_exists($a,$b);
  51. }
  52. }