public static function setUpBeforeClass() { parent::setUpBeforeClass(); require_once buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php'; /* * WP's test suite wipes out BP's email posts. * We must reestablish them before our tests can be successfully run. */ bp_core_install_emails(); }
/** * @ticket BP6936 */ public function test_email_type_descriptions_should_match_when_split_terms_exist() { global $wpdb; // Delete all existing email types and descriptions. $emails = get_posts(array('fields' => 'ids', 'post_type' => bp_get_email_post_type())); foreach ($emails as $email) { wp_delete_post($email, true); } $descriptions = get_terms(bp_get_email_tax_type(), array('fields' => 'ids', 'hide_empty' => false)); foreach ($descriptions as $description) { wp_delete_term((int) $description, bp_get_email_tax_type()); } // Fake the existence of split terms by offsetting the term_taxonomy table. $wpdb->insert($wpdb->term_taxonomy, array('term_id' => 9999, 'taxonomy' => 'post_tag', 'description' => 'foo description', 'parent' => 0, 'count' => 0)); require_once BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php'; bp_core_install_emails(); $d_terms = get_terms(bp_get_email_tax_type(), array('hide_empty' => false)); $correct_descriptions = bp_email_get_type_schema(); foreach ($d_terms as $d_term) { $correct_description = $correct_descriptions[$d_term->slug]; $this->assertSame($correct_description, $d_term->description); } }
/** * Delete emails and restore from defaults. * * @since 2.5.0 * * @return array */ function bp_admin_reinstall_emails() { $switched = false; // Switch to the root blog, where the email posts live. if (!bp_is_root_blog()) { switch_to_blog(bp_get_root_blog_id()); bp_register_taxonomies(); $switched = true; } $emails = get_posts(array('fields' => 'ids', 'post_status' => 'publish', 'post_type' => bp_get_email_post_type(), 'posts_per_page' => 200, 'suppress_filters' => false)); if ($emails) { foreach ($emails as $email_id) { wp_trash_post($email_id); } } // Make sure we have no orphaned email type terms. $email_types = get_terms(bp_get_email_tax_type(), array('fields' => 'ids', 'hide_empty' => false, 'update_term_meta_cache' => false)); if ($email_types) { foreach ($email_types as $term_id) { wp_delete_term((int) $term_id, bp_get_email_tax_type()); } } require_once buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php'; bp_core_install_emails(); if ($switched) { restore_current_blog(); } return array(0, __('Emails have been successfully reinstalled.', 'buddypress')); }
/** * 2.5.0 update routine. * * - Add emails. * * @since 2.5.0 */ function bp_update_to_2_5() { bp_core_install_emails(); }
public function test_sending_email() { require_once BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php'; bp_core_install_emails(); $user1 = get_user_by('id', $this->u1); $result = bp_send_email('core-user-registration', $this->u1, array('tokens' => array('activate.url' => 'http://example.com', 'key' => '123', 'user.email' => $user1->user_email, 'user.id' => $this->u1))); $this->assertTrue($result); }