Updated CMS_STORAGE interface.
Added test cased for MySQL implementation.
This commit is contained in:
@@ -175,9 +175,13 @@ feature -- Test routines
|
||||
test_recent_nodes
|
||||
local
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
end
|
||||
l_nodes := storage.recent_nodes (0, 10)
|
||||
assert ("10 recent nodes", l_nodes.count = 10)
|
||||
@@ -200,70 +204,152 @@ feature -- Test routines
|
||||
end
|
||||
|
||||
test_node_does_not_exist
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
end
|
||||
assert ("Not exist node id: 12", storage.node (12) = Void)
|
||||
end
|
||||
|
||||
test_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
end
|
||||
assert ("Node id: 10", attached storage.node (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
assert ("Node id: 10", attached storage.node (10) as ll_node and then ll_node.title ~ "Title_10" )
|
||||
end
|
||||
|
||||
test_update_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
l_node := ll_node.twin
|
||||
l_node.set_content ("New Content")
|
||||
l_node.set_summary ("New Summary")
|
||||
l_node.set_title("New Title")
|
||||
|
||||
storage.update_node (l_node)
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then not (u_node.title ~ ll_node.title) and then not (u_node.content ~ ll_node.content) and then not (u_node.summary ~ ll_node.summary))
|
||||
if attached storage.user_by_email (default_user.email) as l_user then
|
||||
storage.update_node (l_user.id,l_node)
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then not (u_node.title ~ ll_node.title) and then not (u_node.content ~ ll_node.content) and then not (u_node.summary ~ ll_node.summary))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test_update_node_title
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
storage.save_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_title (ll_node.id, "New Title")
|
||||
storage.update_node_title (2,ll_node.id, "New Title")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then not (u_node.title ~ ll_node.title) and then u_node.content ~ ll_node.content and then u_node.summary ~ ll_node.summary)
|
||||
end
|
||||
end
|
||||
|
||||
test_update_node_summary
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
storage.save_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_summary (ll_node.id, "New Summary")
|
||||
storage.update_node_summary (2,ll_node.id, "New Summary")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then u_node.title ~ ll_node.title and then u_node.content ~ ll_node.content and then not (u_node.summary ~ ll_node.summary))
|
||||
end
|
||||
end
|
||||
|
||||
test_update_node_content
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
storage.save_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_content (ll_node.id, "New Content")
|
||||
storage.update_node_content (2,ll_node.id, "New Content")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then u_node.title ~ ll_node.title and then not (u_node.content ~ ll_node.content) and then u_node.summary ~ ll_node.summary)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_update_node_title_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_title (1,ll_node.id, "New Title")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then not (u_node.title ~ ll_node.title) and then u_node.content ~ ll_node.content and then u_node.summary ~ ll_node.summary)
|
||||
end
|
||||
end
|
||||
|
||||
test_update_node_summary_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_summary (1,ll_node.id, "New Summary")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then u_node.title ~ ll_node.title and then u_node.content ~ ll_node.content and then not (u_node.summary ~ ll_node.summary))
|
||||
end
|
||||
end
|
||||
|
||||
test_update_node_content_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_content (1,ll_node.id, "New Content")
|
||||
assert ("Updated", attached {CMS_NODE} storage.node (1) as u_node and then u_node.title ~ ll_node.title and then not (u_node.content ~ ll_node.content) and then u_node.summary ~ ll_node.summary)
|
||||
end
|
||||
end
|
||||
|
||||
test_delete_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
l_user: like {CMS_NODE}.author
|
||||
do
|
||||
storage.save_user (custom_user ("test_delete", "testu", "email"))
|
||||
l_user := storage.user_by_name ("test_delete")
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (l_user)
|
||||
storage.save_node (l_node)
|
||||
end
|
||||
assert ("Exist node id: 10", attached storage.node (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
assert ("Exist node id: 10", attached storage.node (10) as ll_node and then ll_node.title ~ "Title_10" )
|
||||
storage.delete_node (10)
|
||||
assert ("Not exist node id: 10", storage.node (10) = Void)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user