Changeset 9561 for trunk/tests/phpunit/testcases/activity/functions.php
- Timestamp:
- 02/27/2015 03:00:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/activity/functions.php
r9194 r9561 4 4 */ 5 5 class BP_Tests_Activity_Functions extends BP_UnitTestCase { 6 protected $old_current_user = 0;7 8 public function setUp() {9 parent::setUp();10 11 $this->old_current_user = get_current_user_id();12 $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );13 }14 15 public function tearDown() {16 parent::tearDown();17 $this->set_current_user( $this->old_current_user );18 }19 6 20 7 /** … … 915 902 */ 916 903 public function test_bp_activity_new_comment_clear_comment_caches() { 917 $a1 = $this->factory->activity->create(); 904 $u = $this->factory->user->create(); 905 $a1 = $this->factory->activity->create( array( 906 'user_id' => $u, 907 ) ); 918 908 $a2 = bp_activity_new_comment( array( 919 909 'activity_id' => $a1, 920 910 'parent_id' => $a1, 921 911 'content' => 'foo', 922 'user_id' => 1,912 'user_id' => $u, 923 913 ) ); 924 914 $a3 = bp_activity_new_comment( array( … … 926 916 'parent_id' => $a2, 927 917 'content' => 'foo', 928 'user_id' => 1,918 'user_id' => $u, 929 919 ) ); 930 920 $a4 = bp_activity_new_comment( array( … … 932 922 'parent_id' => $a3, 933 923 'content' => 'foo', 934 'user_id' => 1,924 'user_id' => $u, 935 925 ) ); 936 926 $a5 = bp_activity_new_comment( array( … … 938 928 'parent_id' => $a3, 939 929 'content' => 'foo', 940 'user_id' => 1,930 'user_id' => $u, 941 931 ) ); 942 932 … … 954 944 'parent_id' => $a4, 955 945 'content' => 'foo', 956 'user_id' => 1,946 'user_id' => $u, 957 947 ) ); 958 948 … … 966 956 */ 967 957 public function test_bp_activity_new_comment_clear_activity_caches() { 968 $a1 = $this->factory->activity->create(); 958 $u = $this->factory->user->create(); 959 $a1 = $this->factory->activity->create( array( 960 'user_id' => $u, 961 ) ); 969 962 $a2 = bp_activity_new_comment( array( 970 963 'activity_id' => $a1, 971 964 'parent_id' => $a1, 972 965 'content' => 'foo', 973 'user_id' => 1,966 'user_id' => $u, 974 967 ) ); 975 968 $a3 = bp_activity_new_comment( array( … … 977 970 'parent_id' => $a2, 978 971 'content' => 'foo', 979 'user_id' => 1,972 'user_id' => $u, 980 973 ) ); 981 974 $a4 = bp_activity_new_comment( array( … … 983 976 'parent_id' => $a3, 984 977 'content' => 'foo', 985 'user_id' => 1,978 'user_id' => $u, 986 979 ) ); 987 980 $a5 = bp_activity_new_comment( array( … … 989 982 'parent_id' => $a3, 990 983 'content' => 'foo', 991 'user_id' => 1,984 'user_id' => $u, 992 985 ) ); 993 986 … … 1021 1014 'parent_id' => $a4, 1022 1015 'content' => 'foo', 1023 'user_id' => 1,1016 'user_id' => $u, 1024 1017 ) ); 1025 1018 … … 1035 1028 */ 1036 1029 public function test_bp_activity_delete_comment_clear_cache() { 1030 $u = $this->factory->user->create(); 1037 1031 // add new activity update and comment to this update 1038 $a1 = $this->factory->activity->create(); 1032 $a1 = $this->factory->activity->create( array( 1033 'user_id' => $u, 1034 ) ); 1039 1035 $a2 = bp_activity_new_comment( array( 1040 1036 'activity_id' => $a1, 1041 1037 'parent_id' => $a1, 1042 1038 'content' => 'foo', 1043 'user_id' => 1,1039 'user_id' => $u, 1044 1040 ) ); 1045 1041 … … 1062 1058 */ 1063 1059 public function test_bp_activity_comment_on_deleted_activity() { 1060 $u = $this->factory->user->create(); 1064 1061 $a = $this->factory->activity->create(); 1065 1062 … … 1070 1067 'parent_id' => $a, 1071 1068 'content' => 'foo', 1072 'user_id' => 1,1069 'user_id' => $u, 1073 1070 ) ); 1074 1071 … … 1083 1080 $u = $this->factory->user->create(); 1084 1081 $a = $this->factory->activity->create(); 1082 1083 // bp_activity_add_user_favorite() requires a logged-in user. 1084 $current_user = bp_loggedin_user_id(); 1085 $this->set_current_user( $u ); 1085 1086 1086 1087 $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) ); … … 1089 1090 $this->assertSame( array( $a ), bp_activity_get_user_favorites( $u ) ); 1090 1091 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 1092 1093 $this->set_current_user( $current_user ); 1091 1094 } 1092 1095 … … 1098 1101 $u = $this->factory->user->create(); 1099 1102 $a = $this->factory->activity->create(); 1103 1104 // bp_activity_add_user_favorite() requires a logged-in user. 1105 $current_user = bp_loggedin_user_id(); 1106 $this->set_current_user( $u ); 1100 1107 $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) ); 1108 1109 $this->set_current_user( $current_user ); 1101 1110 } 1102 1111 … … 1110 1119 $a = $this->factory->activity->create(); 1111 1120 1121 // bp_activity_add_user_favorite() requires a logged-in user. 1122 $current_user = bp_loggedin_user_id(); 1123 $this->set_current_user( $u1 ); 1124 1112 1125 // Only favorite for user 1 1113 1126 bp_activity_add_user_favorite( $a, $u1 ); … … 1116 1129 $this->assertFalse( bp_activity_remove_user_favorite( $a, $u2 ) ); 1117 1130 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 1131 1132 $this->set_current_user( $current_user ); 1118 1133 } 1119 1134
Note: See TracChangeset
for help on using the changeset viewer.