NAME
ASP4::API - Your ASP4 Web App's Public API
SYNOPSIS
#!/usr/bin/perl -w
use strict;
use warnings 'all';
use ASP4::API;
my $api; BEGIN { $api = ASP4::API->new }
# Now you can use your other classes:
use My::User;
use My::Product;
use My::Foo;
# Use the API:
my $res = $api->ua->get('/index.asp');
if( $res->is_success ) {
print $res->content;
}
# Access your test data:
warn $res->test_data->contact_form->email;
# Access your properties YAML:
warn $res->properties->contact_form->email->is_missing;
# Access the application config:
warn $api->config->system->settings->foo;
DESCRIPTION
ASP4::API
is very useful for unit tests - specifically when writing tests for the actual web pages themselves.
Example Unit Test
#!/usr/bin/perl -w
use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;
ok(
my $api = ASP4::API->new, "Got api"
);
is(
$api->ua->get('/hello.asp')->content => 'Hello World!',
'Website is friendly'
);
PUBLIC PROPERTIES
ua
Returns an ASP4::UserAgent that can be used to interact with pages on your website.
context
Returns the current instance of ASP4::HTTPContext in use.
config
Returns the ASP4::Config object for the web application.
properties
Returns an object representing your /etc/properties.yaml
file.
data
Returns an object representing your /etc/test_fixtures.yaml
file.
BUGS
It's possible that some bugs have found their way into this release.
Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4 to submit bug reports.
HOMEPAGE
Please visit the ASP4 homepage at http://0x31337.org/code/ to see examples of ASP4 in action.