123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/7/14
- * Time: 下午4:22
- */
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
- require_once(BASE_ROOT_PATH . '/helper/message/publisher.php');
- class TestFriends extends PHPUnit_Framework_TestCase
- {
- public static function setUpBeforeClass()
- {
- Base::run_util();
- }
- public function testAddFollow()
- {
- $result = search\relation_client::instance()->add_follow(array('user_id' => 36490,'friends'=>[1,2,3,4,5]));
- $result = search\relation_client::instance()->add_follow(array('user_id' => 36490,'friends'=>[3,4,5,6,7]));
- }
- public function testDelFollow()
- {
- $result = search\relation_client::instance()->del_follow(array('user_id' => 36490,'friends'=>[1]));
- $result = search\relation_client::instance()->del_follow(array('user_id' => 36490,'friends'=>[3,4]));
- }
- public function testFetchFollow()
- {
- for ($i =0 ; $i < 10000; ++$i) {
- $result = search\relation_client::instance()->fetch_follow(array('user_id' => 36490));
- }
- }
- public function testAddSpecial()
- {
- //for ($i =0 ; $i < 10000; ++$i)
- {
- // $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3])));
- // $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 1, 'spid' =>5],['type' => 1,'spid' => 4],['type' => 0,'spid' => 7])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 7])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 6])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 17])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 16])));
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 19])));
- }
- }
- public function testDelSpecial()
- {
- $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
- $result = search\relation_client::instance()->del_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
- }
- public function testFetchPub()
- {
- $result = search\relation_client::instance()->fetch_pub_special(['special_id' => -1,'count'=> 10,'type' => 1]);
- for ($i =0 ; $i < 10000; ++$i)
- {
- $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 1]);
- $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 0]);
- $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 0]);
- $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 1]);
- }
- }
- //publisher
- public function testAddFriend()
- {
- $publisher = new message\publisher();
- $publisher->add_fellow(36490,[1,2,3,57]);
- }
- public function testDelFriend()
- {
- $publisher = new message\publisher();
- $publisher->del_fellow(36490,[1,2,3,57]);
- }
- public function testAddSpecials()
- {
- $publisher = new message\publisher();
- $publisher->add_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
- }
- public function testDelSpecials()
- {
- $publisher = new message\publisher();
- $publisher->del_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
- }
- public function testFetchSelfSpecials()
- {
- $result = search\relation_client::instance()->fetch_self_special(['user_id' => 39621,
- 'special_id' => -1,'count'=> 20,'type' => 1]);
- }
- }
|