Nicholas Bamber > Test-CGI-Multipart > Test::CGI::Multipart::Gen::Image

Download:
Test-CGI-Multipart-v0.0.3.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: v0.0.3   Source  

NAME ^

Test::CGI::Multipart::Gen::Image - Generate image test data for multipart forms

VERSION ^

This document describes Test::CGI::Multipart::Gen::Image version 0.0.3

SYNOPSIS ^

    use Test::CGI::Multipart;
    use Test::CGI::Multipart::Gen::Image;

    my $tcm = Test::CGI::Multipart;

    # specify the form parameters
    $tcm->upload_file(
        name='Image',
        file=>'cleopatra.doc',
        width=>400,
        height=>250,
        instructions=>[
            ['bgcolor,'red'],
            ['fgcolor','blue'],
            ['rectangle',30,30,100,100],
            ['moveTo',280,210],
            ['font','Times:italic'],
            ['fontsize',20],
            ['angle',-90],
            ['string','Helloooooooooooo world!'],
        ],
        type=>'image/jpeg'
    );
    $tcm->set_param(name=>'first_name',value=>'Jim');
    $tcm->set_param(name=>'last_name',value=>'Hacker');

    # Behind the scenes this will fake the browser and web server behaviour
    # with regard to environment variables, MIME format and standard input.
    my $cgi = $tcm->create_cgi;

    # Okay now we have a CGI object which we can pass into the code 
    # that needs testing and run the form handling various tests.

DESCRIPTION ^

This is a callback package for Test::CGI::Multipart that facilitates the testing of the upload of text files of a given size and sample content. One can specify the dimensions of the image and the size, font and colours of a simple string.

INTERFACE ^

For information on how to use this module, see Test::CGI::Multipart especially the section on callbacks. What this module offers is that if the type parameter begins with 'image/' and there is no value parameter you can specify various human comprehensible inputs into the image rather than the raw binary. In particular this covers what appears to be common use cases in testing image upload: namely images of various types, file sizes and dimensions.

type

The MIME type of the content. For this module to be interested this parameter must be set, and must begin with 'image/'. What follows is taken to be the image format and is treated as a function to the GD::Image module.

width, height

These are the requested dimensions of the proposed image. They are mandatory parameters.

font, fontsize, bgcolor, fgcolor, string

These parameters are passed straight through to the GD::Simple module.

DIAGNOSTICS ^

unexpected data structure

During the construction of the MIME data, the internal data structure turned out to have unexpected features. Since we control that data structure that should not happen.

mismatch: is %s a file upload or not

The parameter was being used for both for file upload and normal parameters.

CONFIGURATION AND ENVIRONMENT ^

Test::CGI::Multipart::Gen::Image requires no configuration files or environment variables.

BUGS AND LIMITATIONS ^

No bugs have been reported.

Please report any bugs or feature requests to bug-test-cgi-multipart@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR ^

Nicholas Bamber <nicholas@periapt.co.uk>

LICENCE AND COPYRIGHT ^

Copyright (c) 2010, Nicholas Bamber <nicholas@periapt.co.uk>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY ^

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

syntax highlighting: