TestRoomFactory.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/12/14
  6. * Time: 下午4:59
  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/event_looper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
  12. require_once(BASE_ROOT_PATH . '/helper/room/factory_processor.php');
  13. require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
  14. require_once(BASE_ROOT_PATH . '/helper/room/room_info.php');
  15. require_once(BASE_ROOT_PATH . '/helper/room/msg_builder.php');
  16. require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
  17. require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
  18. require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
  19. require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
  20. require_once(BASE_ROOT_PATH . '/helper/room/shake_room.php');
  21. require_once(BASE_ROOT_PATH . '/helper/room/factory.php');
  22. require_once(BASE_ROOT_PATH . '/helper/room/room_client.php');
  23. require_once(BASE_ROOT_PATH . '/helper/room/factory_client.php');
  24. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  25. class TestRoomFactory extends PHPUnit_Framework_TestCase
  26. {
  27. const admin_member_id = 36429;
  28. public static function setUpBeforeClass()
  29. {
  30. Base::run_util();
  31. }
  32. public function testProcessorCreateChatwo()
  33. {
  34. }
  35. public function testProcessorCreateGroup()
  36. {
  37. $processor = new room\factory_processor();
  38. $creator = 36429;
  39. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => \room\proto_type::sroom_chat,'creator' => $creator,'invite' => true]));
  40. }
  41. public function testProcessorInvite()
  42. {
  43. $processor = new room\factory_processor();
  44. $roomid=30;
  45. $user = 36429;
  46. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
  47. $user = 36430;
  48. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
  49. }
  50. public function testProcessorCreateShake()
  51. {
  52. $processor = new room\factory_processor();
  53. $creator = 36429;
  54. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'shake_bonus','creator' => $creator]));
  55. }
  56. public function testFactoryCreateBargain()
  57. {
  58. $factory = new room\factory();
  59. $creator = 36477;
  60. $parms = ["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'bargain_goods','creator' => $creator,'goods_id' => 4831,'lowest_price' => 10,'usable_days' => 3,'random' => 1,'total_num' => 10];
  61. $factory->create($parms);
  62. }
  63. public function testFactoryBuildBargain()
  64. {
  65. $factory = new room\factory();
  66. $factory->build(43);
  67. }
  68. public function testProcessorCreateBargain()
  69. {
  70. $processor = new room\factory_processor();
  71. $creator = 36483;
  72. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'bargain_goods','creator' => $creator,
  73. 'goods_id' => 4831,'lowest_price' => 10,'usable_days' => 3,'random' => 1,'total_num' => 10]));
  74. }
  75. public function testInvite()
  76. {
  77. $processor = new room\factory_processor();
  78. $req = ["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => 30,'inviter' => $this->creator(30),'invitees' => [36500]];
  79. $ret = $processor->onRequest(0,json_encode($req));
  80. }
  81. public function testAccessWho()
  82. {
  83. $processor = new room\factory_processor();
  84. $req = ["act" => room\proto_type::act_access,'op' => 'who'];
  85. $ret = $processor->onRequest(0,json_encode($req));
  86. }
  87. public function testCreateChatroom()
  88. {
  89. $ret = room\factory_client::instance()->create_chat(self::admin_member_id);
  90. $room = $ret['room'];
  91. $ret = room\factory_client::instance()->invite($room,self::admin_member_id,[39625]);
  92. }
  93. public function testInviteChatroom()
  94. {
  95. $ret = room\factory_client::instance()->invite(194,self::admin_member_id,[39611]);
  96. }
  97. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  98. public function testSocketInvite()
  99. {
  100. $user = 39623;
  101. for ($i = 0; $i < 10000000; $i++) {
  102. $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
  103. }
  104. }
  105. public function testSocketCreate()
  106. {
  107. $user = 39623;
  108. for ($i = 0; $i < 100000; $i++) {
  109. $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
  110. }
  111. }
  112. public function testShakeBonus()
  113. {
  114. $ret = room\factory_client::instance()->create_shake(self::admin_member_id);
  115. }
  116. public function testPush()
  117. {
  118. $ret = room\factory_client::instance()->notice_all(0,'hello world');
  119. }
  120. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  121. public function testAccess()
  122. {
  123. $ret = room\factory_client::instance()->notice_all('hello world');
  124. }
  125. public function testNoticeRoom()
  126. {
  127. $ret = room\factory_client::instance()->notice_room(291,0,room\proto_type::msg_stype_donate,['user' => 39653,'steps' => 100,'amount' => 1]);
  128. $ret = room\factory_client::instance()->notice_room(291,39668,room\proto_type::msg_stype_text,'你被除名啦~');
  129. }
  130. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  131. private function creator($room_id)
  132. {
  133. $mod_room = Model('room');
  134. $params = $mod_room->getRoom($room_id);
  135. $rinfo = new room\room_info($params);
  136. return $rinfo->creator();
  137. }
  138. public function testNotifyCommand()
  139. {
  140. room\pusher::instance()->new_friend(39674,39623);
  141. }
  142. public function testApplyFriend()
  143. {
  144. room\pusher::instance()->apply_friend(39689,39623,'我是你叔叔');
  145. room\pusher::instance()->apply_friend(39689,39674,'我是你叔叔');
  146. room\pusher::instance()->apply_friend(39674,39623,'我是你叔叔');
  147. room\pusher::instance()->apply_friend(39674,39689,'我是你叔叔');
  148. }
  149. public function testSysNotice()
  150. {
  151. $to_info = new member_info(39668);
  152. $from_info = new member_info(39689);
  153. $amount = 10;
  154. $name = $from_info->nickname();
  155. $text = "{$name}的{$amount}元的红包,在向您飞来~.";
  156. $from = ['nickname' => $from_info->nickname(),'avatar' => $from_info->avatar(),'userid' => $from_info->member_id()];
  157. $shema = schema_helper::bonus_detail('66091537352685812141');
  158. $content = ['type' => 'fly_bonus','from' => $from,'amount' => $amount,'schema' => $shema,'note' => "{$name}摇飞了{$amount}元红包,到你账户."];
  159. room\factory_client::instance()->notice_users([$to_info->member_id()],room\proto_type::push_notify,$content,$text);
  160. }
  161. public function testDownavatar()
  162. {
  163. $y = http_request('http://thirdwx.qlogo.cn/mmopen/vi_32/EgmJg53YibXlPKrz0DydiciaA1VicJI5iariaKqJgdodFFmdb38zqY1QkF5CSaXiacqfPdfMqWZwYvTDd1ialUiaVmX9BpA/132');
  164. $contents = file_get_contents('http://thirdwx.qlogo.cn/mmopen/vi_32/EgmJg53YibXlPKrz0DydiciaA1VicJI5iariaKqJgdodFFmdb38zqY1QkF5CSaXiacqfPdfMqWZwYvTDd1ialUiaVmX9BpA/132');
  165. }
  166. public function testTalks()
  167. {
  168. $x = json_encode('');
  169. $x = urlencode(base64_encode($x));
  170. $params = ['act' => 'member_talk','op' => 'talks','cmp_table' => $x,'HPHPSESSID' => 'd6mgs9lvi5md0o6k6vgv404bs3','client_type' => 'ios'];
  171. $y = https_request('https://passport.lrlz.com/mobile/index.php',$params,'POST',false,['client_type' => 'ios']);
  172. }
  173. public function testKickout()
  174. {
  175. room\pusher::instance()->kick_room(100,38671);
  176. }
  177. }