123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?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');
- 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,\room\proto_type::msg_stype_donate,['user' => 39653,'steps' => 100,'amount' => 1]);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- 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(39623,36505);
- room\pusher::instance()->new_friend(39674,39623);
- }
- public function testApplyFriend()
- {
- room\pusher::instance()->apply_friend(39689,39623,'我是你叔叔');
- room\pusher::instance()->apply_friend(39689,39674,'我是你叔叔');
- }
- }
|