TestFriends.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 7])));
  37. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 6])));
  38. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  39. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 17])));
  40. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 16])));
  41. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 19])));
  42. }
  43. public function testDelSpecial()
  44. {
  45. $result = search\relation_client::instance()->add_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  46. $result = search\relation_client::instance()->del_special(array('user_id' => 36490,'specials'=>array(['type' => 0,'spid' => 9])));
  47. }
  48. public function testFetchPub()
  49. {
  50. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => -1,'count'=> 1000,'type' => 1]);
  51. for ($i =0 ; $i < 10000; ++$i)
  52. {
  53. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 1]);
  54. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 11,'count'=> 10,'type' => 0]);
  55. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 0]);
  56. $result = search\relation_client::instance()->fetch_pub_special(['special_id' => 9,'count'=> 10,'type' => 1]);
  57. }
  58. }
  59. //publisher
  60. public function testAddFriend()
  61. {
  62. $publisher = new message\publisher();
  63. $publisher->add_fellow(36490,[1,2,3,57]);
  64. }
  65. public function testDelFriend()
  66. {
  67. $publisher = new message\publisher();
  68. $publisher->del_fellow(36490,[1,2,3,57]);
  69. }
  70. public function testAddSpecials()
  71. {
  72. $publisher = new message\publisher();
  73. $publisher->add_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
  74. }
  75. public function testDelSpecials()
  76. {
  77. $publisher = new message\publisher();
  78. $publisher->del_special(36490,array(['type' => 1, 'spid' =>1],['type' => 1,'spid' => 2],['type' => 1,'spid' => 3]));
  79. }
  80. public function testFetchSelfSpecials()
  81. {
  82. $result = search\relation_client::instance()->fetch_self_special(['user_id' => 39621,
  83. 'special_id' => -1,'count'=> 20,'type' => 1]);
  84. }
  85. }