Index: openacs-4/packages/acs-content-repository/tcl/test/content-revision-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/content-revision-test-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-content-repository/tcl/test/content-revision-test-procs.tcl 15 Aug 2018 16:24:28 -0000 1.9 +++ openacs-4/packages/acs-content-repository/tcl/test/content-revision-test-procs.tcl 3 Sep 2024 15:37:31 -0000 1.10 @@ -16,9 +16,17 @@ content::folder::unregister_content_type content::item::delete content::item::get_content + content::item::get_revision_count content::item::new + content::revision::get_title + content::revision::is_latest + content::revision::is_live + content::revision::item_id content::revision::new - cr_write_content + content::revision::copy + content::revision::delete + content::revision::revision_name + cr_write_content } \ content_revision { content revision test @@ -52,10 +60,11 @@ # create a revision set revision_id [db_nextval "acs_object_id_seq"] + set title "Test Title" set returned_revision_id [content::revision::new \ -revision_id $revision_id \ -item_id $first_item_id \ - -title "Test Title" \ + -title $title \ -description "Test Description" \ -content "Test Content"] aa_true "Basic Revision created revision_id $revision_id returned_revision_id $returned_revision_id " \ @@ -64,12 +73,78 @@ content::item::get_content -revision_id $returned_revision_id -array revision_content set revision_content(content) [cr_write_content -revision_id $returned_revision_id -string] aa_true "Revision contains correct content" { - $revision_content(title) eq "Test Title" + $revision_content(title) eq $title && $revision_content(content) eq "Test Content" && $revision_id == $revision_content(revision_id) } + aa_equals "content_revision is consistent" \ + [content::revision::item_id -revision_id $revision_id] \ + $first_item_id + + aa_equals "content_revision is latest" \ + [content::revision::is_latest -revision_id $revision_id] \ + t + aa_equals "content_revision is live" \ + [content::revision::is_live -revision_id $revision_id] \ + f + + aa_equals "content_revision name" \ + [content::revision::revision_name -revision_id $revision_id] \ + "Revision 1 of 1 for item: Test Title" + + aa_equals "content_revision count for first item" \ + [content::item::get_revision_count -item_id $first_item_id] \ + 1 + + aa_equals "Title of the revision should be $title" \ + $title \ + [content::revision::get_title \ + -revision_id $returned_revision_id] + + set revision_id2 [content::revision::new \ + -item_id $first_item_id \ + -title "rev2" \ + -description "Test Description2" \ + -content "Test Content2"] + + aa_equals "content_revision count for first item" \ + [content::item::get_revision_count -item_id $first_item_id] \ + 2 + + aa_equals "content_revision name" \ + [content::revision::revision_name -revision_id $revision_id2] \ + "Revision 2 of 2 for item: rev2" + + set second_item_id [content::item::new \ + -name "test_item_two" \ + -parent_id $first_folder_id \ + -storage_type "text"] + set copy_revision_id [content::revision::copy \ + -revision_id $revision_id2 \ + -target_item_id $second_item_id] + db_1row get_copy_info { + select content, item_id + from cr_revisions + where revision_id = :copy_revision_id + } + aa_equals "Copied revision '$copy_revision_id' has the same content as source '$revision_id2'" \ + $content "Test Content2" + aa_equals "Copied revision '$copy_revision_id' was stored under '$second_item_id'" \ + $item_id $second_item_id + + aa_equals "'$second_item_id' has 1 revisions" \ + [content::item::get_revision_count -item_id $second_item_id] \ + 1 + + content::revision::delete -revision_id $copy_revision_id + + aa_equals "After deleting the only revision '$copy_revision_id' of item '$second_item_id', the item has 0 revisions" \ + [content::item::get_revision_count -item_id $second_item_id] \ + 0 + content::item::delete -item_id $first_item_id + content::item::delete -item_id $second_item_id content::folder::unregister_content_type \ -folder_id $first_folder_id \