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
|
use strict;
use warnings;
use RT::Test tests => undef;
use Test::Warn;
use_ok "RT::URI::fsck_com_article";
my $uri = RT::URI::fsck_com_article->new( $RT::SystemUser );
ok $uri;
isa_ok $uri, 'RT::URI::fsck_com_article';
isa_ok $uri, 'RT::URI::base';
isa_ok $uri, 'RT::Base';
is $uri->LocalURIPrefix, 'fsck.com-article://example.com';
my $class = RT::Class->new( $RT::SystemUser );
$class->Create( Name => 'URItest - '. $$ );
ok $class->id, 'created a class';
my $article = RT::Article->new( $RT::SystemUser );
my ($id, $msg) = $article->Create(
Name => 'Testing URI parsing - '. $$,
Summary => 'In which this should load',
Class => $class->Id
);
ok($id,$msg);
$uri = RT::URI::fsck_com_article->new( $article->CurrentUser );
is $uri->URIForObject( $article ),
'fsck.com-article://example.com/article/' . $article->id,
'Got correct URIForObject';
my $article_id = $article->Id;
ok ($uri->ParseURI("fsck.com-article://example.com/article/$article_id"),
'Parsed URI');
ok ($article->Delete(), 'Deleted article');
my $ret;
warning_like {
$ret = $uri->ParseURI("fsck.com-article://example.com/article/$article_id");
} qr/Unable to load article for id $article_id. It may have been deleted/,
"Warned about missing article";
ok (!$ret, 'Returned false on missing article');
ok (!$uri->ParseURI("fsck.com-article://foo.com/article/$article_id"),
'ParseURI returned false with incorrect Organization');
done_testing();
|