Lines 3-9
Link Here
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
use File::Temp qw/tempdir/; |
4 |
use File::Temp qw/tempdir/; |
5 |
use Test::CGI::Multipart; |
5 |
use Test::CGI::Multipart; |
6 |
use Test::More tests => 20; |
6 |
use Test::More tests => 21; |
7 |
use Test::Warn; |
7 |
use Test::Warn; |
8 |
|
8 |
|
9 |
use t::lib::Mocks; |
9 |
use t::lib::Mocks; |
Lines 11-16
use t::lib::Mocks;
Link Here
|
11 |
use C4::Context; |
11 |
use C4::Context; |
12 |
use C4::UploadedFiles; |
12 |
use C4::UploadedFiles; |
13 |
|
13 |
|
|
|
14 |
my $dbh = C4::Context->dbh; |
15 |
$dbh->{AutoCommit} = 0; |
16 |
$dbh->{RaiseError} = 1; |
17 |
|
14 |
# This simulates a multipart POST request with a file upload. |
18 |
# This simulates a multipart POST request with a file upload. |
15 |
my $tcm = new Test::CGI::Multipart; |
19 |
my $tcm = new Test::CGI::Multipart; |
16 |
$tcm->upload_file( |
20 |
$tcm->upload_file( |
Lines 70-72
mkdir $temp2.'/A/AA';
Link Here
|
70 |
mkdir $temp2.'/A/BB'; |
74 |
mkdir $temp2.'/A/BB'; |
71 |
$a= C4::UploadedFiles::finddirs( $temp2 ); |
75 |
$a= C4::UploadedFiles::finddirs( $temp2 ); |
72 |
is( @{$a->[0]->{dirs}} == 2, 1, 'Finddir returns subdirectories' ); |
76 |
is( @{$a->[0]->{dirs}} == 2, 1, 'Finddir returns subdirectories' ); |
73 |
- |
77 |
|
|
|
78 |
#tests for MaxUploadSize |
79 |
subtest 'Tests for MaxUploadSize' => sub { |
80 |
test_max(); |
81 |
}; |
82 |
|
83 |
#end of game |
84 |
$dbh->rollback; |
85 |
|
86 |
sub test_max { |
87 |
$dbh->do("DELETE FROM upload_settings"); |
88 |
my $max = C4::UploadedFiles::MaxUploadSize(); |
89 |
is( $max, 10000000, 'MaxUploadSize is equal to fallback' ); |
90 |
|
91 |
$dbh->do("INSERT INTO upload_settings (type, count1) VALUES (?, ?)", |
92 |
undef, ( 'filesize', 500 )); |
93 |
$max = C4::UploadedFiles::MaxUploadSize(); |
94 |
is( $max, 500, 'MaxUploadSize is equal to default' ); |
95 |
|
96 |
my $borr = $dbh->selectall_arrayref( |
97 |
'SELECT borrowernumber FROM borrowers LIMIT 2' ); |
98 |
if( @$borr < 2 ) { |
99 |
done_testing(2); |
100 |
return; |
101 |
} |
102 |
my $b1 = $borr->[0]->[0]; |
103 |
$dbh->do("INSERT INTO upload_settings (borrowernumber, type, count1) |
104 |
VALUES (?, ?, ?)", undef, ( $b1, 'filesize', 1500 )); |
105 |
$max = C4::UploadedFiles::MaxUploadSize($b1); |
106 |
is( $max, 1500, 'MaxUploadSize is equal to user limit' ); |
107 |
|
108 |
my $b2 = $borr->[1]->[0]; |
109 |
$max = C4::UploadedFiles::MaxUploadSize($b2); |
110 |
is( $max, 500, 'MaxUploadSize is still equal to default for user 2' ); |
111 |
done_testing(4); |
112 |
} |