/[suikacvs]/messaging/manakai/t/DOM-Atom-AtomElement.t
Suika

Contents of /messaging/manakai/t/DOM-Atom-AtomElement.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Sun Jul 29 07:46:50 2007 UTC (17 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
File MIME type: application/x-troff
Was not part of CVS repository

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use Test;
4     BEGIN { plan tests => 38 }
5    
6     require Message::DOM::DOMImplementation;
7    
8     my $impl = Message::DOM::DOMImplementation->new;
9    
10     ## |AtomDOMImplementation|
11     ok $impl->isa ('Message::IF::AtomDOMImplementation') ? 1 : 0, 1,
12     'AtomDOMImplementation interface';
13     ok $impl->can ('create_atom_entry_document') ? 1 : 0, 1, 'ADI->create_aed';
14     ok $impl->can ('create_atom_feed_document') ? 1 : 0, 1, 'ADI->create_afd';
15    
16     my $ATOM_NS = q<http://www.w3.org/2005/Atom>;
17     my $CCE = q<http://suika.fam.cx/www/2006/dom-config/create-child-element>;
18    
19     ## |createAtomFeedDocument|, |createAtomEntryDocument|
20     for my $m (
21     [feed => 'create_atom_feed_document'],
22     [entry => 'create_atom_entry_document'],
23     ) {
24     my $mn = $m->[1];
25     my $doc = $impl->$mn ('about:id', 'feed title', 'en');
26     for (
27     'Message::IF::Node',
28     'Message::IF::Document',
29     ) {
30     ok $doc->isa ($_) ? 1 : 0, 1, $mn.' [1] interface '.$_;
31     }
32    
33     ok $doc->xml_version, '1.0', $mn.' [1] xml_version';
34    
35     my $feed = $doc->document_element;
36     ok $feed->namespace_uri, $ATOM_NS, $mn.' [1] namespace_uri';
37     ok $feed->manakai_local_name, $m->[0], $mn.' [1] local_name';
38     ok $feed->get_attribute_ns (q<http://www.w3.org/XML/1998/namespace>, 'lang'),
39     'en', $mn.' [1] lang';
40    
41     my $id;
42     my $title;
43     my $updated;
44     for my $cn (@{$feed->child_nodes}) {
45     if ($cn->node_type == 1 and # ELEMENT_NODE
46     $cn->namespace_uri eq $ATOM_NS) {
47     if ($cn->manakai_local_name eq 'id') {
48     $id = $cn;
49     } elsif ($cn->manakai_local_name eq 'title') {
50     $title = $cn;
51     } elsif ($cn->manakai_local_name eq 'updated') {
52     $updated = $cn;
53     }
54     }
55     }
56    
57     ok defined $id ? 1 : 0, 1, $mn.' [1] id';
58     ok $id->text_content, 'about:id', $mn.' [1] id.text_content';
59     ok defined $title ? 1 : 0, 1, $mn.' [1] title';
60     ok $title->text_content, 'feed title', $mn.' [1] title.text_content';
61     ok $title->get_attribute_ns (undef, 'type'), undef, $mn.' [1] title@type';
62     ok defined $updated ? 1 : 0, 1, $mn.' [1] updated';
63     ok $updated->value > 0 ? 1 : 0, 1, $mn.' [1] updated.value';
64     }
65    
66     ## |AtomTextConstructor| |container|
67     {
68     my $doc = $impl->create_document;
69     my $el = $doc->create_element_ns ($ATOM_NS, 'title');
70    
71     ok $el->container, $el, 'AtomTextConstructor->container #IMPLIED';
72    
73     $el->type ('text');
74     ok $el->container, $el, 'AtomTextConstructor->container text';
75    
76     $el->type ('html');
77     ok $el->container, $el, 'AtomTextConstructor->container html';
78    
79     $el->type ('xhtml');
80     ok $el->container, undef, 'AtomTextConstructor->container xhtml';
81    
82     $doc->dom_config->set_parameter ($CCE => 1);
83     my $con = $el->container;
84     ok $el ne $con ? 1 : 0, 1, 'AtomTextConstructor->container xhtml container';
85     ok $con->parent_node, $el, 'ATC->container xhtml container parentNode';
86     ok $con->namespace_uri, q<http://www.w3.org/1999/xhtml>,
87     'ATC->container xhtml container namespaceURI';
88     ok $con->manakai_local_name, 'div', 'ATC->container xhtml container ln';
89    
90     ok $el->container, $con, 'ATC->container xhtml container [2]';
91     }
92    
93     ## TODO:
94    
95     =head1 LICENSE
96    
97     Copyright 2007 Wakaba <w@suika.fam.cx>
98    
99     This program is free software; you can redistribute it and/or
100     modify it under the same terms as Perl itself.
101    
102     =cut
103    
104     ## $Date: 2007/07/07 05:58:11 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24