BEGIN {
use
lib (
'lib'
,
'../lib'
);
use_ok(
'XML::XMetaL::Mock::DOMELement'
);
use_ok(
'XML::XMetaL::Mock::DOMNodeList'
);
};
my
$dom_node_list
;
SET_UP: {
eval
{
$dom_node_list
= XML::XMetaL::Mock::DOMNodeList->new(
map
{
XML::XMetaL::Mock::DOMElement->new(
nodeID
=>
$_
,
)
}
qw(node01 node02)
);
};
diag($@)
if
$@;
is(
eval
{
ref
$dom_node_list
},
"XML::XMetaL::Mock::DOMNodeList"
,
"XML::XMetaL::Mock::DOMNodeList constructor test"
);
}
ITEM: {
eval
{
$dom_node_list
->add(
map
{XML::XMetaL::Mock::DOMElement->new(
nodeID
=>
$_
)}
qw(node03 node04)
);
my
$item
;
my
$index
= 0;
foreach
my
$node_id
(
qw(node01 node02 node03 node04)
) {
$item
=
$dom_node_list
->item(
$index
);
is(
$item
->{nodeID},
$node_id
,
"item() test"
);
$index
++;
}
};
diag $@
if
$@;
}
LENGTH: {
is(
eval
{
$dom_node_list
->{
length
}},
4,
"length property test"
);
}