root/XML-Atom-0.22/t/19-ext.t

Revision 397, 1.1 kB (checked in by miya, 2 years ago)

--

Line 
1 # $Id: /mirror/cpan/xml-atom/trunk/t/19-ext.t 2891 2006-06-29T04:18:47.205655Z btrott  $
2
3 use strict;
4 use FindBin;
5 use Test::More tests => 9;
6
7 use XML::Atom::Feed;
8
9 my $foo = XML::Atom::Ext::Foo->new;
10 isa_ok $foo, 'XML::Atom::Ext::Foo';
11 $foo->bar(1);
12 is $foo->bar, 1;
13 like $foo->as_xml, qr/<foo xmlns="http:\/\/www.example.com\/ns\/">/;
14 like $foo->as_xml, qr/<bar xmlns="http:\/\/www.example.com\/ns\/">1<\/bar>/;
15
16 my $feed = XML::Atom::Feed->new;
17 $feed->foo($foo);
18 my $foo2 = $feed->foo;
19 isa_ok $foo2, 'XML::Atom::Ext::Foo';
20 is $foo2->bar, 1;
21
22 ## Make sure the alternate name works.
23 $feed->foo2($foo);
24 $foo2 = $feed->foo2;
25 isa_ok $foo2, 'XML::Atom::Ext::Foo';
26 is $foo2->bar, 1;
27
28 like $feed->as_xml, qr/<(?:\w+:)foo xmlns="http:\/\/www.example.com\/ns\/">/;
29
30 package XML::Atom::Ext::Foo;
31 use strict;
32 use base qw( XML::Atom::Base );
33
34 BEGIN {
35     __PACKAGE__->mk_elem_accessors('bar');
36     XML::Atom::Feed->mk_object_accessor( foo => __PACKAGE__ );
37     XML::Atom::Feed->mk_object_accessor( foo2 => __PACKAGE__ );
38 }
39
40 sub element_name { 'foo' }
41 sub element_ns   { 'http://www.example.com/ns/' }
Note: See TracBrowser for help on using the browser.