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;
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:
The MIME content type, along with parameters, as it appeared in the headers. For instance, it can be:
Don't assume it to be just
text/htmlthough. 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.
Breaks circular references to allow proper reclaiming of unused memory. Must be the last thing to call on the object before forgetting about it.
The error code. Will be 0 to mean OK, but otherwise HTTP error codes are used, as described by HTTP::Status.
Returns a list reference containing all the CGI forms on the page, as
CGI::Test::Formobjects. Will be an empty list for anything but
The amount of forms held in the
Returns true when the page indicates an HTTP error.
Returns true when the page is not the result of an HTTP error.
Returns the server object that returned the page. Currently, this is the
CGI::Testobject, but it might change one day. In any case, this is the place where GET/POST requests may be addresed.
The authenticated user that requested this page, or
undefif no authentication was made.
The original author is Raphael Manfredi.
Steven Hilton was long time maintainer of this module.
Current maintainer is Alexander Tokarev <email@example.com>.