TestSocket.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/6/25
  6. * Time: 下午4:00
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_ROOT_PATH . '/helper/relation_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
  12. class TestSocket extends PHPUnit_Framework_TestCase
  13. {
  14. public static function setUpBeforeClass()
  15. {
  16. Base::run_util();
  17. }
  18. public function testUpContacts()
  19. {
  20. // $datas = array('13911129867','13911129868','13911129869','13911129870','13911129870');
  21. // $jsData = json_encode($datas);
  22. // $jsData = urlencode($jsData);
  23. // session_helper::parse_contacts($jsData);
  24. }
  25. public function testSend()
  26. {
  27. $socket = stream_socket_client ("tcp://192.168.1.105:2000");
  28. $data = array('type' => 1,'keyword' => "美白");
  29. $data = serialize($data);
  30. $i = 0;
  31. while ($i < 10000) {
  32. $len = sprintf("%010d",strlen($data));
  33. stream_socket_sendto($socket,$len . $data);
  34. $i++;
  35. }
  36. stream_socket_shutdown($socket,STREAM_SHUT_RDWR);
  37. }
  38. public function testEAS()
  39. {
  40. $socket = stream_socket_client ("tcp://58.246.76.195:6888");
  41. $ret = fwrite($socket,'test usable');
  42. $tmp = fread($socket,1024);
  43. $y = $socket;
  44. }
  45. public function testLen()
  46. {
  47. $x = sprintf("%010d",500);
  48. $y = intval($x);
  49. $read = "";
  50. while ($read) {
  51. echo "erad";
  52. }
  53. }
  54. public function testImage()
  55. {
  56. $ret = getimagesize("http://192.168.0.200/data/upload/mobile/special/s0/s0_05300358745765788.png",$imginfo);
  57. }
  58. public function testActivity()
  59. {
  60. //require_once ('/Users/stanley-king/work/PHPProject/shopnc/mobile/control/activity.php');
  61. $x = 'http://a.lrlz.com/mobile/index.php?act=activity&amp;op=limit_entra';
  62. $y = htmlspecialchars_decode($x);
  63. $x = 'http://a.lrlz.com/mobile/index.php?act=activity&op=limit_entra';
  64. $y = htmlspecialchars($x);
  65. }
  66. public function testKeysort()
  67. {
  68. $data = array(10 => 3018.25,90 => 5623,30 => 5566);
  69. ksort($data);
  70. $xdata = $data;
  71. krsort($xdata);
  72. }
  73. public function testPath()
  74. {
  75. $path = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/shop/store/goods/6/6_05215748240985301_240.jpg';
  76. $info = pathinfo($path);
  77. }
  78. }