From c0b04527bf13068608175e7ea33e1b9921b463dc Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Mon, 9 Oct 2006 16:46:47 +0000 Subject: [PATCH] updated db_colinfo test, and fixed syntax error in DFV model git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@529 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole/Model/CDBI/DFV.pm | 15 ++++++++++++--- t/00compile.t | 4 +++- t/db_colinfo.t | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Maypole/Model/CDBI/DFV.pm b/lib/Maypole/Model/CDBI/DFV.pm index fcf80fb..3afb985 100644 --- a/lib/Maypole/Model/CDBI/DFV.pm +++ b/lib/Maypole/Model/CDBI/DFV.pm @@ -191,7 +191,7 @@ sub _do_update { $obj->set( %$this_class_params ); $obj->update; } - + return ($obj,$errors); } @@ -200,9 +200,18 @@ sub _do_create { my ($class,$r) = @_; my $errors; my $this_class_params = { map { $_ => $r->{params}{$_} } $class->columns }; - my $obj = eval { My::DBI->create( $this_class_params ) }; + my $dfv_results; + my $obj; - my $dfv_results = ($obj) ? undef : $class->dfv_results->msgs ; + if ($class->isa('Class::DBI::DFV')) { + $obj = eval { My::DBI->create( $this_class_params ) }; + $dfv_results = ($obj) ? undef : $class->dfv_results ; + } else { + $dfv_results = Data::FormValidator->check($r->{params}, $class->dfv_profile); + if ($dfv_results->success) { + $obj = $class->create($this_class_params); + } + } # handle dfv errors if ( $dfv_results->has_missing ) { # missing fields diff --git a/t/00compile.t b/t/00compile.t index aab6480..8c64ce4 100644 --- a/t/00compile.t +++ b/t/00compile.t @@ -1,7 +1,7 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 13; +use Test::More tests => 15; use_ok('Maypole::Application'); use_ok('Maypole::Constants'); @@ -22,4 +22,6 @@ SKIP: { use_ok('Maypole::Model::CDBI::DFV'); } +use_ok('Maypole::View::Base'); +use_ok('Maypole::View::TT'); diff --git a/t/db_colinfo.t b/t/db_colinfo.t index 8f38f3b..3b20f8d 100755 --- a/t/db_colinfo.t +++ b/t/db_colinfo.t @@ -10,7 +10,7 @@ BEGIN { die "couldn't connect to mysql" unless (@databases); }; warn "error : $@ \n" if ($@); - my $testcount = ($@) ? 45 : 65 ; + my $testcount = ($@) ? 45 : 64 ; plan tests => $testcount; } @@ -138,10 +138,10 @@ SKIP: { } foreach my $colname (keys %correct_nullables) { - ok( $DB_Class->column_required($colname) == !$correct_nullables{$colname}, "nullable column $colname is required (via column_required)" ) + ok( $DB_Class->column_required($colname) == !$correct_nullables{$colname}, "nullable column $colname is required (via column_required)" ) } - ok($DB_Class->required_columns([qw/score/]), 'set required column(s)'); + ok($DB_Class->required_columns([qw/style name tasted score/]), 'set required column(s)'); foreach my $colname ( @{$DB_Class->required_columns()} ) { ok($correct_nullables{$colname} == 0 || $colname eq 'score',"nullable or required column $colname is required (via required_columns)" ); -- 2.39.5