# Copyright (c) 2006-2009 bivio Software, Inc. All Rights Reserved. # $Id: tuple.btest,v 1.15 2010/10/08 14:57:40 moeller Exp $ test_setup('PetShop'); my($forum, $uri) = create_forum(); visit_uri("$uri/db-types"); follow_link('add.*type'); submit_form(Save => { name => 'I1', class => 'Integer', default => 1, qr{pick.*_0}i => 1, qr{pick.*_1}i => 2, }); follow_link_in_table('Type Name', 'Type Name', 'I1', 'Actions', 'Modify'); submit_form(Save => { name => 'I1a', }); follow_link_in_table('Type Name', 'Type Name', 'I1a', 'Actions', 'Modify'); test_deviance(qr{default value.*pick list}is); submit_form(Save => { default => 3, }); test_deviance(qr{duplicate.*pick list}is); submit_form(Save => { default => 1, qr{pick.*_1$}is => 1, }); test_conformance(); follow_link('types'); follow_link('add.*type'); submit_form(Save => { name => 'I1', }); follow_link('schemas'); follow_link('add.*schema'); test_deviance(qr{must be at least two characters}is); submit_form(Save => { name => 'Database1', prefix => 'd1', qr{Field.*_0$}is => 'Field1?', qr{type.*_0$}is => 'I1', }); test_conformance(); submit_form(Save => { name => 'Database1', prefix => 'd1', qr{Field.*_0$}is => 'Field1', qr{type.*_0$}is => 'I1', qr{required.*_0$}is => 0, qr{Field.*_1$}is => 'Field2', qr{type.*_1$}is => 'Date', qr{required.*_1$}is => 1, }); follow_link('tables'); follow_link('add.*table'); submit_form({ schema => 'Database1', }); follow_link_in_table('Table Name', 'Database1'); follow_link('add.*record'); my($range) = [1 .. 5]; foreach my $i (@$range) { go_back() if $i > 1; submit_form({ 'Field1:' => 1, 'Field2:' => "12/$i/2001", comment => "update #$i", }); } verify_text(qr{@{[join('.*', map("12/0$_/2001", @$range))]}}s); follow_link('Schemas'); follow_link_in_table('Schema Name', 'Schema Name', 'Database1', 'Actions', 'Modify'); test_deviance('must use a Type with a default value'); submit_form(Save => { Field_2 => 'Field3', qr/required.*_2/i => 1, type_2 => 'String', }); test_conformance(); submit_form(Save => { Field_2 => 'Field3', qr/required.*_2/i => 1, type_2 => 'I1a', Field_3 => 'Field4', type_3 => 'String', Field_4 => 'Field5', type_4 => 'String', }); follow_link('Tables'); follow_link_in_table('Table Name', 'Table Name', 'Database1', 'Actions', 'Records'); verify_table('Record', [ ['Record', 'Field3'], ['2', '1'], ]); follow_link_in_table('Record', 'Record', '2', 'Actions', 'Modify'); submit_form(Save => { 'Field4:' => 'f4', 'Field5:' => 'f5', comment => 'xx', }); verify_table('Record', [ ['Record', 'Field1', 'Field2', 'Field3', 'Field4', 'Field5'], ['2', '1', '12/02/2001', '1', 'f4', 'f5'], ]); follow_link('Schemas'); follow_link_in_table('Schema Name', 'Schema Name', 'Database1', 'Actions', 'Modify'); submit_form(Save => { Field_1 => undef, Field_2 => undef, Field_4 => undef, }); follow_link('Tables'); follow_link_in_table('Table Name', 'Table Name', 'Database1', 'Actions', 'Records'); verify_no_text('Field2'); verify_no_text('Field3'); verify_no_text('Field5'); verify_table('Record', [ ['Record', 'Field1', 'Field4'], ['2', '1', 'f4'], ]);