File: 03-link.t

package info (click to toggle)
libxml-atom-perl 0.23-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 420 kB
  • ctags: 264
  • sloc: perl: 3,357; xml: 663; makefile: 51
file content (40 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# $Id$

use strict;

use Test::More tests => 14;
use XML::Atom::Link;

my $link;

$link = XML::Atom::Link->new;
isa_ok $link, 'XML::Atom::Link';
ok $link->elem;

$link->title('This is a test.');
is $link->title, 'This is a test.';
$link->title('Different title.');
is $link->title, 'Different title.';
$link->title('This is a test.');

$link->rel('alternate');
is $link->rel, 'alternate';

$link->href('http://www.example.com/');
is $link->href, 'http://www.example.com/';

$link->type('text/html');
is $link->type, 'text/html';

my $xml = $link->as_xml;
like $xml, qr/^<\?xml version="1.0" encoding="utf-8"\?>/;
like $xml, qr/<link xmlns="http:\/\/purl.org\/atom\/ns#"/;
like $xml, qr/title="This is a test."/;
like $xml, qr/rel="alternate"/;
like $xml, qr/href="http:\/\/www.example.com\/"/;
like $xml, qr/type="text\/html"/;

my $ns = XML::Atom::Namespace->new(dc => "http://purl.org/dc/elements/1.1/");
$link->set($ns, "subject" => "blah");
$xml = $link->as_xml;
like $xml, qr/dc:subject="blah"/;