Fix a bug where changing fieldTypes in the userProfileField did not update the database field types.
This commit is contained in:
parent
70845fd9e8
commit
86621e255b
3 changed files with 44 additions and 10 deletions
|
|
@ -17,19 +17,23 @@ use FindBin;
|
|||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use Test::More;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Form::Text;
|
||||
use WebGUI::Form::HTMLArea;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $newUser = WebGUI::User->create( $session );
|
||||
WebGUI::Test->usersToDelete($newUser);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 17; # Increment this number for each test you create
|
||||
plan tests => 20; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the creation of ProfileField
|
||||
|
|
@ -66,19 +70,42 @@ like( $ff, qr/value="$ffvalue"[^>]+selected/, 'html returned contains value, uiL
|
|||
$ff = undef;
|
||||
$ffvalue = undef;
|
||||
ok( $ff = $aliasField->formField(undef, undef, $newUser), 'formField method returns something, alias field, defaulted user' );
|
||||
my $ffvalue = $newUser->profileField('alias');
|
||||
$ffvalue = $newUser->profileField('alias');
|
||||
like( $ff, qr/$ffvalue/, 'html returned contains value, alias field, defaulted user' );
|
||||
|
||||
$ff = undef;
|
||||
$ffvalue = undef;
|
||||
ok( $ff = $uilevelField->formField(undef, undef, $newUser), 'formField method returns something, uiLevel field, defaulted user' );
|
||||
my $ffvalue = $newUser->profileField('uiLevel');
|
||||
$ffvalue = $newUser->profileField('uiLevel');
|
||||
like( $ff, qr/$ffvalue/, 'html returned contains value, uiLevel field, defaulted user' );
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# set, changing fieldTypes
|
||||
#
|
||||
#########################################################
|
||||
|
||||
my $newProfileField = WebGUI::ProfileField->create($session, 'testField', {
|
||||
fieldType => 'Text',
|
||||
label => 'Test Field',
|
||||
});
|
||||
|
||||
my $textFieldType = lc WebGUI::Form::Text->getDatabaseFieldType();
|
||||
my $htmlFieldType = lc WebGUI::Form::HTMLArea->getDatabaseFieldType();
|
||||
|
||||
my $fieldSpec = $session->db->quickHashRef('describe userProfileData testField');
|
||||
is (lc $fieldSpec->{Type}, $textFieldType, 'test field created with correct type for text field');
|
||||
|
||||
$newProfileField->set({ fieldType => 'HTMLArea' });
|
||||
is($newProfileField->get('fieldType'), 'HTMLArea', 'test field updated to HTMLArea');
|
||||
|
||||
$fieldSpec = $session->db->quickHashRef('describe userProfileData testField');
|
||||
is (lc $fieldSpec->{Type}, $htmlFieldType, 'database updated along with profile field object');
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$newUser->delete;
|
||||
$newProfileField->delete;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue