Revisited the persistence layer.
Simplified schema to focus on user and node. Now possible to have sqlite via ODBC and/or mysql support, and select using configuration file. Updated demo example.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description : "tests application root class"
|
||||
date : "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision : "$Revision: 95678 $"
|
||||
date : "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision : "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
@@ -17,14 +17,11 @@ feature {NONE} -- Initialization
|
||||
make
|
||||
-- Run application.
|
||||
local
|
||||
user: USER_DATA_PROVIDER
|
||||
node: NODE_DATA_PROVIDER
|
||||
l_security: SECURITY_PROVIDER
|
||||
storage: CMS_STORAGE_SQLITE
|
||||
do
|
||||
-- Change the path.
|
||||
-- Change the path.
|
||||
create connection.login_with_connection_string ("Driver=SQLite3 ODBC Driver;Database=./cms_lite.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
|
||||
create user.make (connection)
|
||||
user.new_user ("test", "test", "test")
|
||||
create storage.make (connection)
|
||||
end
|
||||
|
||||
connection: DATABASE_CONNECTION_ODBC
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
@@ -30,7 +30,7 @@ feature {NONE} -- Events
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
end
|
||||
|
||||
on_clean
|
||||
@@ -42,13 +42,13 @@ feature -- Test routines
|
||||
|
||||
test_new_node
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
node_provider.new_node (default_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
storage.new_node (default_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached node_provider.node (1))
|
||||
assert ("Exist node with id 1", attached storage.node_by_id (1))
|
||||
-- Not exist node with id 2
|
||||
assert ("Not exist node with id 2", node_provider.node (2) = Void)
|
||||
assert ("Not exist node with id 2", storage.node_by_id (2) = Void)
|
||||
end
|
||||
|
||||
|
||||
@@ -56,31 +56,31 @@ feature -- Test routines
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
storage.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node (content and summary)
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
node_provider.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
storage.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
|
||||
-- Update node (content and summary and title)
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
l_un.set_title ("Updating Test case")
|
||||
node_provider.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
storage.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,18 +88,18 @@ feature -- Test routines
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
storage.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node title
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_title (l_un.id, "New Title")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
|
||||
storage.update_node_title (1, l_un.id, "New Title")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,18 +107,18 @@ feature -- Test routines
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
storage.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node summary
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_summary (l_un.id,"New Summary")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
|
||||
storage.update_node_summary (1, l_un.id,"New Summary")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,18 +126,18 @@ feature -- Test routines
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
storage.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node content
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_content (l_un.id,"New Content")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
|
||||
storage.update_node_content (1, l_un.id, "New Content")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,17 +146,17 @@ feature -- Test routines
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
storage.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not storage.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Delte node 1
|
||||
|
||||
node_provider.delete_node (1)
|
||||
assert ("Node does not exist", node_provider.node (1) = Void)
|
||||
storage.delete_node_by_id (1)
|
||||
assert ("Node does not exist", storage.node_by_id (1) = Void)
|
||||
end
|
||||
|
||||
test_recent_nodes
|
||||
@@ -167,57 +167,37 @@ feature -- Test routines
|
||||
local
|
||||
i : INTEGER
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
across 1 |..| 10 as c loop
|
||||
node_provider.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
|
||||
-- Scenario (0,10) rows, recents (10 down to 1)
|
||||
i := 10
|
||||
across node_provider.recent_nodes (0, 10) as c loop
|
||||
across storage.recent_nodes (0, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (5, 10) rows, recent nodes (5 down to 1)
|
||||
i := 5
|
||||
across node_provider.recent_nodes (5, 10) as c loop
|
||||
across storage.recent_nodes (5, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (9,10) rows, recent node 1
|
||||
i := 1
|
||||
across node_provider.recent_nodes (9, 10) as c loop
|
||||
across storage.recent_nodes (9, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenrario 10..10 empty
|
||||
assert ("Empty", node_provider.recent_nodes (10, 10).after)
|
||||
assert ("Empty", storage.recent_nodes (10, 10).after)
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- node provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation Fixture Factories
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {STORAGE_TEST_SET}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
STORAGE_TEST_SET
|
||||
@@ -177,7 +177,7 @@ feature -- Test routines
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
do
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
l_nodes := storage.recent_nodes (0, 10)
|
||||
assert ("10 recent nodes", l_nodes.count = 10)
|
||||
@@ -200,124 +200,74 @@ feature -- Test routines
|
||||
end
|
||||
|
||||
test_node_does_not_exist
|
||||
local
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
do
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
assert ("Not exist node id: 12", storage.node (12) = Void)
|
||||
assert ("Not exist node id: 12", storage.node_by_id (12) = Void)
|
||||
end
|
||||
|
||||
test_node
|
||||
local
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
do
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
assert ("Node id: 10", attached storage.node (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
assert ("has nodes", storage.nodes.count > 5)
|
||||
assert ("Node id: 10", attached storage.node_by_id (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
end
|
||||
|
||||
test_update_node
|
||||
local
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.new_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node_by_id (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))
|
||||
assert ("Updated", attached {CMS_NODE} storage.node_by_id (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
|
||||
|
||||
test_update_node_title
|
||||
local
|
||||
l_nodes: LIST[CMS_NODE]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.new_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
-- storage.update_node_title (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)
|
||||
assert ("Updated", attached {CMS_NODE} storage.node_by_id (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_nodes: LIST[CMS_NODE]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.new_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
-- storage.update_node_summary (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))
|
||||
assert ("Updated", attached {CMS_NODE} storage.node_by_id (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_nodes: LIST[CMS_NODE]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.save_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.new_node (custom_node ("Content", "Summary", "Title"))
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
-- storage.update_node_content (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)
|
||||
assert ("Updated", attached {CMS_NODE} storage.node_by_id (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_nodes: LIST[CMS_NODE]
|
||||
do
|
||||
across 1 |..| 10 as c loop
|
||||
storage.save_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
assert ("Exist node id: 10", attached storage.node (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
storage.delete_node (10)
|
||||
assert ("Not exist node id: 10", storage.node (10) = Void)
|
||||
assert ("Exist node id: 10", attached storage.node_by_id (10) as l_node and then l_node.title ~ "Title_10" )
|
||||
storage.delete_node_by_id (10)
|
||||
assert ("Not exist node id: 10", storage.node_by_id (10) = Void)
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Storage
|
||||
once
|
||||
create {CMS_STORAGE_SQLITE}Result.make (connection)
|
||||
end
|
||||
|
||||
feature {NONE} -- Fixture Factory: Users
|
||||
|
||||
default_user: CMS_USER
|
||||
do
|
||||
Result := custom_user ("test", "password", "test@test.com")
|
||||
end
|
||||
|
||||
custom_user (a_name, a_password, a_email: READABLE_STRING_32): CMS_USER
|
||||
do
|
||||
create Result.make (a_name)
|
||||
Result.set_password (a_password)
|
||||
Result.set_email (a_email)
|
||||
end
|
||||
|
||||
feature {NONE} -- Fixture Factories: Nodes
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="persitence_sqlite" location="..\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
@@ -30,7 +30,7 @@ feature {NONE} -- Events
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
user_provider.new_user ("admin", "admin","admin@admin.com")
|
||||
storage.new_user (custom_user ("admin", "admin","admin@admin.com"))
|
||||
end
|
||||
|
||||
on_clean
|
||||
@@ -43,36 +43,30 @@ feature -- Test routines
|
||||
test_user_exist
|
||||
-- User admin exist
|
||||
do
|
||||
assert ("Not void", attached user_provider.user_by_email ("admin@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (1))
|
||||
assert ("Not void", attached user_provider.user_by_name ("admin"))
|
||||
assert ("Not void", attached storage.user_by_email ("admin@admin.com"))
|
||||
assert ("Not void", attached storage.user_by_id (1))
|
||||
assert ("Not void", attached storage.user_by_name ("admin"))
|
||||
end
|
||||
|
||||
test_user_not_exist
|
||||
-- Uset test does not exist.
|
||||
do
|
||||
assert ("Void", user_provider.user_by_email ("test@admin.com") = Void)
|
||||
assert ("Void", user_provider.user(2) = Void )
|
||||
assert ("Void", user_provider.user_by_name ("test") = Void)
|
||||
assert ("Void", storage.user_by_email ("test@admin.com") = Void)
|
||||
assert ("Void", storage.user_by_id (2) = Void )
|
||||
assert ("Void", storage.user_by_name ("test") = Void)
|
||||
end
|
||||
|
||||
test_new_user
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Not void", attached user_provider.user_by_email ("test@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (2))
|
||||
assert ("Not void", attached user_provider.user (2) as l_user and then l_user.id = 2 and then l_user.name ~ "test")
|
||||
assert ("Not void", attached user_provider.user_by_name ("test"))
|
||||
storage.new_user (custom_user ("test", "test","test@admin.com"))
|
||||
assert ("Not void", attached storage.user_by_email ("test@admin.com"))
|
||||
assert ("Not void", attached storage.user_by_id (2))
|
||||
assert ("Not void", attached storage.user_by_id (2) as l_user and then l_user.id = 2 and then l_user.name ~ "test")
|
||||
assert ("Not void", attached storage.user_by_name ("test"))
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {ABSTRACT_DB_TEST}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
ABSTRACT_DB_TEST
|
||||
@@ -12,8 +12,43 @@ feature -- Database connection
|
||||
connection: DATABASE_CONNECTION_ODBC
|
||||
-- odbc database connection
|
||||
once
|
||||
-- create Result.login_with_connection_string ("Driver=SQLite3 ODBC Driver;Database=PATH/SQLITE.FILE;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
|
||||
create Result.make_basic ("cms_dev")
|
||||
create Result.login_with_connection_string ("Driver=SQLite3 ODBC Driver;Database=cms_lite.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;")
|
||||
-- create Result.make_basic ("cms_lite.db")
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- node provider.
|
||||
once
|
||||
create {CMS_STORAGE_SQLITE} Result.make (connection)
|
||||
end
|
||||
|
||||
feature {NONE} -- Fixture Factory: Users
|
||||
|
||||
default_user: CMS_USER
|
||||
do
|
||||
Result := custom_user ("test", "password", "test@test.com")
|
||||
end
|
||||
|
||||
custom_user (a_name, a_password, a_email: READABLE_STRING_32): CMS_USER
|
||||
do
|
||||
create Result.make (a_name)
|
||||
Result.set_password (a_password)
|
||||
Result.set_email (a_email)
|
||||
end
|
||||
|
||||
feature {NONE} -- Fixture Factories: Nodes
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user