first pass RT4 merge, RT#13852
[freeside.git] / rt / t / api / attachment_filename.t
1 use RT::Test tests => 5;
2 use MIME::Entity;
3 my $ticket = RT::Ticket->new(RT->SystemUser);
4 my $mime   = MIME::Entity->build(
5     From => 'test@example.com',
6     Type => 'text/html',
7     Data => ["test attachment's filename\n"],
8 );
9
10 $mime->attach(
11     Path     => 'share/html/NoAuth/images/bpslogo.png',
12     Type     => 'image/png',
13 );
14
15 $mime->attach(
16     Path     => 'share/html/NoAuth/images/bpslogo.png',
17     Type     => 'image/png',
18     Filename => 'bpslogo.png',
19 );
20
21 $mime->attach(
22     Path     => 'share/html/NoAuth/images/bpslogo.png',
23     Filename => 'images/bpslogo.png',
24     Type     => 'image/png',
25 );
26
27 my $id = $ticket->Create( MIMEObj => $mime, Queue => 'General' );
28 ok( $id, "created ticket $id" );
29
30 my $atts = RT::Attachments->new( RT->SystemUser );
31 $atts->Limit( FIELD => 'ContentType', VALUE => 'image/png' );
32 is( $atts->Count, 3, 'got 3 png files' );
33
34 # no matter if mime's filename include path or not,
35 # we should throw away the path all the time.
36 while ( my $att = $atts->Next ) {
37     is( $att->Filename, 'bpslogo.png', "attachment's filename" );
38 }
39