- Timestamp:
- 11/03/2024 06:19:06 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/activity/test-controller.php
r14026 r14070 32 32 */ 33 33 public function test_get_items() { 34 $this->bp::set_current_user( $this->user );34 wp_set_current_user( $this->user ); 35 35 36 36 $this->bp::factory()->activity->create_many( 3 ); … … 83 83 ); 84 84 85 $this->bp::set_current_user( $this->user );85 wp_set_current_user( $this->user ); 86 86 87 87 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 106 106 */ 107 107 public function test_get_items_with_invalid_type() { 108 $this->bp::set_current_user( $this->user );108 wp_set_current_user( $this->user ); 109 109 110 110 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 159 159 160 160 $u = static::factory()->user->create(); 161 $this->bp::set_current_user( $u );161 wp_set_current_user( $u ); 162 162 163 163 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 224 224 225 225 $u = static::factory()->user->create(); 226 $this->bp::set_current_user( $u );226 wp_set_current_user( $u ); 227 227 228 228 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 247 247 248 248 $u = static::factory()->user->create(); 249 $this->bp::set_current_user( $u );249 wp_set_current_user( $u ); 250 250 251 251 // Current user is $u. … … 308 308 309 309 $u = static::factory()->user->create(); 310 $this->bp::set_current_user( $u );310 wp_set_current_user( $u ); 311 311 312 312 // Current user is $u. … … 353 353 354 354 $u = static::factory()->user->create(); 355 $this->bp::set_current_user( $u );355 wp_set_current_user( $u ); 356 356 357 357 // Current user is $u. … … 413 413 414 414 $u = static::factory()->user->create(); 415 $this->bp::set_current_user( $this->user );415 wp_set_current_user( $this->user ); 416 416 417 417 $g1 = $this->bp::factory()->group->create( … … 435 435 ); 436 436 437 $this->bp::set_current_user( $u );437 wp_set_current_user( $u ); 438 438 439 439 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 461 461 462 462 $u = static::factory()->user->create(); 463 $this->bp::set_current_user( $this->user );463 wp_set_current_user( $this->user ); 464 464 465 465 $g2 = $this->bp::factory()->group->create( … … 483 483 ); 484 484 485 $this->bp::set_current_user( $u );485 wp_set_current_user( $u ); 486 486 487 487 $request = new WP_REST_Request( 'GET', $this->endpoint_url ); … … 509 509 510 510 $u = static::factory()->user->create(); 511 $this->bp::set_current_user( $u );511 wp_set_current_user( $u ); 512 512 513 513 // Current user is $u. … … 551 551 public function test_get_paginated_items() { 552 552 $u = static::factory()->user->create(); 553 $this->bp::set_current_user( $u );553 wp_set_current_user( $u ); 554 554 555 555 $a = $this->bp::factory()->activity->create( array( 'user_id' => $u ) ); … … 582 582 public function test_get_items_with_the_groups_scope() { 583 583 $u = static::factory()->user->create(); 584 $this->bp::set_current_user( $u );584 wp_set_current_user( $u ); 585 585 586 586 $component = buddypress()->groups->id; … … 634 634 */ 635 635 public function test_get_items_with_favorite() { 636 $this->bp::set_current_user( $this->user );636 wp_set_current_user( $this->user ); 637 637 638 638 $this->bp::factory()->activity->create_many( 2 ); … … 640 640 641 641 $u = static::factory()->user->create(); 642 $this->bp::set_current_user( $u );642 wp_set_current_user( $u ); 643 643 644 644 bp_activity_add_user_favorite( $a1, $u ); … … 660 660 public function test_get_items_with_no_favorite() { 661 661 $u = static::factory()->user->create(); 662 $this->bp::set_current_user( $u );662 wp_set_current_user( $u ); 663 663 664 664 $this->bp::factory()->activity->create_many( 3, array( 'user_id' => $u ) ); … … 683 683 */ 684 684 public function test_get_item() { 685 $this->bp::set_current_user( $this->user );685 wp_set_current_user( $this->user ); 686 686 687 687 $activity = $this->endpoint->get_activity_object( $this->activity_id ); … … 722 722 $u1 = static::factory()->user->create(); 723 723 724 $this->bp::set_current_user( $u1 );724 wp_set_current_user( $u1 ); 725 725 726 726 $g1 = $this->bp::factory()->group->create( … … 767 767 ); 768 768 769 $this->bp::set_current_user( $u2 );769 wp_set_current_user( $u2 ); 770 770 771 771 $a1 = $this->bp::factory()->activity->create( … … 800 800 ); 801 801 802 $this->bp::set_current_user( $u2 );802 wp_set_current_user( $u2 ); 803 803 804 804 $a1 = $this->bp::factory()->activity->create( … … 845 845 846 846 // Non-authenticated. 847 $this->bp::set_current_user( 0 );847 wp_set_current_user( 0 ); 848 848 $response = $this->server->dispatch( $request ); 849 849 $this->assertEquals( 401, $response->get_status() ); … … 851 851 // Not a member of the group. 852 852 $u = static::factory()->user->create(); 853 $this->bp::set_current_user( $u );853 wp_set_current_user( $u ); 854 854 855 855 $response = $this->server->dispatch( $request ); … … 873 873 */ 874 874 public function test_render_item() { 875 $this->bp::set_current_user( $this->user );875 wp_set_current_user( $this->user ); 876 876 877 877 $a = $this->bp::factory()->activity->create( … … 895 895 */ 896 896 public function test_render_item_with_embed_post() { 897 $this->bp::set_current_user( $this->user );897 wp_set_current_user( $this->user ); 898 898 $p = static::factory()->post->create(); 899 899 … … 918 918 */ 919 919 public function test_create_item() { 920 $this->bp::set_current_user( $this->user );920 wp_set_current_user( $this->user ); 921 921 922 922 $request = new WP_REST_Request( 'POST', $this->endpoint_url ); … … 935 935 */ 936 936 public function test_rest_create_item() { 937 $this->bp::set_current_user( $this->user );937 wp_set_current_user( $this->user ); 938 938 939 939 $request = new WP_REST_Request( 'POST', $this->endpoint_url ); … … 952 952 */ 953 953 public function test_create_item_with_no_content() { 954 $this->bp::set_current_user( $this->user );954 wp_set_current_user( $this->user ); 955 955 956 956 $request = new WP_REST_Request( 'POST', $this->endpoint_url ); … … 984 984 */ 985 985 public function test_create_item_in_a_group() { 986 $this->bp::set_current_user( $this->user );986 wp_set_current_user( $this->user ); 987 987 $g = $this->bp::factory()->group->create( 988 988 array( … … 1012 1012 */ 1013 1013 public function test_create_item_in_a_private_group() { 1014 $this->bp::set_current_user( $this->user );1014 wp_set_current_user( $this->user ); 1015 1015 $g = $this->bp::factory()->group->create( 1016 1016 array( … … 1041 1041 */ 1042 1042 public function test_create_item_in_an_hidden_group() { 1043 $this->bp::set_current_user( $this->user );1043 wp_set_current_user( $this->user ); 1044 1044 $g = $this->bp::factory()->group->create( 1045 1045 array( … … 1070 1070 */ 1071 1071 public function test_create_item_and_get_comment() { 1072 $this->bp::set_current_user( $this->user );1072 wp_set_current_user( $this->user ); 1073 1073 1074 1074 $a = $this->bp::factory()->activity->create( … … 1082 1082 $u = static::factory()->user->create(); 1083 1083 1084 $this->bp::set_current_user( $u );1084 wp_set_current_user( $u ); 1085 1085 1086 1086 $request = new WP_REST_Request( 'POST', $this->endpoint_url ); … … 1143 1143 ); 1144 1144 1145 $this->bp::set_current_user( $u );1145 wp_set_current_user( $u ); 1146 1146 1147 1147 // Add a reply to c … … 1187 1187 */ 1188 1188 public function test_create_item_and_get_comment_in_a_group() { 1189 $this->bp::set_current_user( $this->user );1189 wp_set_current_user( $this->user ); 1190 1190 1191 1191 $g = $this->bp::factory()->group->create( … … 1206 1206 $u = static::factory()->user->create(); 1207 1207 1208 $this->bp::set_current_user( $u );1208 wp_set_current_user( $u ); 1209 1209 groups_join_group( $g, $u ); 1210 1210 … … 1248 1248 */ 1249 1249 public function test_create_item_with_no_content_in_a_group() { 1250 $this->bp::set_current_user( $this->user );1250 wp_set_current_user( $this->user ); 1251 1251 $g = $this->bp::factory()->group->create( 1252 1252 array( … … 1277 1277 */ 1278 1278 public function test_create_blog_post_item() { 1279 $this->bp::set_current_user( $this->user );1279 wp_set_current_user( $this->user ); 1280 1280 $p = static::factory()->post->create(); 1281 1281 … … 1320 1320 */ 1321 1321 public function test_update_item() { 1322 $this->bp::set_current_user( $this->user );1322 wp_set_current_user( $this->user ); 1323 1323 1324 1324 $activity = $this->endpoint->get_activity_object( $this->activity_id ); … … 1352 1352 $activity_id = $this->bp::factory()->activity->create( array( 'recorded_time' => $activity_date ) ); 1353 1353 1354 $this->bp::set_current_user( $this->user );1354 wp_set_current_user( $this->user ); 1355 1355 1356 1356 $request = new WP_REST_Request( 'PUT', sprintf( $this->endpoint_url . '/%d', $activity_id ) ); … … 1374 1374 */ 1375 1375 public function test_update_item_posted_in_a_group() { 1376 $this->bp::set_current_user( $this->user );1376 wp_set_current_user( $this->user ); 1377 1377 1378 1378 $g = $this->bp::factory()->group->create( … … 1425 1425 */ 1426 1426 public function test_update_item_invalid_id() { 1427 $this->bp::set_current_user( $this->user );1427 wp_set_current_user( $this->user ); 1428 1428 1429 1429 $request = new WP_REST_Request( 'PUT', sprintf( $this->endpoint_url . '/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) ); … … 1461 1461 1462 1462 $u2 = static::factory()->user->create(); 1463 $this->bp::set_current_user( $u2 );1463 wp_set_current_user( $u2 ); 1464 1464 1465 1465 $activity = $this->endpoint->get_activity_object( $a ); … … 1484 1484 $a = $this->bp::factory()->activity->create( array( 'user_id' => $u ) ); 1485 1485 1486 $this->bp::set_current_user( $u );1486 wp_set_current_user( $u ); 1487 1487 1488 1488 $activity = $this->endpoint->get_activity_object( $a ); … … 1506 1506 $a = $this->bp::factory()->activity->create( array( 'user_id' => $u ) ); 1507 1507 1508 $this->bp::set_current_user( $u );1508 wp_set_current_user( $u ); 1509 1509 1510 1510 $activity = $this->endpoint->get_activity_object( $a ); … … 1528 1528 */ 1529 1529 public function test_delete_item() { 1530 $this->bp::set_current_user( $this->user );1530 wp_set_current_user( $this->user ); 1531 1531 1532 1532 $activity_id = $this->bp::factory()->activity->create( … … 1556 1556 */ 1557 1557 public function test_delete_item_invalid_id() { 1558 $this->bp::set_current_user( $this->user );1558 wp_set_current_user( $this->user ); 1559 1559 1560 1560 $request = new WP_REST_Request( 'DELETE', sprintf( $this->endpoint_url . '/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) ); … … 1587 1587 1588 1588 $u2 = static::factory()->user->create(); 1589 $this->bp::set_current_user( $u2 );1589 wp_set_current_user( $u2 ); 1590 1590 1591 1591 $activity = $this->endpoint->get_activity_object( $activity_id ); … … 1610 1610 1611 1611 $u = static::factory()->user->create(); 1612 $this->bp::set_current_user( $u );1612 wp_set_current_user( $u ); 1613 1613 1614 1614 $request = new WP_REST_Request( 'PUT', sprintf( $this->endpoint_url . '/%d/favorite', $a ) ); … … 1638 1638 1639 1639 $u = static::factory()->user->create(); 1640 $this->bp::set_current_user( $u );1640 wp_set_current_user( $u ); 1641 1641 1642 1642 bp_activity_add_user_favorite( $a, $u ); … … 1664 1664 1665 1665 $u = static::factory()->user->create(); 1666 $this->bp::set_current_user( $u );1666 wp_set_current_user( $u ); 1667 1667 1668 1668 add_filter( 'bp_activity_can_favorite', '__return_false' ); … … 1679 1679 1680 1680 public function test_prepare_item() { 1681 $this->bp::set_current_user( $this->user );1681 wp_set_current_user( $this->user ); 1682 1682 1683 1683 $activity = $this->endpoint->get_activity_object( $this->activity_id ); … … 1716 1716 ); 1717 1717 1718 $this->bp::set_current_user( $this->user );1718 wp_set_current_user( $this->user ); 1719 1719 $expected = 'bar_value'; 1720 1720 … … 1760 1760 ); 1761 1761 1762 $this->bp::set_current_user( $this->user );1762 wp_set_current_user( $this->user ); 1763 1763 $expected = 'foo_value'; 1764 1764 $a_id = $this->bp::factory()->activity->create();
Note: See TracChangeset
for help on using the changeset viewer.