annotate _test/Test/DOM/Node.pm @ 184:7525ea9a071a

IMPL::Web::View::TTLoader tests
author sergey
date Thu, 29 Mar 2012 01:54:20 +0400
parents 4267a2ac3d46
children 029c9610528c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
1 package Test::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 148
diff changeset
5 use parent qw(IMPL::Test::Unit);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
6 use IMPL::Test qw(test shared failed cmparray);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
7 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
9 require IMPL::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
11 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
13 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
14 shared public property Root => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
15 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
16
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
17 test Create => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
18 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
20 $this->Root(new IMPL::DOM::Document(nodeName => 'Root')) or failed "Failed to create a document";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
21 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
22
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
23 test InsertNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
24 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
25 my $child = $this->Root->insertNode(new IMPL::DOM::Node(nodeName => 'Child')) or failed "Failed to insert a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
26 failed "fiestChild returned incorrect results" unless ($this->Root->firstChild || 0) == $child;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
27 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
28
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
29 test AppendNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
30 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
32 my $child = $this->Root->appendNode(new IMPL::DOM::Node(nodeName => 'Child')) or failed "Failed to append a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
34 my $lastChild = $this->Root->removeLast;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
36 failed "removeLast returned incorrect results" unless $lastChild == $child;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
37 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
38
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
39 test GetDocumentNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
40 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
42 my $child = $this->Root->firstChild->appendNode(new IMPL::DOM::Node(nodeName => 'GrandChild')) or failed "Failed to append a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
43
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
44 failed "document property is undef" unless $child->document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
45 failed "document property returned incorrect value" unless $child->document == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
46 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
47
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
48 test DocumentCreateNode => sub {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
49 my ($this) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
50
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
51 my $child = $this->Root->firstChild->appendNode($this->Root->Create(Info => { uuid => '77f9-9a-6d58' } )) or failed "Failed to append a child node";
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
52
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
53 failed "document property is undef" unless $child->document;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
54 failed "document property returned incorrect value" unless $child->document == $this->Root;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
55 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
56
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
57 test MoveNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
58 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
59
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
60 my $grandChild = $this->Root->firstChild->firstChild;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
61 $this->Root->appendNode($grandChild);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
62
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
63 failed "incorrect new parentNode value" unless ($grandChild->parentNode || 0) == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
64 failed "incorrect new document value" unless ($grandChild->document || 0) == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
65 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
66
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
67 test AppendRange => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
68 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
69
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
70 my $count = $this->Root->childNodes->Count;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
71
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
72 $this->Root->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
73 map IMPL::DOM::Node->new(nodeName => "Item", nodeValue => $_),1..10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
74 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
75
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
76 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
77 "Wrong number of a child nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
78 "Expected: ".($count+10),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
79 "Actual: ".$this->Root->childNodes->Count
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
80 unless $count + 10 == $this->Root->childNodes->Count;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
81 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
82
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
83 test SelectNodes => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
84 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
85
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
86 my @result = $this->Root->selectNodes("Item");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
87
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
88 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
89 "Wrong number of a selected nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
90 "Expected: 10",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
91 "Actual: ".scalar(@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
92 unless @result == 10;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
93 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
94
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
95 test SelectNodesByQuery => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
96 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
97
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
98 my @result = $this->Root->selectNodes(sub { $_->nodeName =~ /child/i } );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
99 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
100 "Wrong number of a selected nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
101 "Expected: 2",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
102 "Actual: ".scalar(@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
103 unless @result == 2;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
104 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
105
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
106 test SelectNodesPath => sub {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
107 my ($this) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
108
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
109 my @result = $this->Root->selectNodes('Child','Info');
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
110
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
111 failed "Failed to select a node by path 'Child/Info'" unless @result;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
112 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
113
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
114 test SelectByAxisDescendant => sub {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
115 my ($this) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
116
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
117 my @result = $this->Root->selectNodes( { descendant => ['GrandChild','Info']} );
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
118
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
119 failed "Failed to select a node by path '//(GrandChild|Info)/'" unless @result == 2;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
120 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
121
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
122 test SelectByAxisAncestor => sub {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
123 my ($this) = @_;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
124
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
125 my @result = $this->Root->selectSingleNode( { descendant => 'Info'} )->selectNodes( { ancestor => undef } ) ;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
126
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
127 failed "Failed to select a node by path '//Info/ancestor:*'" unless @result == 2;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
128 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
129
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
130 test CheckNodesValues => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
131 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
132
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
133 my @expected = (1..10);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
134
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
135 my @result = map $_->nodeValue, grep $_->nodeValue, $this->Root->selectNodes("Item");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
136
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
137 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
138 "Some nodes returned wrong node values or in a wrong order",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
139 "Expected: ".join(', ',@expected),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
140 "Recieved: ".join(', ',@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
141 unless cmparray(\@expected,\@result);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
142
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
143 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
144 "a text property of a root node returned a wrong value",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
145 "Expected: @expected",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
146 "Recieved: ". $this->Root->text
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
147 unless $this->Root->text eq join '',@expected;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
148 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
149
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
150 test isComplex => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
151 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
152
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
153 failed "property isComplex returned false for the root node" unless $this->Root->isComplex;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
154 failed "property isComplex returned true for a simple node", $this->Root->selectSingleNode('Item')->childNodes->Count if $this->Root->selectSingleNode('Item')->isComplex;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
155 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
156
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
157 test setObjectProperty => sub {
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
158 my ($this) = @_;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
159
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
160 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
161
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
162 my $name = 'Vergon 6';
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
163
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
164 $node->nodeProperty(name => $name);
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
165 failed "Failed to set a property 'name'", "Expected: $name", "Got: ".$node->name unless $node->name eq $name;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
166
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
167 $name = 'entity_vergon_6';
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
168 $node->systemName($name);
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
169 failed "Failed to set a property 'systemName'", "Expected: $name", "Got: ".$node->nodeProperty('systemName') unless $node->nodeProperty('systemName') eq $name;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
170 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
171
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
172 test setDynamicProperty => sub {
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
173 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
174
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
175 my $uuid = 'entity_76fd98b9e7a';
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
176 $node->nodeProperty(uuid => $uuid);
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
177 failed "Failed to set a dynamic property 'uuid'", "Expected: $uuid", "Got: ".$node->nodeProperty('uuid') unless $node->nodeProperty('uuid') eq $uuid;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
178 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
179
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
180 test setPrivateProperty => sub {
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
181 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
182
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
183 eval {
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
184 $node->nodeProperty(_private => 'failed');
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
185 1;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
186 } and failed "Setting a private property successfull";
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
187 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
188
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
189 test createNodeWithProps => sub {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
190 my $uuid = 'entity_76fd98b9e7a';
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
191 my $name = 'Vergon 6';
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
192 my $systemName = 'entity_vergon_6';
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
193
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
194 my $node = Test::DOM::TypedNode->new(
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
195 nodeName => 'TestNode',
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
196 uuid => $uuid,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
197 name => $name,
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
198 systemName => $systemName
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
199 );
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
200
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
201 failed "Failed to get dynamic property 'uuid'" unless $node->nodeProperty('uuid') eq $uuid;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
202 failed "Failed to get property 'name' through nodeProperty method" unless $node->nodeProperty('name') eq $name;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
203 failed "Failed to get property name directly" unless $node->name eq $name;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
204 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
205
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
206 test listNodePredefinedProps => sub {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
207 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
208
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
209 my @props = $node->listProperties;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
210 my @expected = qw(name _private);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
211
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
212 failed "Got wrong list of props", @props unless cmparray(\@props,\@expected);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
213 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
214
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
215 test listNodeAllProps => sub {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
216 my $node = Test::DOM::TypedNode->new(
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
217 nodeName => 'TestNode',
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
218 uuid => 'ade58f98b', # dynamic
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
219 name => 'noname', # predefined
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
220 systemName => 'no sys' # not visible to DOM
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
221 );
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
222
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
223 my @props = $node->listProperties;
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
224 my @expected = qw(name _private uuid); # systemName is not a DOM prop
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
225
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
226 failed "Got wrong list of props", @props unless cmparray(\@props,\@expected);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
227 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
228
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
229 package Test::DOM::TypedNode;
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 148
diff changeset
230 use parent qw(IMPL::DOM::Node);
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
231 use IMPL::Class::Property;
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
232 use IMPL::DOM::Property qw(_dom);
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
233
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
234 __PACKAGE__->PassThroughArgs;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
235
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
236 BEGIN {
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
237 public _dom property name => prop_all;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
238 public property systemName => prop_all;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
239 private _dom property _private => prop_all;
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
240 }
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
241
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
242
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
243 1;