Fixed a bug in WebGUI::User::profileField, where the check for whether or not
a profile field existed in the db always passed because it used quickArray in scalar context. Since quickArray always returns 1 element, this was always true and it never returned undef like it was supposed to. To fix this, I added a new method called quickScalar that returns the first column from the row as a scalar. It has a basic test in SQL.t. Then there's the new test in User.t for coverage that exposed this problem, and I also removed a whole slew of duplicate tests.
This commit is contained in:
parent
1a278fed6c
commit
1412f023f1
4 changed files with 63 additions and 68 deletions
7
t/SQL.t
7
t/SQL.t
|
|
@ -17,7 +17,7 @@ use WebGUI::Session;
|
|||
use Data::Dumper;
|
||||
use Test::Deep;
|
||||
|
||||
use Test::More tests => 50; # increment this value for each test you create
|
||||
use Test::More tests => 52; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -82,6 +82,11 @@ $sth->finish;
|
|||
my ($value) = $session->db->quickArray("select value from settings where name='authMethod'");
|
||||
ok($value, "quickArray()");
|
||||
|
||||
# quickScalar
|
||||
my $quickScalar = $session->db->quickScalar("SELECT COUNT(*) from userProfileField where fieldName='email'");
|
||||
is(ref $quickScalar, '', 'quickScalar returns a scalar');
|
||||
is($quickScalar, 1, 'quickScalar returns the correct scalar');
|
||||
|
||||
# write
|
||||
$session->db->write("delete from incrementer where incrementerId='theBigTest'"); # clean up previous failures
|
||||
$session->db->write("insert into incrementer (incrementerId, nextValue) values ('theBigTest',25)");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue