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
|
use Test::More tests => 5;
BEGIN { use_ok('XML::Atom::Microformats') };
my $xml = <<XML;
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<id>http://example.com/id/1</id>
<content type="text/html">
<p class="vcard"><span class="fn">Alice</span></p>
</content>
<link rel="self" href="http://example.com/article/1" />
<link rel="profile" href="http://ufs.cc/x/hcard" />
</entry>
<entry xml:base="http://bob.com/">
<foo property=":fooble">lala</foo>
<id>http://example.com/id/2</id>
<content type="text/html">
<p class="vcard"><a href="/foo" class="fn url">Bob</a></p>
</content>
<link rel="self" href="http://example.com/article/2" />
</entry>
</feed>
XML
ok(
my $model1 = XML::Atom::Microformats->new_feed($xml, "http://example.net/")->model,
"Was able to build a model",
);
ok(
my $model2 = XML::Atom::Microformats->new_feed($xml, "http://example.net/")->assume_profile('hCard')->model,
"Was able to build a model, assuming hCard profile",
);
is(
$model1->count_statements(
undef,
RDF::Trine::Node::Resource->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
RDF::Trine::Node::Resource->new('http://www.w3.org/2006/vcard/ns#VCard'),
),
1,
"When not assuming profiles, only an explicitly profiled hCard is found."
);
is(
$model2->count_statements(
undef,
RDF::Trine::Node::Resource->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
RDF::Trine::Node::Resource->new('http://www.w3.org/2006/vcard/ns#VCard'),
),
2,
"When assuming hCard profile, both hCards are found."
);
|