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

# 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;

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.

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_typeThe 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.
deleteBreaks circular references to allow proper reclaiming of unused memory. Must be the last thing to call on the object before forgetting about it.
error_codeThe error code. Will be 0 to mean OK, but otherwise HTTP error codes are used, as described by HTTP::Status.
formsReturns 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_countThe amount of forms held in the forms list.
is_errorReturns true when the page indicates an HTTP error.
is_okReturns true when the page is not the result of an HTTP error.
serverReturns 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.
userThe authenticated user that requested this page, or undef if no authentication was made.

Raphael Manfredi <Raphael_Manfredi@pobox.com>
