ASP4::API - Public Programmatic API to an ASP4 Application
#!/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;
ASP4::API is very useful for unit tests - specifically when writing tests for the actual web pages themselves.
ASP4::API
#!/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' );
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() is simply an alias of new()
init()
new()
Returns an ASP4::UserAgent that can be used to interact with pages on your website.
Returns the current instance of ASP4::HTTPContext in use.
Returns the ASP4::Config object for the web application.
Returns an object representing your /etc/properties.yaml file.
/etc/properties.yaml
Returns an object representing your /etc/test_fixtures.yaml file.
/etc/test_fixtures.yaml
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.
Please visit the ASP4 homepage at http://0x31337.org/code/ to see examples of ASP4 in action.
To install ASP4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ASP4
CPAN shell
perl -MCPAN -e shell install ASP4
For more information on module installation, please visit the detailed CPAN module installation guide.