MySQL-ORM
view release on metacpan or search on metacpan
t/20-foo-testmysqlorm.t view on Meta::CPAN
#!perl
BEGIN {
# $ENV{PERL5LIB} = "tmp:" . $ENV{PERL5LIB};
};
use Modern::Perl;
use String::Util ':all';
use Test::More;
use Data::Printer alias => 'pdump';
use MySQL::ORM::Generate;
use Module::Load;
use lib '.', './t', 'tmp';
require 'testlib.pl';
use vars qw($Orm);
########################
if ( !mysql_binary_exists() ) {
plan skip_all => 'mysql not found';
}
elsif ( !check_connection() ) {
plan skip_all => 'unable to connect to mysql';
}
else {
run(1); # default
run(0);
}
done_testing();
##################################
sub run {
my $use_fq_table_names = shift;
remove_tmp();
drop_db();
load_db();
generate($use_fq_table_names);
check();
drop_db();
remove_tmp();
}
sub check {
use_ok("Foo::Testmysqlorm") || BAIL_OUT("failed to use module");
my $dbh = get_dbh();
my $orm;
eval {
$orm = Foo::Testmysqlorm->new(dbh => $dbh);
};
ok(!$@) or BAIL_OUT($@);
ok($orm);
my ($fk_id) = $dbh->selectrow_array("select fk_test_id from testmysqlorm_fk.fk_test");
my $sport = $orm->Sport;
ok($sport);
my $sport_id = $sport->insert(sport_name => 'football');
ok($sport_id);
( run in 0.875 second using v1.01-cache-2.11-cpan-39bf76dae61 )