TestRoomFactory.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. class TestRoomFactory extends PHPUnit_Framework_TestCase
  25. {
  26. const admin_member_id = 36429;
  27. public static function setUpBeforeClass()
  28. {
  29. Base::run_util();
  30. }
  31. public function testProcessorCreateChatwo()
  32. {
  33. }
  34. public function testProcessorCreateGroup()
  35. {
  36. $processor = new room\factory_processor();
  37. $creator = 36429;
  38. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => \room\proto_type::sroom_chat,'creator' => $creator,'invite' => true]));
  39. }
  40. public function testProcessorInvite()
  41. {
  42. $processor = new room\factory_processor();
  43. $roomid=30;
  44. $user = 36429;
  45. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
  46. $user = 36430;
  47. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
  48. }
  49. public function testProcessorCreateShake()
  50. {
  51. $processor = new room\factory_processor();
  52. $creator = 36429;
  53. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'shake_bonus','creator' => $creator]));
  54. }
  55. public function testFactoryCreateBargain()
  56. {
  57. $factory = new room\factory();
  58. $creator = 36477;
  59. $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];
  60. $factory->create($parms);
  61. }
  62. public function testFactoryBuildBargain()
  63. {
  64. $factory = new room\factory();
  65. $factory->build(43);
  66. }
  67. public function testProcessorCreateBargain()
  68. {
  69. $processor = new room\factory_processor();
  70. $creator = 36483;
  71. $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'bargain_goods','creator' => $creator,
  72. 'goods_id' => 4831,'lowest_price' => 10,'usable_days' => 3,'random' => 1,'total_num' => 10]));
  73. }
  74. public function testInvite()
  75. {
  76. $processor = new room\factory_processor();
  77. $req = ["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => 30,'inviter' => $this->creator(30),'invitees' => [36500]];
  78. $ret = $processor->onRequest(0,json_encode($req));
  79. }
  80. public function testAccessWho()
  81. {
  82. $processor = new room\factory_processor();
  83. $req = ["act" => room\proto_type::act_access,'op' => 'who'];
  84. $ret = $processor->onRequest(0,json_encode($req));
  85. }
  86. public function testCreateChatroom()
  87. {
  88. $ret = room\factory_client::instance()->create_chat(self::admin_member_id);
  89. $room = $ret['room'];
  90. $ret = room\factory_client::instance()->invite($room,self::admin_member_id,[39625]);
  91. }
  92. public function testInviteChatroom()
  93. {
  94. $ret = room\factory_client::instance()->invite(194,self::admin_member_id,[39611]);
  95. }
  96. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  97. public function testSocketInvite()
  98. {
  99. $user = 39623;
  100. for ($i = 0; $i < 10000000; $i++) {
  101. $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
  102. }
  103. }
  104. public function testSocketCreate()
  105. {
  106. $user = 39623;
  107. for ($i = 0; $i < 100000; $i++) {
  108. $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
  109. }
  110. }
  111. public function testShakeBonus()
  112. {
  113. $ret = room\factory_client::instance()->create_shake(self::admin_member_id);
  114. }
  115. public function testPush()
  116. {
  117. $ret = room\factory_client::instance()->notice_all(0,'hello world');
  118. }
  119. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  120. public function testAccess()
  121. {
  122. $ret = room\factory_client::instance()->notice_all('hello world');
  123. }
  124. public function testNoticeRoom()
  125. {
  126. $ret = room\factory_client::instance()->notice_room(291,\room\proto_type::msg_stype_donate,['user' => 39653,'steps' => 100,'amount' => 1]);
  127. }
  128. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  129. private function creator($room_id)
  130. {
  131. $mod_room = Model('room');
  132. $params = $mod_room->getRoom($room_id);
  133. $rinfo = new room\room_info($params);
  134. return $rinfo->creator();
  135. }
  136. public function testNotifyCommand()
  137. {
  138. // room\pusher::instance()->new_friend(39623,36505);
  139. room\pusher::instance()->new_friend(39674,39623);
  140. }
  141. public function testApplyFriend()
  142. {
  143. room\pusher::instance()->apply_friend(39689,39623,'我是你叔叔');
  144. room\pusher::instance()->apply_friend(39689,39674,'我是你叔叔');
  145. }
  146. }