TestFriends.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/7/14
  6. * Time: 下午4:22
  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/search/tcp_client.php');
  11. require_once(BASE_ROOT_PATH . '/helper/message/publisher.php');
  12. class TestFriends extends PHPUnit_Framework_TestCase
  13. {
  14. public static function setUpBeforeClass()
  15. {
  16. Base::run_util();
  17. }
  18. public function testAddFollow()
  19. {
  20. $result = search\relation_client::instance()->add_follow(array('user_id' => 36490,'friends'=>[1,2,3,4,5]));
  21. $result = search\relation_client::instance()->add_follow(array('user_id' => 36490,'friends'=>[3,4,5,6,7]));
  22. }
  23. public function testDelFollow()
  24. {
  25. $result = search\relation_client::instance()->del_follow(array('user_id' => 36490,'friends'=>[1]));
  26. $result = search\relation_client::instance()->del_follow(array('user_id' => 36490,'friends'=>[3,4]));
  27. }
  28. public function testFetchFollow()
  29. {
  30. for ($i =0 ; $i < 10000; ++$i) {
  31. $result = search\relation_client::instance()->fetch_follow(array('user_id' => 36490));
  32. }
  33. }
  34. public function testAddSpecial()
  35. {
  36. //for ($i =0 ; $i < 10000; ++$i)
  37. {
  38. // $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])));
  39. // $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])));
  40. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 7])));
  41. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 6])));
  42. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  43. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 17])));
  44. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 16])));
  45. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 19])));
  46. }
  47. }
  48. public function testDelSpecial()
  49. {
  50. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  51. $result = search\relation_client::instance()->del_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  52. }
  53. public function testFetchPub()
  54. {
  55. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => -1,'count'=> 10,'type' => 1]);
  56. for ($i =0 ; $i < 10000; ++$i)
  57. {
  58. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 1]);
  59. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 0]);
  60. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 0]);
  61. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 1]);
  62. }
  63. }
  64. //publisher
  65. public function testAddFriend()
  66. {
  67. $publisher = new message\publisher();
  68. $publisher->add_fellow(36490,[1,2,3,57]);
  69. }
  70. public function testDelFriend()
  71. {
  72. $publisher = new message\publisher();
  73. $publisher->del_fellow(36490,[1,2,3,57]);
  74. }
  75. public function testAddSpecials()
  76. {
  77. $publisher = new message\publisher();
  78. $publisher->add_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
  79. }
  80. public function testDelSpecials()
  81. {
  82. $publisher = new message\publisher();
  83. $publisher->del_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
  84. }
  85. public function testFetchSelfSpecials()
  86. {
  87. $result = search\relation_client::instance()->fetch_self_special(['user_id' => 39621,
  88. 'special_id' => -1,'count'=> 20,'type' => 1]);
  89. }
  90. }