Class::DBI::Lite::Fixture - Test fixtures for easy testing.
package app::fixtures; use strict; use warnings 'all'; use base 'Class::DBI::Lite::Fixture'; use app::state; my @state_info = qw( AL:Alabama AK:Alaska AR:Arkansas ); my @states = ( ); sub setup_states { push @states, map { my ($abbr, $name) = split /\:/, $_; app::state->find_or_create( name => $name, abbr => $abbr, ) } @state_info; }# end setup_states() sub destroy_states { map { eval{$_->delete} } @states; }# end destroy_states() 1;# return true:
use strict; use warnings 'all'; use Test::More 'no_plan'; use lib qw( lib t/lib ); # Setup your test fixtures: use app::fixtures 'states'; use_ok('app::state'); is( app::state->count_search(abbr => 'AL') => 1 ); # The 'app::state' records are automatically deleted in 'destroy_states'!
This module provides stubs for the use of "test fixtures" to test your code.
Copyright John Drago <jdrago_999@yahoo.com>. All rights reserved.
This software is Free software and may be used and redistributed under the same terms as perl itself.
To install Class::DBI::Lite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::Lite
CPAN shell
perl -MCPAN -e shell install Class::DBI::Lite
For more information on module installation, please visit the detailed CPAN module installation guide.