5 use RT::Test tests => 20;
11 -e $RT::StaticPath . '/images/bpslogo.png'
16 use constant ImageFile => $RT::StaticPath . "/images/$logo";
18 use constant ImageFileContent => do {
20 open my $fh, '<', ImageFile or die ImageFile.$!;
26 my $class = RT::Class->new($RT::SystemUser);
27 my ($ret, $msg) = $class->Create('Name' => 'tlaTestClass-'.$$,
28 'Description' => 'A general-purpose test class');
29 ok($ret, "Test class created");
32 my ($url, $m) = RT::Test->started_ok;
33 isa_ok($m, 'Test::WWW::Mechanize');
34 ok($m->login, 'logged in');
35 $m->follow_link_ok( { text => 'Admin' } );
36 $m->title_is(q/RT Administration/, 'admin screen');
37 $m->follow_link_ok( { text => 'Custom Fields' } );
38 $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
39 $m->follow_link_ok( { text => 'Create', url_regex => qr{^/Admin/CustomFields/} } );
41 form_name => "ModifyCustomField",
43 TypeComposite => 'Image-0',
44 LookupType => 'RT::Class-RT::Article',
49 $m->title_is(qq/Editing CustomField img$$/, 'admin-cf created');
50 $m->follow_link( text => 'Applies to' );
51 $m->title_is(qq/Modify associated objects for img$$/, 'pick cf screenadmin screen');
54 my $tcf = (grep { /AddCustomField-/ } map { $_->name } $m->current_form->inputs )[0];
55 $m->tick( $tcf, 0 ); # Associate the new CF with this queue
56 $m->click('UpdateObjs');
57 $m->content_like( qr/Object created/, 'TCF added to the queue' );
59 $m->follow_link_ok( { text => 'Articles', url_regex => qr!^/Articles/! },
61 $m->follow_link( text => 'New Article');
63 $m->follow_link( url_regex => qr/Edit.html\?Class=1/ );
64 $m->title_is(qq/Create a new article/);
66 $m->content_like(qr/Upload multiple images/, 'has a upload image field');
68 $tcf =~ /(\d+)$/ or die "Hey this is impossible dude";
69 my $upload_field = "Object-RT::Article--CustomField-$1-Upload";
71 diag("Uploading an image to $upload_field") if $ENV{TEST_VERBOSE};
74 form_name => "EditArticle",
76 $upload_field => ImageFile,
77 Name => 'Image Test '.$$,
78 Summary => 'testing img cf creation',
82 $m->content_like(qr/Article \d+ created/, "an article was created succesfully");
84 my $id = $1 if $m->content =~ /Article (\d+) created/;
86 $m->title_like(qr/Modify article #$id/, "Editing article $id");
88 $m->follow_link( text => $logo );
89 $m->content_is(ImageFileContent, "it links to the uploaded image");