function test_pmp_delete_saved_query_by_id() { // Make sure we have at least one query stored pmp_save_search_query(0, (object) array('options' => (object) array('title' => 'Test title does not matter'), 'query' => (object) array())); pmp_delete_saved_query_by_id(0); $result = pmp_get_saved_search_query(0); $this->assertTrue(empty($result)); }
/** * Ajax function to save a search query for later use * * @since 0.3 */ function pmp_save_query() { check_ajax_referer('pmp_ajax_nonce', 'security'); $search_query = json_decode(stripslashes($_POST['data'])); if (isset($search_query->options->search_id)) { $search_id = $search_query->options->search_id; unset($search_query->options->search_id); } else { $search_id = null; } $search_id = pmp_save_search_query($search_id, $search_query); if ($search_id >= 0) { print json_encode(array("success" => true, "search_id" => $search_id)); } else { print json_encode(array("success" => false)); } wp_die(); }