Man pages sections > man3 > CGI::Test::Page

CGI::Test::Page - Abstract represention of an HTTP reply content

CGI::Test::Page(3pm) User Contributed Perl Documentation CGI::Test::Page(3pm)

NAME

CGI::Test::Page - Abstract represention of an HTTP reply content

SYNOPSIS

 # Deferred class, only heirs can be created
 # $page holds a CGI::Test::Page object
 use CGI::Test;
 ok 1, $page->is_ok;
 ok 2, $page->user ne '';    # authenticated access
 my $ctype = $page->content_type;
 ok 3, $ctype eq "text/plain";
 $page->delete;

DESCRIPTION

The "CGI::Test::Page" class is deferred. It is an abstract representation of an HTTP reply content, which would be displayed on a browser, as a page. It does not necessarily hold HTML content.
Here is an outline of the class hierarchy tree, with the leading "CGI::Test::" string stripped for readability, and a trailing "*" indicating deferred clases:
    Page*
      Page::Error
      Page::Real*
        Page::HTML
        Page::Other
        Page::Text
Those classes are constructed as needed by "CGI::Test". You must always call delete on them to break the circular references if you care about reclaiming unused memory.

INTERFACE

This is the interface defined at the "CGI::Test::Page" level. Each subclass may add further specific features, but the following is available to the whole hierarchy:
"content_type"
The MIME content type, along with parameters, as it appeared in the headers. For instance, it can be:
 
        text/html; charset=ISO-8859-1
    
 
Don't assume it to be just "text/html" though. Use something like:
 
        ok 1, $page->content_type =~ m|^text/html\b|;
    
 
in your regression tests, which will match whether there are parameters following the content type or not.
"delete"
Breaks circular references to allow proper reclaiming of unused memory. Must be the last thing to call on the object before forgetting about it.
"error_code"
The error code. Will be 0 to mean OK, but otherwise HTTP error codes are used, as described by HTTP::Status.
"forms"
Returns a list reference containing all the CGI forms on the page, as "CGI::Test::Form" objects. Will be an empty list for anything but "CGI::Test::Page::HTML", naturally.
"form_count"
The amount of forms held in the "forms" list.
"is_error"
Returns true when the page indicates an HTTP error.
"is_ok"
Returns true when the page is not the result of an HTTP error.
"server"
Returns the server object that returned the page. Currently, this is the "CGI::Test" object, but it might change one day. In any case, this is the place where GET/POST requests may be addresed.
"user"
The authenticated user that requested this page, or "undef" if no authentication was made.

AUTHORS

The original author is Raphael Manfredi.
Steven Hilton was long time maintainer of this module.
Current maintainer is Alexander Tokarev <tokarev@cpan.org>.

SEE ALSO

CGI::Test::Page::Error(3), CGI::Test::Page::Real(3).
2016-02-04 perl v5.22.1