6 use RT::Test tests => 20;
12 -e $RT::MasonComponentRoot . '/NoAuth/images/bpslogo.png'
17 use constant ImageFile => $RT::MasonComponentRoot . "/NoAuth/images/$logo";
19 use constant ImageFileContent => do {
21 open my $fh, '<', ImageFile or die ImageFile.$!;
27 my $class = RT::Class->new($RT::SystemUser);
28 my ($ret, $msg) = $class->Create('Name' => 'tlaTestClass-'.$$,
29 'Description' => 'A general-purpose test class');
30 ok($ret, "Test class created");
33 my ($url, $m) = RT::Test->started_ok;
34 isa_ok($m, 'Test::WWW::Mechanize');
35 ok($m->login, 'logged in');
36 $m->follow_link_ok( { text => 'Configuration' } );
37 $m->title_is(q/RT Administration/, 'admin screen');
38 $m->follow_link_ok( { text => 'Custom Fields' } );
39 $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
40 $m->follow_link_ok( { text => 'Create', url_regex => qr{^/Admin/CustomFields/} } );
42 form_name => "ModifyCustomField",
44 TypeComposite => 'Image-0',
45 LookupType => 'RT::Class-RT::Article',
50 $m->title_is(qq/Editing CustomField img$$/, 'admin-cf created');
51 $m->follow_link( text => 'Applies to' );
52 $m->title_is(qq/Modify associated objects for img$$/, 'pick cf screenadmin screen');
55 my $tcf = (grep { /AddCustomField-/ } map { $_->name } $m->current_form->inputs )[0];
56 $m->tick( $tcf, 0 ); # Associate the new CF with this queue
57 $m->click('UpdateObjs');
58 $m->content_like( qr/Object created/, 'TCF added to the queue' );
60 $m->follow_link_ok( { text => 'Articles', url_regex => qr!^/Articles/! },
62 $m->follow_link( text => 'New Article');
64 $m->follow_link( url_regex => qr/Edit.html\?Class=1/ );
65 $m->title_is(qq/Create a new article/);
67 $m->content_like(qr/Upload multiple images/, 'has a upload image field');
69 $tcf =~ /(\d+)$/ or die "Hey this is impossible dude";
70 my $upload_field = "Object-RT::Article--CustomField-$1-Upload";
72 diag("Uploading an image to $upload_field") if $ENV{TEST_VERBOSE};
75 form_name => "EditArticle",
77 $upload_field => ImageFile,
78 Name => 'Image Test '.$$,
79 Summary => 'testing img cf creation',
83 $m->content_like(qr/Article \d+ created/, "an article was created succesfully");
85 my $id = $1 if $m->content =~ /Article (\d+) created/;
87 $m->title_like(qr/Modify article #$id/, "Editing article $id");
89 $m->follow_link( text => $logo );
90 $m->content_is(ImageFileContent, "it links to the uploaded image");