X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=t%2F01basics.t;h=324bb0bceaa0ad2eedb89e67f7bb5109905b6747;hb=a212c53b5fa6f60af5c20168bb0f992e5431eed6;hp=e40fa85f488725b000c26b80428cc70012c51779;hpb=ea4ae8a93a09e21354465c485471e5f10582b784;p=maypole.git diff --git a/t/01basics.t b/t/01basics.t index e40fa85..324bb0b 100644 --- a/t/01basics.t +++ b/t/01basics.t @@ -1,13 +1,17 @@ #!/usr/bin/perl -w use Test::More; -use lib 'ex'; # Where BeerDB should live +use Data::Dumper; +use lib 'examples'; # Where BeerDB should live BEGIN { + $ENV{BEERDB_DEBUG} = 0; + eval { require BeerDB }; Test::More->import( skip_all => "SQLite not working or BeerDB module could not be loaded: $@" ) if $@; plan tests => 18; + } use Maypole::CLI qw(BeerDB); use Maypole::Constants; @@ -29,20 +33,26 @@ like(BeerDB->call_url("http://localhost/beerdb"), qr/frontpage/, "Got frontpage, trailing '/' on uri_base but not request"); like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list"); -my (%classdata)=split /\n/, BeerDB->call_url("http://localhost/beerdb/beer/classdata"); + +my $classdata_page = BeerDB->call_url("http://localhost/beerdb/beer/classdata"); +my (%classdata)=split /\n+/, $classdata_page; +#warn $classdata_page; +#warn Dumper(%classdata); + is ($classdata{plural},'beers','classdata.plural'); is ($classdata{moniker},'beer','classdata.moniker'); like ($classdata{cgi},qr/^HTML::Element/,'classdata.cgi'); is ($classdata{table},'beer','classdata.table'); is ($classdata{name},'BeerDB::Beer','classdata.name'); is ($classdata{colnames},'Abv','classdata.colnames'); -is($classdata{columns}, 'abv brewery id name notes price score style url', +is($classdata{columns}, 'abv brewery id name notes price score style tasted url', 'classdata.columns'); is($classdata{list_columns}, 'score name price style brewery url', 'classdata.list_columns'); is ($classdata{related_accessors},'pubs','classdata.related_accessors'); -# test if successfully loaded customised model class +# test Maypole::load_custom_class() can_ok(BeerDB::Beer => 'fooey'); # defined in BeerDB::Beer can_ok(BeerDB::Beer => 'floob'); # defined in BeerDB::Base -is_deeply( [@BeerDB::Beer::ISA], [qw/Maypole::Model::CDBI Class::DBI::SQLite BeerDB::Base/] ); + +is_deeply( [@BeerDB::Beer::ISA], [qw/Class::DBI::SQLite Maypole::Model::CDBI BeerDB::Base/] );