package Maypole::CLI;
use UNIVERSAL::require;
use URI; use URI::QueryParam;
+use Maypole::Constants;
use strict;
use warnings;
$self->{path} = $url->path;
$self->{path} =~ s/^$root//i if $root;
$self->parse_path;
+ $self->parse_args;
+}
+
+sub parse_args {
+ my $self = shift;
+ $self->{params} = $url->query_form_hash;
$self->{query} = $url->query_form_hash;
}
# Do it!
CHECK { if ((caller(0))[1] eq "-e") {
- $package->handler() and print $buffer;
+ $package->handler() == OK and print $buffer;
} }
1;
use Test::More tests => 5;
use Maypole::CLI qw(BeerDB);
+ use Maypole::Constants;
$ENV{MAYPOLE_TEMPLATES} = "t/templates";
# Hack because isa_ok only supports object isa not class isa
isa_ok( (bless {},"BeerDB") , "Maypole");
@ARGV = ("http://localhost/beerdb/");
- is(BeerDB->handler, 200, "OK");
+ is(BeerDB->handler, OK, "OK");
like($Maypole::CLI::buffer, qr/frontpage/, "Got the front page");
@ARGV = ("http://localhost/beerdb/beer/list");
- is(BeerDB->handler, 200, "OK");
+ is(BeerDB->handler, OK, "OK");
like($Maypole::CLI::buffer, qr/Organic Best/, "Found a beer in the list");