diff --git a/t/Form/GetName.t b/t/Form/GetName.t index 0b3e7d46c..e6d6dcb46 100644 --- a/t/Form/GetName.t +++ b/t/Form/GetName.t @@ -32,8 +32,6 @@ my $session = WebGUI::Test->session; # put your tests here -diag("Getting the list of all Form types\n"); - my @formTypes = sort @{ WebGUI::Form::FieldType->getTypes($session) }; ##We have to remove DynamicField from this list, since when you call new diff --git a/t/Form/ProfileEnabled.t b/t/Form/ProfileEnabled.t new file mode 100644 index 000000000..c0e2b965d --- /dev/null +++ b/t/Form/ProfileEnabled.t @@ -0,0 +1,61 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; +use WebGUI::Form::FieldType; +use WebGUI::Form::DynamicField; +use WebGUI::Session; +use WebGUI::Utility; + +#The goal of this test is to verify that the profileEnabled setting +#works on all form elements and that only the correct forms are profile +#enabled. + +use Test::More; # increment this value for each test you create + +my $numTests = 0; + +my $session = WebGUI::Test->session; + +# put your tests here + +my @formTypes = sort @{ WebGUI::Form::FieldType->getTypes($session) }; + +##We have to remove DynamicField from this list, since when you call new +##it wants to return a type. We'll check it manually. + +$numTests = scalar @formTypes + 1; + +plan tests => $numTests; + +diag("Planning on running $numTests tests\n"); + +my @notEnabled = qw/Asset Button Captcha Color Control List MimeType Submit/; + +foreach my $formType (@formTypes) { + my $form = WebGUI::Form::DynamicField->new($session, fieldType => $formType); + my $ref = (split /::/, ref $form)[-1]; + if (isIn($ref, @notEnabled)) { + ok(!$form->get('profileEnabled'), " $ref should not be profile enabled"); + } + else { + ok($form->get('profileEnabled'), "$ref should be profile enabled"); + } +} + +##Note: DynamicField will report true, but only because it's actually creating +##an object of type Text! +my $form = WebGUI::Form::DynamicField->new($session); + +ok($form->get('profileEnabled'), 'DynamicField lies about being profile enable');