File: basic.t

package info (click to toggle)
librdf-helper-properties-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 228 kB
  • sloc: perl: 1,454; makefile: 10
file content (35 lines) | stat: -rw-r--r-- 980 bytes parent folder | download
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
#!/usr/bin/perl

use FindBin qw($Bin);

use strict;
use Test::More tests => 7;

#use Test::NoWarnings;

my $file = $Bin . '/data/basic.ttl';

BEGIN {
    use_ok('RDF::Helper::Properties');
    use_ok('RDF::Trine::Parser');
    use_ok('RDF::Trine::Model');
}

my $parser     = RDF::Trine::Parser->new( 'turtle' );
my $model = RDF::Trine::Model->temporary_model;
my $base_uri = 'http://localhost:3000';
$parser->parse_file_into_model( $base_uri, $file, $model );

ok($model, "We have a model");

my $preds = RDF::Helper::Properties->new(model => $model);

my $node = RDF::Trine::Node::Resource->new('http://localhost:3000/foo');
my $barnode = RDF::Trine::Node::Resource->new('http://localhost:3000/bar/baz/bing');

is($preds->title($node), 'This is a test', "Correct title");

is($preds->page($node), 'http://en.wikipedia.org/wiki/Foo', "/foo has a foaf:page at Wikipedia");

is($preds->page($barnode), 'http://localhost:3000/bar/baz/bing/page', "/bar/baz/bing has default page");