Index: openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl,v diff -u -r1.2.2.2 -r1.2.2.3 --- openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 30 Dec 2004 21:01:26 -0000 1.2.2.2 +++ openacs-4/packages/acs-content-repository/tcl/test/content-item-test-procs.tcl 3 Jan 2005 16:38:02 -0000 1.2.2.3 @@ -10,8 +10,6 @@ } -# FIXME DaveB Write some tests! - aa_register_case content_item { content item test } { @@ -46,14 +44,14 @@ -name "test_item_one" \ -item_id $first_item_id \ -parent_id $first_folder_id \ - -title "Title" + -attributes [list title "Title"] ] aa_true "First item created" [expr $first_item_id == $returned_first_item_id] aa_true "First item exists" [expr $first_item_id == \ [db_string get_item \ "select item_id from - cr_items where item_id=:first_item_id"]] + cr_items where item_id=:first_item_id and name='test_item_one'"]] aa_true "First item's revision exists" \ [expr \ {![string equal "" \ @@ -65,6 +63,49 @@ set is_empty [content::folder::is_empty -folder_id $first_folder_id] aa_true "Folder 1 is not empty" [string is false $is_empty] + + # create a new content type + set new_type_id [content::type::new \ + -content_type "__test_type" \ + -pretty_name "__test_type" \ + -pretty_plural "__test_type" \ + -table_name "__test_type" \ + -id_column "test_id"] + + # todo test that new item is NOT allowed to be created + # unless registered by catching error when creating new + # item + + # register new type to folder + content::folder::register_content_type \ + -folder_id $first_folder_id \ + -content_type "__test_type" + # create an item of that type + set new_type_item_id [db_nextval "acs_object_id_seq"] + set returned_new_type_item_id [content::item::new \ + -name "test_item_${new_type_item_id}" \ + -item_id $new_type_item_id \ + -parent_id $first_folder_id \ + -content_type "__test_type" \ + -attributes [list title "Title"]] + + # check that the item exists + + aa_true "New Type item created" [expr $new_type_item_id == $returned_new_type_item_id] + aa_true "New Type item exists" [expr $new_type_item_id == \ + [db_string get_item \ + "select item_id from + cr_items where item_id=:new_type_item_id and name='test_item_${new_type_item_id}'" -default ""]] + + # check that the extended attributes and the revision + # exist + aa_true "First item's revision exists" \ + [expr \ + {![string equal "" \ + [db_string get_revision "select + latest_revision + from cr_items, __test_typex where latest_revision=test_id and cr_items.item_id=:new_type_item_id" -default ""]]}] + # copy it # move the copy