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