File: 14reltag.t

package info (click to toggle)
libhtml-microformats-perl 0.105-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,340 kB
  • sloc: perl: 14,121; makefile: 10; sh: 1
file content (63 lines) | stat: -rw-r--r-- 1,363 bytes parent folder | download | duplicates (5)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use Test::More tests => 8;
use HTML::Microformats;

my $html = <<'HTML';
<html lang=en>

	<section class="vcard">
		<h1 class="fn">Neil Armstrong</h1>
		<a href="/tag/Astronaut" rel="tag">Space Guy</a>
	</section>
	
	<section class="hentry">
		<h1 class="entry-title">Bee Keeping</h1>
		<a href="/tag/Bees" rel="foo tag bar">Bees</a>
	</section>
	
	<a rel="tag" href="/tag/Cats">Cats</a>

HTML

my $document = HTML::Microformats->new_document($html, 'http://example.com/');
$document->assume_all_profiles;

my @tags = sort { $a->get_tag cmp $b->get_tag }
	$document->objects('RelTag');

is($tags[0]->get_tag,
	'Astronaut',
	'tag Astronaut found');

is($tags[1]->get_tag,
	'Bees',
	'tag Bees found');

is($tags[2]->get_tag,
	'Cats',
	'tag Cats found');
	
for my $i (0..2)
{
	is($tags[$i]->get_tagspace,
		'http://example.com/tag/',
		'tag has correct tag space');
}

my $model = $document->model;

is($model->count_statements(
		RDF::Trine::Node::Resource->new('http://example.com/'),
		RDF::Trine::Node::Resource->new('http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag'),
		undef),
	3,
	'Page tagged with three tags.');

my ($armstrong) = $document->objects('hCard');

is($model->count_statements(
		$armstrong->id(1),
		RDF::Trine::Node::Resource->new('http://www.holygoat.co.uk/owl/redwood/0.1/tags/taggedWithTag'),
		undef),
	1,
	'VCard tagged.');