NAME

ASP4::API - Public Programmatic API to an ASP4 Application

SYNOPSIS

#!/usr/bin/perl -w

use strict;
use warnings 'all';

# Load up and initialize ASP4::API *before* using your app's classes:
use ASP4::API;

# *Now* you can use your app's other classes:
# because the environment has been initialized (@INC, %ENV, etc):
use app::user;
use app::product;
use app::order;

# Create an api object:
my $api = ASP4::API->new;

# 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;
my $api = ASP4::API->new();

ok(
  $api, "Got api"
);
like(
  $api->ua->get('/hello.asp')->content => qr/Hello\s+World\!/,
  'Website is friendly'
);

CONSTRUCTOR

new( )

Takes no arguments. Finds and initializes your application's configuration, which means that any other part of your application which requires the configuration to have been loaded up will now work.

init( )

init() is simply an alias of new()

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.