/** * Try to revise an existing document (creates that document first) * @return int the revision ID */ function test_revise_document() { $docID = WP_Test_Document_Revisions::test_add_document(); $attach_id = $this->spoof_upload($docID, $this->test_file2); $post = array('ID' => $docID, 'post_content' => $attach_id, 'post_excerpt' => 'revised'); $result = wp_update_post($post); wp_cache_flush(); $this->assertGreaterThan(0, $result, 'Cannot update document post_content with revised attachment ID'); $this->verify_attachment_matches_file($result, $this->test_file2, 'revise document'); return $result; }
/** * Tests that changing the document slug is reflected in permalinks */ function test_document_slug() { global $wp_rewrite; $tdr = new WP_Test_Document_Revisions(); //set new slug update_site_option('document_slug', 'docs'); //add doc and flush $docID = $tdr->test_add_document(); wp_publish_post($docID); wp_cache_flush(); $this->verify_download(get_permalink($docID), $tdr->test_file, 'revised document slug permalink doesn\'t rewrite'); $this->assertContains('/docs/', get_permalink($docID), 'revised document slug not in permalink'); }
/** * Tests that get_documents properly filters when asked */ function test_get_documents_filter() { $tdr = new WP_Test_Document_Revisions(); $tdr->test_add_document(); //add a doc $docID = $tdr->test_add_document(); //add another doc wp_publish_post($docID); //give postmeta to a doc update_post_meta($docID, 'test_meta_key', 'test_value'); wp_cache_flush(); $docs = get_documents(array('test_meta_key' => 'test_value')); $this->assertCount(1, $docs, 'get_documents filter count'); }