diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-07-09 22:18:55 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-07-09 22:18:55 -0700 |
commit | 1c538bfabc2cd31f27067505f0c3d1a46cba6ef0 (patch) | |
tree | 96922ad4459eda1e649327fd391d60c58d454c53 /rt/t/articles | |
parent | 4f5619288413a185e9933088d9dd8c5afbc55dfa (diff) |
RT 4.2.11, ticket#13852
Diffstat (limited to 'rt/t/articles')
-rw-r--r-- | rt/t/articles/interface.t | 138 | ||||
-rw-r--r-- | rt/t/articles/search-interface.t | 108 | ||||
-rw-r--r-- | rt/t/articles/set-subject.t | 110 | ||||
-rw-r--r-- | rt/t/articles/upload-customfields.t | 8 | ||||
-rw-r--r-- | rt/t/articles/uri-articles.t | 26 |
5 files changed, 263 insertions, 127 deletions
diff --git a/rt/t/articles/interface.t b/rt/t/articles/interface.t index 779127fa6..0aeefe7ca 100644 --- a/rt/t/articles/interface.t +++ b/rt/t/articles/interface.t @@ -20,11 +20,11 @@ my ($ret, $msg); # Create a test class my $class = RT::Class->new($RT::SystemUser); ($ret, $msg) = $class->Create('Name' => 'tlaTestClass-'.$$, - 'Description' => 'A general-purpose test class'); + 'Description' => 'A general-purpose test class'); ok($ret, "Test class created"); my $class2 = RT::Class->new($RT::SystemUser); ($ret, $msg) = $class2->Create('Name' => 'tlaTestClass2-'.$$, - 'Description' => 'Another general-purpose test class'); + 'Description' => 'Another general-purpose test class'); ok($ret, "Test class 2 created"); @@ -36,34 +36,34 @@ my $topic2 = RT::Topic->new($RT::SystemUser); my $topic_class2= RT::Topic->new($RT::SystemUser); my $gtopic = RT::Topic->new($RT::SystemUser); ($ret, $msg) = $topic1->Create('Parent' => 0, - 'Name' => 'tlaTestTopic1-'.$$, - 'ObjectType' => 'RT::Class', - 'ObjectId' => $class->Id); + 'Name' => 'tlaTestTopic1-'.$$, + 'ObjectType' => 'RT::Class', + 'ObjectId' => $class->Id); ok($ret, "Topic 1 created"); ($ret, $msg) = $topic11->Create('Parent' => $topic1->Id, - 'Name' => 'tlaTestTopic1.1-'.$$, - 'ObjectType' => 'RT::Class', - 'ObjectId' => $class->Id); + 'Name' => 'tlaTestTopic1.1-'.$$, + 'ObjectType' => 'RT::Class', + 'ObjectId' => $class->Id); ok($ret, "Topic 1.1 created"); ($ret, $msg) = $topic12->Create('Parent' => $topic1->Id, - 'Name' => 'tlaTestTopic1.2-'.$$, - 'ObjectType' => 'RT::Class', - 'ObjectId' => $class->Id); + 'Name' => 'tlaTestTopic1.2-'.$$, + 'ObjectType' => 'RT::Class', + 'ObjectId' => $class->Id); ok($ret, "Topic 1.2 created"); ($ret, $msg) = $topic2->Create('Parent' => 0, - 'Name' => 'tlaTestTopic2-'.$$, - 'ObjectType' => 'RT::Class', - 'ObjectId' => $class->Id); + 'Name' => 'tlaTestTopic2-'.$$, + 'ObjectType' => 'RT::Class', + 'ObjectId' => $class->Id); ok($ret, "Topic 2 created"); ($ret, $msg) = $topic_class2->Create('Parent' => 0, - 'Name' => 'tlaTestTopicClass2-'.$$, - 'ObjectType' => 'RT::Class', - 'ObjectId' => $class2->Id); + 'Name' => 'tlaTestTopicClass2-'.$$, + 'ObjectType' => 'RT::Class', + 'ObjectId' => $class2->Id); ok($ret, "Topic Class2 created"); ($ret, $msg) = $gtopic->Create('Parent' => 0, - 'Name' => 'tlaTestTopicGlobal-'.$$, - 'ObjectType' => 'RT::System', - 'ObjectId' => $RT::System->Id ); + 'Name' => 'tlaTestTopicGlobal-'.$$, + 'ObjectType' => 'RT::System', + 'ObjectId' => $RT::System->Id ); ok($ret, "Global Topic created"); # Create some article custom fields @@ -71,18 +71,18 @@ ok($ret, "Global Topic created"); my $questionCF = RT::CustomField->new($RT::SystemUser); my $answerCF = RT::CustomField->new($RT::SystemUser); ($ret, $msg) = $questionCF->Create('Name' => 'Question-'.$$, - 'Type' => 'Text', - 'MaxValues' => 1, - 'LookupType' => 'RT::Class-RT::Article', - 'Description' => 'The question to be answered', - 'Disabled' => 0); + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The question to be answered', + 'Disabled' => 0); ok($ret, "Question CF created: $msg"); ($ret, $msg) = $answerCF->Create('Name' => 'Answer-'.$$, - 'Type' => 'Text', - 'MaxValues' => 1, - 'LookupType' => 'RT::Class-RT::Article', - 'Description' => 'The answer to the question', - 'Disabled' => 0); + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The answer to the question', + 'Disabled' => 0); ok($ret, "Answer CF created: $msg"); # Attach the custom fields to our class @@ -93,13 +93,13 @@ ok($ret, "Answer CF added to class: $msg"); my ($qid, $aid) = ($questionCF->Id, $answerCF->Id); my %cvals = ('article1q' => 'Some question about swallows', - 'article1a' => 'Some answer about Europe and Africa', - 'article2q' => 'Another question about Monty Python', - 'article2a' => 'Romani ite domum', - 'article3q' => 'Why should I eat my supper?', - 'article3a' => 'There are starving children in Africa', - 'article4q' => 'What did Brian originally write?', - 'article4a' => 'Romanes eunt domus'); + 'article1a' => 'Some answer about Europe and Africa', + 'article2q' => 'Another question about Monty Python', + 'article2a' => 'Romani ite domum', + 'article3q' => 'Why should I eat my supper?', + 'article3a' => 'There are starving children in Africa', + 'article4q' => 'What did Brian originally write?', + 'article4a' => 'Romanes eunt domus'); # Create an article or two with our custom field values. @@ -108,36 +108,36 @@ my $article2 = RT::Article->new($RT::SystemUser); my $article3 = RT::Article->new($RT::SystemUser); my $article4 = RT::Article->new($RT::SystemUser); ($ret, $msg) = $article1->Create(Name => 'First article '.$$, - Summary => 'blah blah 1', - Class => $class->Id, - Topics => [$topic1->Id], - "CustomField-$qid" => $cvals{'article1q'}, - "CustomField-$aid" => $cvals{'article1a'}, - ); + Summary => 'blah blah 1', + Class => $class->Id, + Topics => [$topic1->Id], + "CustomField-$qid" => $cvals{'article1q'}, + "CustomField-$aid" => $cvals{'article1a'}, + ); ok($ret, "article 1 created"); ($ret, $msg) = $article2->Create(Name => 'Second article '.$$, - Summary => 'foo bar 2', - Class => $class->Id, - Topics => [$topic11->Id], - "CustomField-$qid" => $cvals{'article2q'}, - "CustomField-$aid" => $cvals{'article2a'}, - ); + Summary => 'foo bar 2', + Class => $class->Id, + Topics => [$topic11->Id], + "CustomField-$qid" => $cvals{'article2q'}, + "CustomField-$aid" => $cvals{'article2a'}, + ); ok($ret, "article 2 created"); ($ret, $msg) = $article3->Create(Name => 'Third article '.$$, - Summary => 'ping pong 3', - Class => $class->Id, - Topics => [$topic12->Id], - "CustomField-$qid" => $cvals{'article3q'}, - "CustomField-$aid" => $cvals{'article3a'}, - ); + Summary => 'ping pong 3', + Class => $class->Id, + Topics => [$topic12->Id], + "CustomField-$qid" => $cvals{'article3q'}, + "CustomField-$aid" => $cvals{'article3a'}, + ); ok($ret, "article 3 created"); ($ret, $msg) = $article4->Create(Name => 'Fourth article '.$$, - Summary => 'hoi polloi 4', - Class => $class->Id, - Topics => [$topic2->Id], - "CustomField-$qid" => $cvals{'article4q'}, - "CustomField-$aid" => $cvals{'article4a'}, - ); + Summary => 'hoi polloi 4', + Class => $class->Id, + Topics => [$topic2->Id], + "CustomField-$qid" => $cvals{'article4q'}, + "CustomField-$aid" => $cvals{'article4a'}, + ); ok($ret, "article 4 created"); # Create a ticket. @@ -152,8 +152,8 @@ May as well say something about Africa.'); my $ticket = RT::Ticket->new($RT::SystemUser); my $obj; ($ret, $obj, $msg) = $ticket->Create(Queue => 'General', - Subject => 'test ticket for articles '.$$, - MIMEObj => $parser->Entity); + Subject => 'test ticket for articles '.$$, + MIMEObj => $parser->Entity); ok($ret, "Test ticket for articles created: $msg"); @@ -161,7 +161,7 @@ ok($ret, "Test ticket for articles created: $msg"); isa_ok($m, 'Test::WWW::Mechanize'); ok($m->login, 'logged in'); -$m->follow_link_ok( { text => 'Articles', url_regex => qr!^/Articles/! }, +$m->follow_link_ok( { text => 'Articles', url_regex => qr!^/Articles/index.html! }, 'UI -> Articles' ); $m->content_contains($article3->Name); @@ -175,9 +175,9 @@ my $ticket_id = $ticket->Id; my $turi = "t:$ticket_id"; my $a1uri = 'a:'.$article1->Id; $m->submit_form(form_name => 'EditArticle', - fields => { $article3->Id.'-RefersTo' => $turi, - 'RefersTo-'.$article3->Id => $a1uri } - ); + fields => { $article3->Id.'-RefersTo' => $turi, + 'RefersTo-'.$article3->Id => $a1uri } + ); $m->content_like(qr/Ticket.*$ticket_id/, "Ticket linkto was created"); $m->content_like(qr/URI.*$a1uri/, "Article linkfrom was created"); @@ -185,7 +185,7 @@ $m->content_like(qr/URI.*$a1uri/, "Article linkfrom was created"); # Now try to extract an article from a link. $m->get_ok($url."/Ticket/Display.html?id=".$ticket->Id, - "Loaded ticket display"); + "Loaded ticket display"); $m->content_like(qr/Extract Article/, "Article extraction link shows up"); $m->follow_link_ok( { text => 'Extract Article' }, '-> Extract Article' ); $m->content_contains($class->Name); @@ -203,7 +203,7 @@ $m->title_like(qr/Modify article/); $m->follow_link_ok( { text => 'Display' }, '-> Display' ); $m->content_like(qr/Africa/, "Article content exist"); $m->content_contains($ticket->Subject, - "Article references originating ticket"); + "Article references originating ticket"); diag("Test creating a ticket in Class2 and make sure we don't see Class1 Topics") if $ENV{TEST_VERBOSE}; { diff --git a/rt/t/articles/search-interface.t b/rt/t/articles/search-interface.t index e957a6c31..3c75268b9 100644 --- a/rt/t/articles/search-interface.t +++ b/rt/t/articles/search-interface.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test tests => 44; +use RT::Test tests => undef; use RT::CustomField; use RT::Queue; @@ -16,36 +16,39 @@ my ($url, $m) = RT::Test->started_ok; # Variables to test return values my ($ret, $msg); -# Create a test class +# Create two classes my $class = RT::Class->new($RT::SystemUser); -($ret, $msg) = $class->Create('Name' => 'tlaTestClass-'.$$, - 'Description' => 'A general-purpose test class'); +($ret, $msg) = $class->Create('Name' => 'First-class', + 'Description' => 'A general-purpose test class'); ok($ret, "Test class created"); +($ret, $msg) = $class->Create('Name' => 'Second-class', + 'Description' => 'Another class'); +ok($ret, "Test class created"); my $questionCF = RT::CustomField->new($RT::SystemUser); my $answerCF = RT::CustomField->new($RT::SystemUser); my $ticketCF = RT::CustomField->new($RT::SystemUser); ($ret, $msg) = $questionCF->Create('Name' => 'Question-'.$$, - 'Type' => 'Text', - 'MaxValues' => 1, - 'LookupType' => 'RT::Class-RT::Article', - 'Description' => 'The question to be answered', - 'Disabled' => 0); + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The question to be answered', + 'Disabled' => 0); ok($ret, "Question CF created: $msg"); ($ret, $msg) = $answerCF->Create('Name' => 'Answer-'.$$, - 'Type' => 'Text', - 'MaxValues' => 1, - 'LookupType' => 'RT::Class-RT::Article', - 'Description' => 'The answer to the question', - 'Disabled' => 0); + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The answer to the question', + 'Disabled' => 0); ok($ret, "Answer CF created: $msg"); ($ret, $msg) = $ticketCF->Create('Name' => 'Class', - 'Type' => 'Text', - 'MaxValues' => 1, - 'LookupType' => 'RT::Queue-RT::Ticket', - 'Disabled' => 0); + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Queue-RT::Ticket', + 'Disabled' => 0); ok($ret, "Ticket CF 'Class' created: $msg"); # Attach the custom fields to our class @@ -60,18 +63,18 @@ my $global_queue = RT::Queue->new($RT::SystemUser); ok($ret, "Ticket CF added globally: $msg"); my %cvals = ('article1q' => 'Some question about swallows', - 'article1a' => 'Some answer about Europe and Africa', - 'article2q' => 'Another question about Monty Python', - 'article2a' => 'Romani ite domum', - 'article3q' => 'Why should I eat my supper?', - 'article3a' => 'There are starving children in Africa', - 'article4q' => 'What did Brian originally write?', - 'article4a' => 'This is an answer that is longer than 255 ' - . 'characters so these tests will be sure to use the LargeContent ' - . 'SQL as well as the normal SQL that would be generated if this ' - . 'was an answer that was shorter than 255 characters. This second ' - . 'sentence has a few extra characters to get this string to go ' - . 'over the 255 character boundary. Lorem ipsum.'); + 'article1a' => 'Some answer about Europe and Africa', + 'article2q' => 'Another question about Monty Python', + 'article2a' => 'Romani ite domum', + 'article3q' => 'Why should I eat my supper?', + 'article3a' => 'There are starving children in Africa', + 'article4q' => 'What did Brian originally write?', + 'article4a' => 'This is an answer that is longer than 255 ' + . 'characters so these tests will be sure to use the LargeContent ' + . 'SQL as well as the normal SQL that would be generated if this ' + . 'was an answer that was shorter than 255 characters. This second ' + . 'sentence has a few extra characters to get this string to go ' + . 'over the 255 character boundary. Lorem ipsum.'); # Create an article or two with our custom field values. @@ -80,32 +83,32 @@ my $article2 = RT::Article->new($RT::SystemUser); my $article3 = RT::Article->new($RT::SystemUser); my $article4 = RT::Article->new($RT::SystemUser); ($ret, $msg) = $article1->Create(Name => 'First article '.$$, - Summary => 'blah blah 1', - Class => $class->Id, - "CustomField-$qid" => $cvals{'article1q'}, - "CustomField-$aid" => $cvals{'article1a'}, - ); + Summary => 'blah blah 1', + Class => $class->Id, + "CustomField-$qid" => $cvals{'article1q'}, + "CustomField-$aid" => $cvals{'article1a'}, + ); ok($ret, "article 1 created"); ($ret, $msg) = $article2->Create(Name => 'Second article '.$$, - Summary => 'foo bar 2', - Class => $class->Id, - "CustomField-$qid" => $cvals{'article2q'}, - "CustomField-$aid" => $cvals{'article2a'}, - ); + Summary => 'foo bar 2', + Class => $class->Id, + "CustomField-$qid" => $cvals{'article2q'}, + "CustomField-$aid" => $cvals{'article2a'}, + ); ok($ret, "article 2 created"); ($ret, $msg) = $article3->Create(Name => 'Third article '.$$, - Summary => 'ping pong 3', - Class => $class->Id, - "CustomField-$qid" => $cvals{'article3q'}, - "CustomField-$aid" => $cvals{'article3a'}, - ); + Summary => 'ping pong 3', + Class => $class->Id, + "CustomField-$qid" => $cvals{'article3q'}, + "CustomField-$aid" => $cvals{'article3a'}, + ); ok($ret, "article 3 created"); ($ret, $msg) = $article4->Create(Name => 'Fourth article '.$$, - Summary => 'hoi polloi 4', - Class => $class->Id, - "CustomField-$qid" => $cvals{'article4q'}, - "CustomField-$aid" => $cvals{'article4a'}, - ); + Summary => 'hoi polloi 4', + Class => $class->Id, + "CustomField-$qid" => $cvals{'article4q'}, + "CustomField-$aid" => $cvals{'article4a'}, + ); ok($ret, "article 4 created"); isa_ok($m, 'Test::WWW::Mechanize'); @@ -140,6 +143,9 @@ TODO:{ $m->text_contains('hoi polloi 4'); } +undef $m; +done_testing; + # When you send $m to this sub, it must be on a page with # a Search link. sub DoArticleSearch{ @@ -147,7 +153,7 @@ sub DoArticleSearch{ my $class_name = shift; my $search_text = shift; - $m->follow_link_ok( {text => 'Search'}, 'Articles -> Search'); + $m->follow_link_ok( {text => 'Articles'}, 'Articles Search'); $m->follow_link_ok( {text => 'in class '. $class_name}, 'Articles in class '. $class_name); $m->text_contains('First article'); diff --git a/rt/t/articles/set-subject.t b/rt/t/articles/set-subject.t new file mode 100644 index 000000000..9b9ff850a --- /dev/null +++ b/rt/t/articles/set-subject.t @@ -0,0 +1,110 @@ +use strict; +use warnings; + +use RT::Test tests => undef; + +use RT::CustomField; +use RT::EmailParser; +use RT::Queue; +use RT::Ticket; +use_ok 'RT::Class'; +use_ok 'RT::Topic'; +use_ok 'RT::Article'; + +# Variables to test return values +my ($ret, $msg); + +# Create a test class +my $class = RT::Class->new($RT::SystemUser); +($ret, $msg) = $class->Create('Name' => 'TestClass-'.$$, + 'Description' => 'A general-purpose test class'); +ok($ret, "Test class created: $msg"); +# because id 0 represents global, it uses an empty Queue object... +($ret, $msg) = $class->AddToObject(RT::Queue->new($RT::SystemUser)); +ok($ret, "Applied Class globally: $msg"); + +# Create some article custom fields +my $bodyCF = RT::CustomField->new($RT::SystemUser); +my $subjectCF = RT::CustomField->new($RT::SystemUser); +($ret, $msg) = $subjectCF->Create('Name' => 'Subject-'.$$, + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The subject to be answered', + 'Disabled' => 0); +ok($ret, "Question CF created: $msg"); +($ret, $msg) = $bodyCF->Create('Name' => 'Body-'.$$, + 'Type' => 'Text', + 'MaxValues' => 1, + 'LookupType' => 'RT::Class-RT::Article', + 'Description' => 'The body to the subject', + 'Disabled' => 0); +ok($ret, "Answer CF created: $msg"); +my ($sid, $bid) = ($subjectCF->Id, $bodyCF->Id); + +# Attach the custom fields to our class +($ret, $msg) = $subjectCF->AddToObject($class); +ok($ret, "Subject CF added to class: $msg"); +($ret, $msg) = $bodyCF->AddToObject($class); +ok($ret, "Body CF added to class: $msg"); + +my $article = RT::Article->new($RT::SystemUser); +($ret, $msg) = $article->Create(Name => 'First article '.$$, + Summary => 'blah blah 1', + Class => $class->Id, + "CustomField-$bid" => 'This goes in the body', + "CustomField-$sid" => 'This clobbers your subject', + ); +ok($ret, "article 1 created: $msg"); + +# Create a ticket. +my $parser = RT::EmailParser->new(); +$parser->ParseMIMEEntityFromScalar('From: root@localhost +To: rt@example.com +Subject: test ticket for articles + +This is some form of new request. +May as well say something about Africa.'); + +my $ticket = RT::Ticket->new($RT::SystemUser); +my $obj; +($ret, $obj, $msg) = $ticket->Create(Queue => 'General', + Subject => 'test ticket for articles '.$$, + MIMEObj => $parser->Entity); +ok($ret, "Test ticket for articles created: $msg"); + + +#### Right. That's our data. Now begin the real testing. + +my ($url, $m) = RT::Test->started_ok; +ok($m->login, 'logged in'); + +$m->get_ok( '/Ticket/Update.html?Action=Comment&id=' . $ticket->id, + 'ticket update page' ); +is($m->form_number(3)->find_input('UpdateSubject')->value,$ticket->Subject,'Ticket Subject Found'); +$m->submit_form( + form_number => 3, + fields => { 'Articles-Include-Article-Named' => $article->Id }, + button => 'Go', +); +is($m->form_number(3)->find_input('UpdateSubject')->value,$ticket->Subject,'Ticket Subject Not Clobbered'); + +$m->get_ok("$url/Admin/Articles/Classes/"); +$m->follow_link_ok( { text => 'TestClass-'.$$ } ); +$m->submit_form_ok({ + form_number => 3, + fields => { SubjectOverride => $sid }, +}); +$m->content_contains("Added Subject Override: Subject-$$"); + +$m->get_ok( '/Ticket/Update.html?Action=Comment&id=' . $ticket->id, + 'ticket update page' ); +is($m->form_number(3)->find_input('UpdateSubject')->value,$ticket->Subject,'Ticket Subject Found'); +$m->submit_form( + form_number => 3, + fields => { 'Articles-Include-Article-Named' => $article->Name }, + button => 'Go', +); +is($m->form_number(3)->find_input('UpdateSubject')->value,$article->FirstCustomFieldValue("Subject-$$"),'Ticket Subject Clobbered'); +undef $m; +done_testing; diff --git a/rt/t/articles/upload-customfields.t b/rt/t/articles/upload-customfields.t index e5ed5d190..29bd677ca 100644 --- a/rt/t/articles/upload-customfields.t +++ b/rt/t/articles/upload-customfields.t @@ -8,12 +8,12 @@ use RT; my $logo; BEGIN { $logo = - -e $RT::MasonComponentRoot . '/NoAuth/images/bpslogo.png' + -e $RT::StaticPath . '/images/bpslogo.png' ? 'bpslogo.png' : 'bplogo.gif'; } -use constant ImageFile => $RT::MasonComponentRoot . "/NoAuth/images/$logo"; +use constant ImageFile => $RT::StaticPath . "/images/$logo"; use constant ImageFileContent => do { local $/; @@ -25,14 +25,14 @@ use constant ImageFileContent => do { use RT::Class; my $class = RT::Class->new($RT::SystemUser); my ($ret, $msg) = $class->Create('Name' => 'tlaTestClass-'.$$, - 'Description' => 'A general-purpose test class'); + 'Description' => 'A general-purpose test class'); ok($ret, "Test class created"); my ($url, $m) = RT::Test->started_ok; isa_ok($m, 'Test::WWW::Mechanize'); ok($m->login, 'logged in'); -$m->follow_link_ok( { text => 'Configuration' } ); +$m->follow_link_ok( { text => 'Admin' } ); $m->title_is(q/RT Administration/, 'admin screen'); $m->follow_link_ok( { text => 'Custom Fields' } ); $m->title_is(q/Select a Custom Field/, 'admin-cf screen'); diff --git a/rt/t/articles/uri-articles.t b/rt/t/articles/uri-articles.t index b6a1c8dac..9ad4b0724 100644 --- a/rt/t/articles/uri-articles.t +++ b/rt/t/articles/uri-articles.t @@ -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 ); @@ -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 - '. $$ ); @@ -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(); |