Changeset 10545 for trunk/tests/phpunit/testcases/activity/functions.php
- Timestamp:
- 02/07/2016 04:55:04 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/activity/functions.php
r10515 r10545 764 764 } 765 765 766 $bp = buddypress();767 768 766 register_post_type( 'foo', array( 769 767 'label' => 'foo', … … 801 799 802 800 _unregister_post_type( 'foo' ); 803 804 // Reset globals805 unset( $bp->activity->actions->activity->new_foo );806 $bp->activity->track = array();807 801 } 808 802 … … 816 810 return; 817 811 } 818 819 $bp = buddypress();820 812 821 813 $b = $this->factory->blog->create(); … … 864 856 865 857 $this->assertSame( $expected, $a_obj->action ); 866 867 // Reset globals868 unset( $bp->activity->actions->activity->new_foo );869 $bp->activity->track = array();870 858 } 871 859 … … 879 867 return; 880 868 } 881 882 $bp = buddypress();883 869 884 870 $labels = array( … … 925 911 926 912 _unregister_post_type( 'foo' ); 927 928 // Reset globals929 unset( $bp->activity->actions->activity->foo_bar );930 $bp->activity->track = array();931 913 } 932 914 … … 940 922 return; 941 923 } 942 943 $bp = buddypress();944 $reset = $bp->activity->actions;945 924 946 925 $b = $this->factory->blog->create(); … … 992 971 993 972 $this->assertSame( $expected, $a_obj->action ); 994 995 // Reset globals996 unset( $bp->activity->actions->activity->new_foo );997 $bp->activity->track = array();998 973 } 999 974 … … 1032 1007 1033 1008 remove_post_type_support( 'page', 'buddypress-activity' ); 1034 1035 // Reset globals1036 unset( $bp->activity->actions->blogs->new_page );1037 $bp->activity->track = array();1038 1009 } 1039 1010 … … 1074 1045 1075 1046 $this->assertSame( $set_bp_activity, $register_bp_activity ); 1047 } 1048 1049 /** 1050 * @group activity_action 1051 * @group bp_activity_format_activity_action_custom_post_type_post_ms 1052 * @group post_type_comment_activities 1053 */ 1054 public function test_bp_activity_format_activity_action_custom_post_type_comment() { 1055 if ( is_multisite() ) { 1056 $b = $this->factory->blog->create(); 1057 switch_to_blog( $b ); 1058 add_filter( 'comment_flood_filter', '__return_false' ); 1059 } else { 1060 $b = get_current_blog_id(); 1061 } 1062 1063 $u = $this->factory->user->create(); 1064 $userdata = get_userdata( $u ); 1065 1066 $labels = array( 1067 'name' => 'bars', 1068 'singular_name' => 'bar', 1069 'bp_activity_new_comment' => __( '%1$s commented on the <a href="%2$s">bar</a>', 'buddypress' ), 1070 'bp_activity_new_comment_ms' => __( '%1$s commented on the <a href="%2$s">bar</a>, on the site %3$s', 'buddypress' ), 1071 ); 1072 1073 register_post_type( 'foo', array( 1074 'labels' => $labels, 1075 'public' => true, 1076 'supports' => array( 'buddypress-activity', 'comments' ), 1077 'bp_activity' => array( 1078 'action_id' => 'new_bar', 1079 'comment_action_id' => 'new_bar_comment', 1080 ), 1081 ) ); 1082 1083 // Build the actions to fetch the tracking args 1084 bp_activity_get_actions(); 1085 1086 $p = $this->factory->post->create( array( 1087 'post_author' => $u, 1088 'post_type' => 'foo', 1089 ) ); 1090 1091 $c = wp_new_comment( array( 1092 'comment_post_ID' => $p, 1093 'comment_author' => $userdata->user_nicename, 1094 'comment_author_url' => 'http://buddypress.org', 1095 'comment_author_email' => $userdata->user_email, 1096 'comment_content' => 'this is a blog comment', 1097 'comment_type' => '', 1098 'comment_parent' => 0, 1099 'user_id' => $u, 1100 ) ); 1101 1102 $a = bp_activity_get_activity_id( array( 'type' => 'new_bar_comment' ) ); 1103 1104 $a_obj = new BP_Activity_Activity( $a ); 1105 1106 $user_link = bp_core_get_userlink( $u ); 1107 $comment_url = get_comment_link( $c ); 1108 1109 _unregister_post_type( 'foo' ); 1110 1111 if ( is_multisite() ) { 1112 $blog_url = get_blog_option( $a_obj->item_id, 'home' ); 1113 restore_current_blog(); 1114 remove_filter( 'comment_flood_filter', '__return_false' ); 1115 1116 $expected = sprintf( $labels['bp_activity_new_comment_ms'], $user_link, $comment_url, '<a href="' . $blog_url . '">' . get_blog_option( $a_obj->item_id, 'blogname' ) . '</a>' ); 1117 } else { 1118 $expected = sprintf( $labels['bp_activity_new_comment'], $user_link, $comment_url ); 1119 } 1120 1121 $this->assertSame( $expected, $a_obj->action ); 1076 1122 } 1077 1123
Note: See TracChangeset
for help on using the changeset viewer.