1use strict;
2use warnings;
3
4use Test::More tests => 4;
5
6use Apps::Checkbook qw{
7    -Engine=CGI
8    -TemplateEngine=TT
9    -PluginNamespace=Apps::Checkbook
10    PluginQ
11};
12
13use Gantry::Server;
14use Gantry::Engine::CGI;
15
16# these tests must contain valid template paths to the core gantry templates
17# and any application specific templates
18
19my $cgi = Gantry::Engine::CGI->new( {
20    config => {
21        dbconn => 'dbi:SQLite:dbname=app.db',
22        DB => 'app_db',
23        DBName => 'someone',
24        root => 'html:html/templates',
25    },
26    locations => {
27        '/payee' => 'Apps::Checkbook::PayeeOr',
28        '/foreign/location' => 'Apps::Checkbook::Trans',
29        '/transaction' => 'Apps::Checkbook::Trans::Action',
30        '/sch_tbl' => 'Apps::Checkbook::SchTbl',
31    },
32} );
33
34my @tests = qw(
35    /payee
36    /foreign/location
37    /transaction
38    /sch_tbl
39);
40
41my $server = Gantry::Server->new();
42$server->set_engine_object( $cgi );
43
44SKIP: {
45
46    eval {
47        require DBD::SQLite;
48    };
49    skip 'DBD::SQLite is required for run tests.', 4 if ( $@ );
50
51    unless ( -f 'app.db' ) {
52        skip 'app.db sqlite database required for run tests.', 4;
53    }
54
55    foreach my $location ( @tests ) {
56        my( $status, $page ) = $server->handle_request_test( $location );
57        ok( $status eq '200',
58                "expected 200, received $status for $location" );
59
60        if ( $status ne '200' ) {
61            print STDERR $page . "\n\n";
62        }
63    }
64
65}
66