123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/12/14
- * Time: 下午4:59
- */
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/helper/event_looper.php');
- require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
- require_once(BASE_ROOT_PATH . '/helper/room/factory_processor.php');
- require_once(BASE_ROOT_PATH . '/helper/room/proto_type.php');
- require_once(BASE_ROOT_PATH . '/helper/room/room_info.php');
- require_once(BASE_ROOT_PATH . '/helper/room/msg_builder.php');
- require_once(BASE_ROOT_PATH . '/helper/room/base_room.php');
- require_once(BASE_ROOT_PATH . '/helper/room/chatwo.php');
- require_once(BASE_ROOT_PATH . '/helper/room/chat_room.php');
- require_once(BASE_ROOT_PATH . '/helper/room/bargain_room.php');
- require_once(BASE_ROOT_PATH . '/helper/room/shake_room.php');
- require_once(BASE_ROOT_PATH . '/helper/room/factory.php');
- require_once(BASE_ROOT_PATH . '/helper/room/room_client.php');
- require_once(BASE_ROOT_PATH . '/helper/room/factory_client.php');
- require_once(BASE_CORE_PATH . '/framework/function/http.php');
- class TestRoomFactory extends PHPUnit_Framework_TestCase
- {
- const admin_member_id = 36429;
- public static function setUpBeforeClass()
- {
- Base::run_util();
- }
- public function testProcessorCreateChatwo()
- {
- }
- public function testProcessorCreateGroup()
- {
- $processor = new room\factory_processor();
- $creator = 36429;
- $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => \room\proto_type::sroom_chat,'creator' => $creator,'invite' => true]));
- }
- public function testProcessorInvite()
- {
- $processor = new room\factory_processor();
- $roomid=30;
- $user = 36429;
- $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
- $user = 36430;
- $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => $roomid,'inviter' => $user,'invitees' => [36500]]));
- }
- public function testProcessorCreateShake()
- {
- $processor = new room\factory_processor();
- $creator = 36429;
- $ret = $processor->onRequest(0,json_encode(["act" => room\proto_type::act_fcgi,'op' => 'create', "type" => 'shake_bonus','creator' => $creator]));
- }
- public function testFactoryCreateBargain()
- {
- $factory = new room\factory();
- $creator = 36477;
- $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];
- $factory->create($parms);
- }
- public function testFactoryBuildBargain()
- {
- $factory = new room\factory();
- $factory->build(43);
- }
- public function testProcessorCreateBargain()
- {
- $processor = new room\factory_processor();
- $creator = 36483;
- $ret = $processor->onRequest(0,json_encode(["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]));
- }
- public function testInvite()
- {
- $processor = new room\factory_processor();
- $req = ["act" => room\proto_type::act_fcgi,'op' => 'invite','room' => 30,'inviter' => $this->creator(30),'invitees' => [36500]];
- $ret = $processor->onRequest(0,json_encode($req));
- }
- public function testAccessWho()
- {
- $processor = new room\factory_processor();
- $req = ["act" => room\proto_type::act_access,'op' => 'who'];
- $ret = $processor->onRequest(0,json_encode($req));
- }
- public function testCreateChatroom()
- {
- $ret = room\factory_client::instance()->create_chat(self::admin_member_id);
- $room = $ret['room'];
- $ret = room\factory_client::instance()->invite($room,self::admin_member_id,[39625]);
- }
- public function testInviteChatroom()
- {
- $ret = room\factory_client::instance()->invite(194,self::admin_member_id,[39611]);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function testSocketInvite()
- {
- $user = 39623;
- for ($i = 0; $i < 10000000; $i++) {
- $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
- }
- }
- public function testSocketCreate()
- {
- $user = 39623;
- for ($i = 0; $i < 100000; $i++) {
- $ret = room\factory_client::instance()->invite(37,self::admin_member_id,[$user]);
- }
- }
- public function testShakeBonus()
- {
- $ret = room\factory_client::instance()->create_shake(self::admin_member_id);
- }
- public function testPush()
- {
- $ret = room\factory_client::instance()->notice_all(0,'hello world');
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function testAccess()
- {
- $ret = room\factory_client::instance()->notice_all('hello world');
- }
- public function testNoticeRoom()
- {
- $ret = room\factory_client::instance()->notice_room(291,0,room\proto_type::msg_stype_donate,['user' => 39653,'steps' => 100,'amount' => 1]);
- $ret = room\factory_client::instance()->notice_room(291,39668,room\proto_type::msg_stype_text,'你被除名啦~');
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- private function creator($room_id)
- {
- $mod_room = Model('room');
- $params = $mod_room->getRoom($room_id);
- $rinfo = new room\room_info($params);
- return $rinfo->creator();
- }
- public function testNotifyCommand()
- {
- room\pusher::instance()->new_friend(39674,39623);
- }
- public function testApplyFriend()
- {
- room\pusher::instance()->apply_friend(39689,39623,'我是你叔叔');
- room\pusher::instance()->apply_friend(39689,39674,'我是你叔叔');
- room\pusher::instance()->apply_friend(39674,39623,'我是你叔叔');
- room\pusher::instance()->apply_friend(39674,39689,'我是你叔叔');
- }
- public function testSysNotice()
- {
- $to_info = new member_info(39668);
- $from_info = new member_info(39689);
- $amount = 10;
- $name = $from_info->nickname();
- $text = "{$name}的{$amount}元的红包,在向您飞来~.";
- $from = ['nickname' => $from_info->nickname(),'avatar' => $from_info->avatar(),'userid' => $from_info->member_id()];
- $shema = schema_helper::bonus_detail('66091537352685812141');
- $content = ['type' => 'fly_bonus','from' => $from,'amount' => $amount,'schema' => $shema,'note' => "{$name}摇飞了{$amount}元红包,到你账户."];
- room\factory_client::instance()->notice_users([$to_info->member_id()],room\proto_type::push_notify,$content,$text);
- }
- public function testDownavatar()
- {
- $y = http_request('http://thirdwx.qlogo.cn/mmopen/vi_32/EgmJg53YibXlPKrz0DydiciaA1VicJI5iariaKqJgdodFFmdb38zqY1QkF5CSaXiacqfPdfMqWZwYvTDd1ialUiaVmX9BpA/132');
- $contents = file_get_contents('http://thirdwx.qlogo.cn/mmopen/vi_32/EgmJg53YibXlPKrz0DydiciaA1VicJI5iariaKqJgdodFFmdb38zqY1QkF5CSaXiacqfPdfMqWZwYvTDd1ialUiaVmX9BpA/132');
- }
- public function testTalks()
- {
- $x = json_encode('');
- $x = urlencode(base64_encode($x));
- $params = ['act' => 'member_talk','op' => 'talks','cmp_table' => $x,'HPHPSESSID' => 'd6mgs9lvi5md0o6k6vgv404bs3','client_type' => 'ios'];
- $y = https_request('https://passport.lrlz.com/mobile/index.php',$params,'POST',false,['client_type' => 'ios']);
- }
- public function testKickout()
- {
- room\pusher::instance()->kick_room(100,38671);
- }
- }
|