CGI-Application-Plugin-AJAXUpload
view release on metacpan or search on metacpan
t/03.images.t view on Meta::CPAN
$c->ajax_upload_httpdocs(nonexistent_dir());
},
},
);
isa_ok($app, 'CGI::Application');
$app->query->param(validate=>1);
$app->response_like(
$CONTENT_RE,
qr/{"status":"Document root is not a directory"}/,
'httpdocs_dir does not exist'
);
};
subtest 'httpdocs_dir not a directory' => sub{
plan tests => 3;
my $actually_a_file = File::Temp->new;
my $app = TestWebApp->new(
QUERY=>$tcm->create_cgi(),
PARAMS=>{
document_root=>sub {
my $c = shift;
$c->ajax_upload_httpdocs($actually_a_file->filename);
},
},
);
isa_ok($app, 'CGI::Application');
$app->query->param(rm=>'ajax_upload_rm');
$app->query->param(validate=>1);
$app->response_like(
$CONTENT_RE,
qr/{"status":"Document root is not a directory"}/,
'httpdocs_dir not a directory'
);
};
subtest 'upload_subdir does not exist' => sub{
plan tests => 3;
my $tmpdir = File::Temp->newdir;
my $app = TestWebApp->new(
QUERY=>$tcm->create_cgi(),
PARAMS=>{
document_root=>sub {
my $c = shift;
$c->ajax_upload_httpdocs($tmpdir->dirname);
},
},
);
isa_ok($app, 'CGI::Application');
$app->query->param(validate=>1);
$app->response_like(
$CONTENT_RE,
qr/{"status":"Upload folder is not a directory"}/,
'upload folder does not exist'
);
};
subtest 'upload_subdir is not writeable' => sub{
plan tests => 3;
my $tmpdir = valid_dir();
my $tmpdir_name = $tmpdir->dirname;
chmod 300, "$tmpdir_name/img/uploads";
my $app = TestWebApp->new(
QUERY=>$tcm->create_cgi(),
PARAMS=>{
document_root=>sub {
my $c = shift;
$c->ajax_upload_httpdocs($tmpdir_name);
},
},
);
isa_ok($app, 'CGI::Application');
$app->query->param(validate=>1);
$app->response_like(
$CONTENT_RE,
qr/{"status":"Upload folder is not writeable"}/,
'Upload folder is not writeable'
);
};
my $tcm2 = Test::CGI::Multipart->new;
$tcm2->set_param(name=>'rm', value=>'ajax_upload_rm');
subtest 'no file parameter' => sub{
plan tests => 3;
my $tmpdir = valid_dir();
my $tmpdir_name = $tmpdir->dirname;
my $app = TestWebApp->new(
QUERY=>$tcm2->create_cgi(),
PARAMS=>{
document_root=>sub {
my $c = shift;
$c->ajax_upload_httpdocs($tmpdir_name);
},
},
);
isa_ok($app, 'CGI::Application');
$app->response_like(
$CONTENT_RE,
qr/{"status":"No file handle obtained"}/,
'no file parameter'
);
};
my $tcm4 = Test::CGI::Multipart->new;
$tcm4->set_param(name=>'rm', value=>'ajax_upload_rm');
$tcm4->upload_file(
name=>'file',
width=>400,
height=>250,
instructions=>$IMAGE_INSTRUCTIONS,
file=>'test*blah.jpeg',
type=>'image/jpeg'
);
subtest 'DFV messages' => sub{
plan tests => 3;
my $tmpdir = valid_dir();
my $tmpdir_name = $tmpdir->dirname;
my $app = TestWebApp->new(
QUERY=>$tcm4->create_cgi(),
PARAMS=>{
document_root=>sub {
my $c = shift;
( run in 0.780 second using v1.01-cache-2.11-cpan-39bf76dae61 )