Skip to content

Commit

Permalink
Update tests to reflect API consistent with ticket links
Browse files Browse the repository at this point in the history
Also expand test coverage to handle additional failure cases.
  • Loading branch information
cbrandtbuffalo committed Feb 26, 2014
1 parent ef6c7ba commit fb647e0
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions t/articles/uri-articles.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use strict;
use warnings;

use RT::Test tests => 9;
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 );
Expand All @@ -12,7 +13,7 @@ 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/article/';
is $uri->LocalURIPrefix, 'fsck.com-article://example.com';

my $class = RT::Class->new( $RT::SystemUser );
$class->Create( Name => 'URItest - '. $$ );
Expand All @@ -26,5 +27,24 @@ my ($id, $msg) = $article->Create(
ok($id,$msg);

$uri = RT::URI::fsck_com_article->new( $article->CurrentUser );
is $uri->LocalURIPrefix . $article->id, $uri->URIForObject( $article );
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();

0 comments on commit fb647e0

Please sign in to comment.