Changeset 11737 for trunk/tests/phpunit/testcases/activity/functions.php
- Timestamp:
- 11/03/2017 07:44:10 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/activity/functions.php
r11583 r11737 28 28 29 29 // create an activity update 30 $activity = $this->factory->activity->create( array(30 $activity = self::factory()->activity->create( array( 31 31 'type' => 'activity_update' 32 32 ) ); … … 57 57 58 58 // create an activity update 59 $this->factory->activity->create( $criteria );60 $this->factory->activity->create( $criteria );61 $this->factory->activity->create( $criteria );62 $this->factory->activity->create( $criteria );59 self::factory()->activity->create( $criteria ); 60 self::factory()->activity->create( $criteria ); 61 self::factory()->activity->create( $criteria ); 62 self::factory()->activity->create( $criteria ); 63 63 64 64 // now delete the activity items … … 83 83 84 84 // create an activity update 85 $this->factory->activity->create( $criteria );86 $this->factory->activity->create( $criteria );87 $this->factory->activity->create( $criteria );88 $this->factory->activity->create( $criteria );85 self::factory()->activity->create( $criteria ); 86 self::factory()->activity->create( $criteria ); 87 self::factory()->activity->create( $criteria ); 88 self::factory()->activity->create( $criteria ); 89 89 90 90 // now delete the activity items … … 109 109 110 110 // create an activity update 111 $this->factory->activity->create( $criteria );112 $this->factory->activity->create( $criteria );113 $this->factory->activity->create( $criteria );114 $this->factory->activity->create( $criteria );111 self::factory()->activity->create( $criteria ); 112 self::factory()->activity->create( $criteria ); 113 self::factory()->activity->create( $criteria ); 114 self::factory()->activity->create( $criteria ); 115 115 116 116 // now delete the activity items … … 130 130 131 131 // create an activity update 132 $activity = $this->factory->activity->create( array(132 $activity = self::factory()->activity->create( array( 133 133 'type' => 'activity_update' 134 134 ) ); … … 153 153 154 154 // create an activity update 155 $activity = $this->factory->activity->create( array(155 $activity = self::factory()->activity->create( array( 156 156 'type' => 'activity_update' 157 157 ) ); … … 188 188 189 189 // create an activity update 190 $parent_activity = $this->factory->activity->create( array(190 $parent_activity = self::factory()->activity->create( array( 191 191 'type' => 'activity_update', 192 192 ) ); 193 193 194 194 // create some activity comments 195 $comment_one = $this->factory->activity->create( array(195 $comment_one = self::factory()->activity->create( array( 196 196 'type' => 'activity_comment', 197 197 'item_id' => $parent_activity, … … 199 199 ) ); 200 200 201 $comment_two = $this->factory->activity->create( array(201 $comment_two = self::factory()->activity->create( array( 202 202 'type' => 'activity_comment', 203 203 'item_id' => $parent_activity, … … 227 227 228 228 // create an activity update 229 $parent_activity = $this->factory->activity->create( array(229 $parent_activity = self::factory()->activity->create( array( 230 230 'type' => 'activity_update', 231 231 ) ); 232 232 233 233 // create some activity comments 234 $comment_one = $this->factory->activity->create( array(234 $comment_one = self::factory()->activity->create( array( 235 235 'type' => 'activity_comment', 236 236 'item_id' => $parent_activity, … … 238 238 ) ); 239 239 240 $comment_two = $this->factory->activity->create( array(240 $comment_two = self::factory()->activity->create( array( 241 241 'type' => 'activity_comment', 242 242 'item_id' => $parent_activity, … … 271 271 */ 272 272 public function test_bp_activity_update_meta_with_line_breaks() { 273 $a = $this->factory->activity->create();273 $a = self::factory()->activity->create(); 274 274 $meta_value = 'Foo! 275 275 … … 285 285 */ 286 286 public function test_bp_activity_update_meta_with_0() { 287 $a = $this->factory->activity->create();287 $a = self::factory()->activity->create(); 288 288 $meta_value = 0; 289 289 … … 307 307 */ 308 308 public function test_bp_activity_update_meta_with_illegal_key_characters() { 309 $a = $this->factory->activity->create();309 $a = self::factory()->activity->create(); 310 310 $krazy_key = ' f!@#$%^o *(){}o?+'; 311 311 bp_activity_update_meta( $a, $krazy_key, 'bar' ); … … 319 319 */ 320 320 public function test_bp_activity_update_meta_stripslashes() { 321 $a = $this->factory->activity->create();321 $a = self::factory()->activity->create(); 322 322 $value = "This string is totally slashin\'!"; 323 323 bp_activity_update_meta( $a, 'foo', $value ); … … 331 331 */ 332 332 public function test_bp_activity_update_meta_false_value_deletes() { 333 $a = $this->factory->activity->create();333 $a = self::factory()->activity->create(); 334 334 bp_activity_update_meta( $a, 'foo', false ); 335 335 $this->assertSame( '', bp_activity_get_meta( $a, 'foo' ) ); … … 341 341 */ 342 342 public function test_bp_activity_update_meta_new() { 343 $a = $this->factory->activity->create();343 $a = self::factory()->activity->create(); 344 344 $this->assertSame( '', bp_activity_get_meta( $a, 'foo' ), '"foo" meta should be empty for this activity item.' ); 345 345 $this->assertNotEmpty( bp_activity_update_meta( $a, 'foo', 'bar' ) ); … … 352 352 */ 353 353 public function test_bp_activity_update_meta_existing() { 354 $a = $this->factory->activity->create();354 $a = self::factory()->activity->create(); 355 355 bp_activity_update_meta( $a, 'foo', 'bar' ); 356 356 $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo' ) ); … … 364 364 */ 365 365 public function test_bp_activity_update_meta_same_value() { 366 $a = $this->factory->activity->create();366 $a = self::factory()->activity->create(); 367 367 bp_activity_update_meta( $a, 'foo', 'bar' ); 368 368 $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo' ) ); … … 376 376 */ 377 377 public function test_bp_activity_update_meta_prev_value() { 378 $a = $this->factory->activity->create();378 $a = self::factory()->activity->create(); 379 379 bp_activity_add_meta( $a, 'foo', 'bar' ); 380 380 … … 413 413 */ 414 414 public function test_bp_activity_get_meta_with_illegal_characters() { 415 $a = $this->factory->activity->create();415 $a = self::factory()->activity->create(); 416 416 bp_activity_update_meta( $a, 'foo', 'bar' ); 417 417 … … 425 425 */ 426 426 public function test_bp_activity_get_meta_multiple() { 427 $a = $this->factory->activity->create();427 $a = self::factory()->activity->create(); 428 428 bp_activity_update_meta( $a, 'foo', 'bar' ); 429 429 bp_activity_update_meta( $a, 'foo1', 'bar1' ); … … 447 447 */ 448 448 public function test_bp_activity_get_meta_no_results_returns_false() { 449 $a = $this->factory->activity->create();449 $a = self::factory()->activity->create(); 450 450 451 451 $this->assertSame( '', bp_activity_get_meta( $a, 'foo' ) ); … … 457 457 */ 458 458 public function test_bp_activity_get_meta_single_true() { 459 $a = $this->factory->activity->create();459 $a = self::factory()->activity->create(); 460 460 bp_activity_add_meta( $a, 'foo', 'bar' ); 461 461 bp_activity_add_meta( $a, 'foo', 'baz' ); … … 469 469 */ 470 470 public function test_bp_activity_get_meta_single_false() { 471 $a = $this->factory->activity->create();471 $a = self::factory()->activity->create(); 472 472 bp_activity_add_meta( $a, 'foo', 'bar' ); 473 473 bp_activity_add_meta( $a, 'foo', 'baz' ); … … 481 481 */ 482 482 public function test_bp_activity_get_meta_cache_all_on_get() { 483 $a = $this->factory->activity->create();483 $a = self::factory()->activity->create(); 484 484 bp_activity_add_meta( $a, 'foo', 'bar' ); 485 485 bp_activity_add_meta( $a, 'foo1', 'baz' ); … … 507 507 */ 508 508 public function test_bp_activity_delete_meta_trim_meta_value() { 509 $a = $this->factory->activity->create();509 $a = self::factory()->activity->create(); 510 510 bp_activity_update_meta( $a, 'foo', 'bar' ); 511 511 bp_activity_delete_meta( $a, 'foo', ' bar ' ); … … 518 518 */ 519 519 public function test_bp_activity_delete_meta_single() { 520 $a = $this->factory->activity->create();520 $a = self::factory()->activity->create(); 521 521 bp_activity_update_meta( $a, 'foo', 'bar' ); 522 522 $this->assertTrue( bp_activity_delete_meta( $a, 'foo', 'bar' ) ); … … 529 529 */ 530 530 public function test_bp_activity_delete_meta_all_for_activity() { 531 $a = $this->factory->activity->create();531 $a = self::factory()->activity->create(); 532 532 bp_activity_update_meta( $a, 'foo', 'bar' ); 533 533 bp_activity_update_meta( $a, 'foo1', 'bar1' ); … … 542 542 */ 543 543 public function test_bp_activity_delete_meta_with_meta_value() { 544 $a = $this->factory->activity->create();544 $a = self::factory()->activity->create(); 545 545 bp_activity_update_meta( $a, 'foo', 'bar' ); 546 546 $this->assertTrue( bp_activity_delete_meta( $a, 'foo', 'bar' ) ); … … 555 555 // With no meta key, don't delete for all items - just delete 556 556 // all for a single item 557 $a1 = $this->factory->activity->create();558 $a2 = $this->factory->activity->create();557 $a1 = self::factory()->activity->create(); 558 $a2 = self::factory()->activity->create(); 559 559 bp_activity_update_meta( $a1, 'foo', 'bar' ); 560 560 bp_activity_update_meta( $a1, 'foo1', 'bar1' ); … … 575 575 // With no meta key, don't delete for all items - just delete 576 576 // all for a single item 577 $a1 = $this->factory->activity->create();578 $a2 = $this->factory->activity->create();577 $a1 = self::factory()->activity->create(); 578 $a2 = self::factory()->activity->create(); 579 579 bp_activity_update_meta( $a1, 'foo', 'bar' ); 580 580 bp_activity_update_meta( $a1, 'foo1', 'bar1' ); … … 610 610 */ 611 611 public function test_bp_activity_add_meta_existing_unique() { 612 $a = $this->factory->activity->create();612 $a = self::factory()->activity->create(); 613 613 bp_activity_add_meta( $a, 'foo', 'bar' ); 614 614 $this->assertFalse( bp_activity_add_meta( $a, 'foo', 'baz', true ) ); … … 620 620 */ 621 621 public function test_bp_activity_add_meta_existing_not_unique() { 622 $a = $this->factory->activity->create();622 $a = self::factory()->activity->create(); 623 623 bp_activity_add_meta( $a, 'foo', 'bar' ); 624 624 $this->assertNotEmpty( bp_activity_add_meta( $a, 'foo', 'baz' ) ); … … 631 631 add_filter( 'bp_is_username_compatibility_mode', '__return_false' ); 632 632 633 $u = $this->factory->user->create( array(633 $u = self::factory()->user->create( array( 634 634 'user_login' => 'foo bar baz', 635 635 'user_nicename' => 'foo-bar-baz', … … 647 647 add_filter( 'bp_is_username_compatibility_mode', '__return_true' ); 648 648 649 $u1 = $this->factory->user->create( array(649 $u1 = self::factory()->user->create( array( 650 650 'user_login' => 'foo bar baz', 651 651 'user_nicename' => 'foo-bar-baz', 652 652 ) ); 653 653 654 $u2 = $this->factory->user->create( array(654 $u2 = self::factory()->user->create( array( 655 655 'user_login' => 'foo.bar.baz', 656 656 'user_nicename' => 'foo-bar-baz', … … 669 669 add_filter( 'bp_is_username_compatibility_mode', '__return_false' ); 670 670 671 $u = $this->factory->user->create( array(671 $u = self::factory()->user->create( array( 672 672 'user_login' => 'foo bar baz', 673 673 'user_nicename' => 'foo-bar-baz', … … 686 686 687 687 // all spaces are hyphens 688 $u1 = $this->factory->user->create( array(688 $u1 = self::factory()->user->create( array( 689 689 'user_login' => 'foo bar baz', 690 690 'user_nicename' => 'foobarbaz', … … 692 692 693 693 // no spaces are hyphens 694 $u2 = $this->factory->user->create( array(694 $u2 = self::factory()->user->create( array( 695 695 'user_login' => 'foo-bar-baz-1', 696 696 'user_nicename' => 'foobarbaz-1', … … 698 698 699 699 // some spaces are hyphens 700 $u3 = $this->factory->user->create( array(700 $u3 = self::factory()->user->create( array( 701 701 'user_login' => 'foo bar-baz 2', 702 702 'user_nicename' => 'foobarbaz-2', 703 703 ) ); 704 704 705 $u4 = $this->factory->user->create( array(705 $u4 = self::factory()->user->create( array( 706 706 'user_login' => 'foo.bar.baz', 707 707 'user_nicename' => 'foo-bar-baz', … … 721 721 */ 722 722 public function test_bp_activity_format_activity_action_activity_update() { 723 $u = $this->factory->user->create();724 $a = $this->factory->activity->create( array(723 $u = self::factory()->user->create(); 724 $a = self::factory()->activity->create( array( 725 725 'component' => buddypress()->activity->id, 726 726 'type' => 'activity_update', … … 740 740 */ 741 741 public function test_bp_activity_format_activity_action_activity_comment() { 742 $u = $this->factory->user->create();743 $a = $this->factory->activity->create( array(742 $u = self::factory()->user->create(); 743 $a = self::factory()->activity->create( array( 744 744 'component' => buddypress()->activity->id, 745 745 'type' => 'activity_comment', … … 773 773 bp_activity_get_actions(); 774 774 775 $u = $this->factory->user->create();776 $p = $this->factory->post->create( array(775 $u = self::factory()->user->create(); 776 $p = self::factory()->post->create( array( 777 777 'post_author' => $u, 778 778 'post_type' => 'foo', 779 779 ) ); 780 780 781 $a = $this->factory->activity->create( array(781 $a = self::factory()->activity->create( array( 782 782 'component' => 'activity', 783 783 'type' => 'new_foo', … … 811 811 } 812 812 813 $b = $this->factory->blog->create();814 $u = $this->factory->user->create();813 $b = self::factory()->blog->create(); 814 $u = self::factory()->user->create(); 815 815 816 816 switch_to_blog( $b ); … … 825 825 bp_activity_get_actions(); 826 826 827 $p = $this->factory->post->create( array(827 $p = self::factory()->post->create( array( 828 828 'post_author' => $u, 829 829 'post_type' => 'foo', … … 843 843 restore_current_blog(); 844 844 845 $a = $this->factory->activity->create( $activity_args );845 $a = self::factory()->activity->create( $activity_args ); 846 846 847 847 $a_obj = new BP_Activity_Activity( $a ); … … 886 886 bp_activity_get_actions(); 887 887 888 $u = $this->factory->user->create();889 $p = $this->factory->post->create( array(888 $u = self::factory()->user->create(); 889 $p = self::factory()->post->create( array( 890 890 'post_author' => $u, 891 891 'post_type' => 'foo', 892 892 ) ); 893 893 894 $a = $this->factory->activity->create( array(894 $a = self::factory()->activity->create( array( 895 895 'component' => 'activity', 896 896 'type' => 'foo_bar', … … 923 923 } 924 924 925 $b = $this->factory->blog->create();926 $u = $this->factory->user->create();925 $b = self::factory()->blog->create(); 926 $u = self::factory()->user->create(); 927 927 928 928 switch_to_blog( $b ); … … 943 943 bp_activity_get_actions(); 944 944 945 $p = $this->factory->post->create( array(945 $p = self::factory()->post->create( array( 946 946 'post_author' => $u, 947 947 'post_type' => 'foo', … … 960 960 restore_current_blog(); 961 961 962 $a = $this->factory->activity->create( $activity_args );962 $a = self::factory()->activity->create( $activity_args ); 963 963 964 964 $a_obj = new BP_Activity_Activity( $a ); … … 990 990 bp_activity_get_actions(); 991 991 992 $u = $this->factory->user->create();993 994 $post_id = $this->factory->post->create( array(992 $u = self::factory()->user->create(); 993 994 $post_id = self::factory()->post->create( array( 995 995 'post_author' => $u, 996 996 'post_status' => 'publish', … … 1054 1054 public function test_bp_activity_format_activity_action_custom_post_type_comment() { 1055 1055 if ( is_multisite() ) { 1056 $b = $this->factory->blog->create();1056 $b = self::factory()->blog->create(); 1057 1057 switch_to_blog( $b ); 1058 1058 add_filter( 'comment_flood_filter', '__return_false' ); … … 1061 1061 } 1062 1062 1063 $u = $this->factory->user->create();1063 $u = self::factory()->user->create(); 1064 1064 $userdata = get_userdata( $u ); 1065 1065 … … 1084 1084 bp_activity_get_actions(); 1085 1085 1086 $p = $this->factory->post->create( array(1086 $p = self::factory()->post->create( array( 1087 1087 'post_author' => $u, 1088 1088 'post_type' => 'foo', … … 1127 1127 */ 1128 1128 public function test_bp_activity_new_comment_clear_comment_caches() { 1129 $u = $this->factory->user->create();1130 $a1 = $this->factory->activity->create( array(1129 $u = self::factory()->user->create(); 1130 $a1 = self::factory()->activity->create( array( 1131 1131 'user_id' => $u, 1132 1132 ) ); … … 1181 1181 */ 1182 1182 public function test_bp_activity_new_comment_clear_activity_caches() { 1183 $u = $this->factory->user->create();1184 $a1 = $this->factory->activity->create( array(1183 $u = self::factory()->user->create(); 1184 $a1 = self::factory()->activity->create( array( 1185 1185 'user_id' => $u, 1186 1186 ) ); … … 1253 1253 */ 1254 1254 public function test_bp_activity_delete_comment_clear_cache() { 1255 $u = $this->factory->user->create();1255 $u = self::factory()->user->create(); 1256 1256 // add new activity update and comment to this update 1257 $a1 = $this->factory->activity->create( array(1257 $a1 = self::factory()->activity->create( array( 1258 1258 'user_id' => $u, 1259 1259 ) ); … … 1283 1283 */ 1284 1284 public function test_bp_activity_delete_comment_shouldnt_delete_all_comments_when_parameters_are_empty() { 1285 $u = $this->factory->user->create();1285 $u = self::factory()->user->create(); 1286 1286 1287 1287 // create an activity update 1288 $parent_activity = $this->factory->activity->create( array(1288 $parent_activity = self::factory()->activity->create( array( 1289 1289 'type' => 'activity_update', 1290 1290 'user_id' => $u … … 1330 1330 */ 1331 1331 public function test_bp_activity_comment_on_deleted_activity() { 1332 $u = $this->factory->user->create();1333 $a = $this->factory->activity->create();1332 $u = self::factory()->user->create(); 1333 $a = self::factory()->activity->create(); 1334 1334 1335 1335 bp_activity_delete_by_activity_id( $a ); … … 1350 1350 */ 1351 1351 public function test_add_user_favorite_already_favorited() { 1352 $u = $this->factory->user->create();1353 $a = $this->factory->activity->create();1352 $u = self::factory()->user->create(); 1353 $a = self::factory()->activity->create(); 1354 1354 1355 1355 // bp_activity_add_user_favorite() requires a logged-in user. … … 1371 1371 */ 1372 1372 public function test_add_user_favorite_not_yet_favorited() { 1373 $u = $this->factory->user->create();1374 $a = $this->factory->activity->create();1373 $u = self::factory()->user->create(); 1374 $a = self::factory()->activity->create(); 1375 1375 1376 1376 // bp_activity_add_user_favorite() requires a logged-in user. … … 1387 1387 */ 1388 1388 public function test_remove_user_favorite_bad_activity_id() { 1389 $u1 = $this->factory->user->create();1390 $u2 = $this->factory->user->create();1391 $a = $this->factory->activity->create();1389 $u1 = self::factory()->user->create(); 1390 $u2 = self::factory()->user->create(); 1391 $a = self::factory()->activity->create(); 1392 1392 1393 1393 // bp_activity_add_user_favorite() requires a logged-in user. … … 1426 1426 */ 1427 1427 public function test_bp_activity_post_update_success() { 1428 $u = $this->factory->user->create();1428 $u = self::factory()->user->create(); 1429 1429 1430 1430 $a = bp_activity_post_update( array( … … 1448 1448 ); 1449 1449 1450 $a = $this->factory->activity->create( $args );1450 $a = self::factory()->activity->create( $args ); 1451 1451 1452 1452 $this->assertEquals( $a, bp_activity_get_activity_id( $args ) ); … … 1465 1465 ); 1466 1466 1467 $a = $this->factory->activity->create( $args );1467 $a = self::factory()->activity->create( $args ); 1468 1468 1469 1469 $this->assertTrue( bp_activity_delete_by_item_id( $args ) );
Note: See TracChangeset
for help on using the changeset viewer.