From 394c2dae725be19357ecfa9945ae9a219ede08b8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 28 Jun 2010 12:00:02 -0700 Subject: [PATCH] Enable a simple test for CXGN::Page::Form::Static --- lib/CXGN/Page/Form/Static.pm | 5 +-- t/CXGN/Page/Form/forms.t | 17 ++++++++ t/CXGN/Page/Form/forms.t.todo | 98 ------------------------------------------- 3 files changed, 18 insertions(+), 102 deletions(-) create mode 100644 t/CXGN/Page/Form/forms.t delete mode 100644 t/CXGN/Page/Form/forms.t.todo diff --git a/lib/CXGN/Page/Form/Static.pm b/lib/CXGN/Page/Form/Static.pm index a167aa7c2..7937b17a7 100644 --- a/lib/CXGN/Page/Form/Static.pm +++ b/lib/CXGN/Page/Form/Static.pm @@ -462,7 +462,6 @@ sub set_error_hash { sub validate { my $self = shift; my %args = @_; - print STDERR "Static Form - no validation\n"; } =head2 from_request @@ -635,9 +634,8 @@ sub get_error_message { =cut -sub store { +sub store { my $self = shift; - print STDERR "Static Form: Nothing saved.\n"; } =head2 get_insert_id @@ -660,7 +658,6 @@ sub get_insert_id { my $object_type = ref($object); if (!exists($self->{insert_id}) || !exists($self->{insert_id}->{object_type})) { - #print STDERR "last insert id for object_type $object_type unknown!\n"; } else { return $self->{insert_id}{object_type}; diff --git a/t/CXGN/Page/Form/forms.t b/t/CXGN/Page/Form/forms.t new file mode 100644 index 000000000..5ea6f9d1c --- /dev/null +++ b/t/CXGN/Page/Form/forms.t @@ -0,0 +1,17 @@ +use strict; +use warnings; + +use Test::More tests => 1; +use CXGN::Page::Form::Static; + +my $f = CXGN::Page::Form::Static->new(); + +$f->add_field( + screen_name => 'test1', + field_name => 'test1', + contents => 'test1 contents', + length => 10, +); + + +cmp_ok ( $f->as_table_string(), '=~' , qr!.*test1 contents!, "as_table_string"); diff --git a/t/CXGN/Page/Form/forms.t.todo b/t/CXGN/Page/Form/forms.t.todo deleted file mode 100644 index 437258bce..000000000 --- a/t/CXGN/Page/Form/forms.t.todo +++ /dev/null @@ -1,98 +0,0 @@ -# note: these tests are not yet functional. - -use strict; - -use Test::More qw | |; -use CXGN::Page::Form::Static; - -my $test = CXGN::Test->new(); - -# build a static form -# -my $f = CXGN::Page::Form::Static->new(); - -$f->add_field( screen_name => 'test1', - field_name => 'test1', - contents => 'test1', - length => 10, - object => $test, - getter => 'get_test', - setter => 'set_test', - - ); - - - -$f->add_textarea( screen_name => 'test2', - field_name => 'test2', - contents => 'test2', - length => 10, - object => $test, - getter => 'get_test', - setter => 'set_test', - - ); - -# $f->add_select( screen_name => 'test', -# field_name => 'test', -# contents => 'test', -# length => 10, -# object => $test, -# getter => 'get_test', -# setter => 'set_test',); - -$f->add_hidden( screen_name => 'test3', - field_name => 'test3', - contents => 'test3', - length => 10, - object => $test, - getter => 'get_test', - setter => 'set_test',); - -$f->add_checkbox( screen_name => 'test4', - field_name => 'test4', - contents => 'test4', - length => 10, - object => $test, - getter => 'get_test', - setter => 'set_test',); - -# $f->add_radiolist( screen_name => 'test', -# field_name => 'test', -# contents => 'test', -# length => 10, -# object => $test, -# getter => 'get_test', -# setter => 'set_test',); - -ok (length($f->as_table())>0, "form test"); - -my %h = $f->get_field_hash(); -my $t = $f->as_table(); - -foreach my $k ( qw | test1 test2 test3 test4 | ) { - print STDERR "$k\n"; -# is(exists($h{$k}), 1, "object test"); - is($t=~/test/, /set_test/, "$k setter test"); - is($t=~/test/, /get_test/,"$k getter test"); - -} - -package CXGN::Test; - -sub new { - my $class = shift; - my $self = bless {}, $class; - - return $self; -} - -sub get_test { - my $self = shift; - return $self->{test}; -} - -sub set_test { - my $self = shift; - $self->{test}=shift; -} -- 2.11.4.GIT