added new API methods to User for easier use
This commit is contained in:
parent
18bb51bc2b
commit
1afff052c4
2 changed files with 10 additions and 2 deletions
|
|
@ -1251,10 +1251,12 @@ sub update {
|
||||||
|
|
||||||
# Make a safe copy of properties, we'll be deleting from it
|
# Make a safe copy of properties, we'll be deleting from it
|
||||||
$properties = { %$properties };
|
$properties = { %$properties };
|
||||||
|
|
||||||
$self->uncache;
|
$self->uncache;
|
||||||
$properties->{lastUpdated} ||= time;
|
$properties->{lastUpdated} ||= time;
|
||||||
|
|
||||||
|
# No userId, bad!
|
||||||
|
delete $properties->{userId};
|
||||||
|
|
||||||
# $self->{_user} contains all fields in `users` table
|
# $self->{_user} contains all fields in `users` table
|
||||||
my @userFields = ();
|
my @userFields = ();
|
||||||
my @userValues = ();
|
my @userValues = ();
|
||||||
|
|
|
||||||
8
t/User.t
8
t/User.t
|
|
@ -20,7 +20,7 @@ use WebGUI::Cache;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
use WebGUI::ProfileField;
|
use WebGUI::ProfileField;
|
||||||
|
|
||||||
use Test::More tests => 211; # increment this value for each test you create
|
use Test::More tests => 221; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
|
@ -115,12 +115,18 @@ $newSession->close;
|
||||||
|
|
||||||
my $now = time;
|
my $now = time;
|
||||||
$user->update({
|
$user->update({
|
||||||
|
userId => 'INEDU2COMEINSATURDYTHX',
|
||||||
username => "jlumbe",
|
username => "jlumbe",
|
||||||
firstName => "John",
|
firstName => "John",
|
||||||
lastName => "Lumbergh",
|
lastName => "Lumbergh",
|
||||||
lastUpdated => $now,
|
lastUpdated => $now,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
isnt(
|
||||||
|
$user->get('userId'), 'INEDU2COMEINSATURDYTHX',
|
||||||
|
"update() does not allow changing userId",
|
||||||
|
);
|
||||||
|
|
||||||
is(
|
is(
|
||||||
$session->db->quickScalar("SELECT username FROM users WHERE userId=?",[$user->getId]),
|
$session->db->quickScalar("SELECT username FROM users WHERE userId=?",[$user->getId]),
|
||||||
"jlumbe",
|
"jlumbe",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue