Changeset 9561
- Timestamp:
- 02/27/2015 03:00:42 AM (10 years ago)
- Location:
- trunk/tests/phpunit/testcases
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/activity/actions.php
r9486 r9561 4 4 */ 5 5 class BP_Tests_Activity_Actions 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 /** -
trunk/tests/phpunit/testcases/activity/class.BP_Activity_Activity.php
r9139 r9561 4 4 */ 5 5 class BP_Tests_Activity_Class 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(13 'role' => 'subscriber',14 ) ) );15 }16 17 public function tearDown() {18 parent::tearDown();19 $this->set_current_user( $this->old_current_user );20 }21 6 22 7 /** … … 259 244 */ 260 245 public function test_get_with_display_comments_threaded() { 246 $u = $this->factory->user->create(); 247 261 248 $now = time(); 262 249 $a1 = $this->factory->activity->create( array( 250 'user_id' => $u, 263 251 'content' => 'Life Rules', 264 252 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 265 253 ) ); 266 254 $a2 = $this->factory->activity->create( array( 255 'user_id' => $u, 267 256 'content' => 'Life Drools', 268 257 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 269 258 ) ); 270 259 $a3 = bp_activity_new_comment( array( 260 'user_id' => $u, 271 261 'activity_id' => $a1, 272 262 'content' => 'Candy is good', -
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 -
trunk/tests/phpunit/testcases/activity/template.php
r9475 r9561 4 4 */ 5 5 class BP_Tests_Activity_Template 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 /** … … 23 10 public function test_user_can_delete() { 24 11 $bp = buddypress(); 12 $u = $this->factory->user->create(); 13 $original_user = bp_loggedin_user_id(); 14 $this->set_current_user( $u ); 25 15 26 16 $a = $this->factory->activity->create( array( 27 17 'type' => 'activity_update', 18 'user_id' => $u, 28 19 ) ); 29 20 … … 31 22 $activity = $this->factory->activity->get_object_by_id( $a ); 32 23 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 33 34 // Stash original user35 $original_user = get_current_user_id();36 24 37 25 // Logged-out user can't delete … … 107 95 ) ); 108 96 97 $current_user = bp_loggedin_user_id(); 98 $this->set_current_user( $user_id ); 99 109 100 bp_activity_add_user_favorite( $a1, $user_id ); 110 101 bp_activity_add_user_favorite( $a2, $user_id ); 102 103 $this->set_current_user( $current_user ); 111 104 112 105 // groan. It sucks that you have to invoke the global … … 1224 1217 add_filter( 'bp_disable_blogforum_comments', '__return_false' ); 1225 1218 1219 $u = $this->factory->user->create(); 1220 1226 1221 $now = time(); 1227 1222 $a1 = $this->factory->activity->create( array( … … 1230 1225 'type' => 'new_blog_post', 1231 1226 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1227 'user_id' => $u, 1232 1228 ) ); 1233 1229 $a2 = $this->factory->activity->create( array( … … 1236 1232 'type' => 'new_blog_comment', 1237 1233 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1234 'user_id' => $u, 1238 1235 ) ); 1239 1236 … … 1244 1241 'content' => 'Candy is good', 1245 1242 'recorded_time' => date( 'Y-m-d H:i:s', $now - 200 ), 1243 'user_id' => $u, 1246 1244 ) ); 1247 1245 … … 1251 1249 'type' => 'activity_update', 1252 1250 'recorded_time' => date( 'Y-m-d H:i:s', $now - 300 ), 1251 'user_id' => $u, 1253 1252 ) ); 1254 1253 … … 1259 1258 'content' => 'Candy is great', 1260 1259 'recorded_time' => date( 'Y-m-d H:i:s', $now - 400 ), 1260 'user_id' => $u, 1261 1261 ) ); 1262 1262 global $activities_template; -
trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php
r9354 r9561 6 6 */ 7 7 class BP_Tests_BP_Blogs_Blog_TestCases extends BP_UnitTestCase { 8 public function setUp() {9 parent::setUp();10 }11 12 public function tearDown() {13 parent::tearDown();14 }15 16 8 public function test_get_with_search_terms() { 17 9 if ( ! is_multisite() ) { -
trunk/tests/phpunit/testcases/core/avatars.php
r9455 r9561 5 5 */ 6 6 class BP_Tests_Avatars extends BP_UnitTestCase { 7 protected $old_current_user = 0;8 9 7 private $params = array(); 10 11 public function setUp() {12 parent::setUp();13 14 $this->old_current_user = get_current_user_id();15 $this->administrator = $this->factory->user->create( array( 'role' => 'administrator' ) );16 wp_set_current_user( $this->administrator );17 }18 19 public function tearDown() {20 parent::tearDown();21 wp_set_current_user( $this->old_current_user );22 }23 8 24 9 private function clean_existing_avatars( $type = 'user' ) { … … 59 44 } 60 45 46 $u = $this->factory->user->create(); 47 61 48 // get BP root blog's upload directory data 62 49 $upload_dir = wp_upload_dir(); … … 64 51 // create new subsite 65 52 $blog_id = $this->factory->blog->create( array( 66 'user_id' => $ this->administrator,53 'user_id' => $u, 67 54 'title' => 'Test Title', 68 55 'path' => '/path' . rand() . time() . '/', -
trunk/tests/phpunit/testcases/core/class-bp-button.php
r9139 r9561 6 6 */ 7 7 class BP_Tests_BP_Button extends BP_UnitTestCase { 8 protected $old_current_user;9 10 public function setUp() {11 $this->old_current_user = get_current_user_id();12 parent::setUp();13 }14 15 public function tearDown() {16 $this->set_current_user( $this->old_current_user );17 parent::tearDown();18 }19 20 8 /** 21 9 * @group block_self -
trunk/tests/phpunit/testcases/core/class-bp-core-user.php
r9139 r9561 6 6 */ 7 7 class BP_Tests_BP_Core_User_TestCases extends BP_UnitTestCase { 8 protected $old_current_user = 0;9 10 public function setUp() {11 parent::setUp();12 }13 14 public function tearDown() {15 parent::tearDown();16 }17 18 8 /** 19 9 * @expectedDeprecated BP_Core_User::get_users -
trunk/tests/phpunit/testcases/core/class-bp-user-query.php
r9533 r9561 6 6 */ 7 7 class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase { 8 protected $old_current_user = 0;9 10 public function setUp() {11 parent::setUp();12 13 $this->old_current_user = get_current_user_id();14 $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );15 }16 17 public function tearDown() {18 parent::tearDown();19 $this->set_current_user( $this->old_current_user );20 }21 22 8 /** 23 9 * Checks that user_id returns friends -
trunk/tests/phpunit/testcases/friends/class-bp-friends-friendship.php
r9525 r9561 5 5 */ 6 6 class BP_Tests_BP_Friends_Friendship_TestCases extends BP_UnitTestCase { 7 protected $old_current_user = 0;8 9 public function setUp() {10 parent::setUp();11 12 $this->old_current_user = get_current_user_id();13 $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );14 }15 16 public function tearDown() {17 parent::tearDown();18 $this->set_current_user( $this->old_current_user );19 }20 21 7 public function test_search_friends() { 22 8 $u1 = $this->factory->user->create(); -
trunk/tests/phpunit/testcases/friends/functions.php
r9173 r9561 12 12 parent::setUp(); 13 13 $this->filter_fired = ''; 14 }15 16 public function tearDown() {17 parent::tearDown();18 14 } 19 15 -
trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php
r9139 r9561 8 8 */ 9 9 class BP_Tests_Group_Extension_TestCases extends BP_UnitTestCase { 10 public function setUp() {11 parent::setUp();12 }13 14 public function tearDown() {15 parent::tearDown();16 }17 18 10 public function test_parse_legacy_properties() { 19 11 $class_name = 'BPTest_Group_Extension_Parse_Legacy_Properties'; -
trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php
r9139 r9561 5 5 */ 6 6 class BP_Tests_BP_Group_Member_Query_TestCases extends BP_UnitTestCase { 7 public function setUp() {8 $this->current_user = get_current_user_id();9 $this->set_current_user( 0 );10 parent::setUp();11 }12 13 public function tearDown() {14 $this->set_current_user( $this->current_user );15 parent::tearDown();16 }17 7 18 8 /** -
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r9483 r9561 5 5 */ 6 6 class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 7 15 8 /** __construct() ***************************************************/ -
trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php
r9300 r9561 5 5 */ 6 6 class BP_Tests_BP_Groups_Member_TestCases extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 15 7 public static function invite_user_to_group( $user_id, $group_id, $inviter_id ) { 16 8 $invite = new BP_Groups_Member; -
trunk/tests/phpunit/testcases/groups/functions.php
r9471 r9561 6 6 */ 7 7 class BP_Tests_Groups_Functions extends BP_UnitTestCase { 8 protected $old_current_user_id = 0;9 10 public function setUp() {11 parent::setUp();12 $this->old_current_user = get_current_user_id();13 }14 15 public function tearDown() {16 parent::tearDown();17 $this->set_current_user( $this->old_current_user );18 }19 20 8 public function test_creating_new_group_as_authenticated_user() { 21 9 $u = $this->factory->user->create(); -
trunk/tests/phpunit/testcases/groups/template.php
r9417 r9561 5 5 */ 6 6 class BP_Tests_Groups_Template extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 15 7 /** 16 8 * Integration test to make sure meta_query is getting passed through -
trunk/tests/phpunit/testcases/members/functions.php
r9471 r9561 4 4 */ 5 5 class BP_Tests_Members_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 /** -
trunk/tests/phpunit/testcases/members/template.php
r9417 r9561 4 4 */ 5 5 class BP_Tests_Members_Template 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 $new_user = $this->factory->user->create( array( 'role' => 'administrator' ) );13 $this->set_current_user( $new_user );14 15 }16 17 public function tearDown() {18 parent::tearDown();19 $this->set_current_user( $this->old_current_user );20 }21 22 6 public function test_bp_has_members_include_on_user_page() { 23 7 $u1 = $this->factory->user->create(); -
trunk/tests/phpunit/testcases/notifications/template.php
r9486 r9561 5 5 */ 6 6 class BP_Tests_Notifications_Template extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 15 7 /** 16 8 * @group pagination -
trunk/tests/phpunit/testcases/routing/anonymous.php
r8958 r9561 4 4 */ 5 5 class BP_Tests_Routing_Anonymous 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( 0 );13 }14 15 public function tearDown() {16 parent::tearDown();17 $this->set_current_user( $this->old_current_user );18 }19 20 6 function test_wordpress_page() { 21 7 $this->go_to( '/' ); -
trunk/tests/phpunit/testcases/routing/core.php
r8958 r9561 18 18 $this->set_current_user( $this->old_current_user ); 19 19 } 20 21 20 function test_wordpress_page() { 22 21 $this->go_to( '/' ); -
trunk/tests/phpunit/testcases/routing/url.php
r9364 r9561 4 4 */ 5 5 class BP_Tests_URL 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 20 6 function test_bp_core_ajax_url() { 21 7 $forced = force_ssl_admin(); -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php
r8958 r9561 5 5 */ 6 6 class BP_Tests_XProfile_Field_Type extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 15 7 public function test_unregistered_field_type_returns_textbox() { 16 8 $field = bp_xprofile_create_field_type( 'fakeyfield' ); -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php
r9324 r9561 5 5 */ 6 6 class BP_Tests_BP_XProfile_Field_TestCases extends BP_UnitTestCase { 7 public function setUp() {8 parent::setUp();9 }10 11 public function tearDown() {12 parent::tearDown();13 }14 15 7 public function test_can_delete_save() { 16 8 $group = $this->factory->xprofile_group->create(); -
trunk/tests/phpunit/testcases/xprofile/functions.php
r9139 r9561 6 6 */ 7 7 class BP_Tests_XProfile_Functions extends BP_UnitTestCase { 8 public function setUp() {9 parent::setUp();10 }11 12 public function tearDown() {13 parent::tearDown();14 }15 16 8 public function test_get_hidden_field_types_for_user_loggedout() { 17 9 $duser = $this->factory->user->create();
Note: See TracChangeset
for help on using the changeset viewer.