Add purge method to Shop::Credit, tests.
This commit is contained in:
parent
229a4080a8
commit
7f0657927d
3 changed files with 162 additions and 1 deletions
|
|
@ -35,7 +35,8 @@ readonly userId => my %userId;
|
|||
|
||||
=head2 adjust ( amount, [ comment ] )
|
||||
|
||||
Adjusts the amount of credit this user has by a specified amount.
|
||||
Adjusts the amount of credit this user has by a specified amount. Returns 0 if the current user is Visitor.
|
||||
Otherwise, returns the amount set.
|
||||
|
||||
=head3 amount
|
||||
|
||||
|
|
@ -154,6 +155,20 @@ sub new {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
Removes all shop credit for the current user.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my ($self) = @_;
|
||||
$self->session->db->write("delete from shopCredit where userId = ?",[$self->userId]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ()
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use WebGUI::Utility;
|
|||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Workflow::Instance;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
use WebGUI::Shop::Credit;
|
||||
use JSON;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::ProfileField;
|
||||
|
|
@ -424,6 +425,9 @@ sub delete {
|
|||
$book->delete;
|
||||
}
|
||||
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $userId);
|
||||
$credit->purge;
|
||||
|
||||
# remove user itself
|
||||
$db->write("DELETE FROM userProfileData WHERE userId=?",[$userId]);
|
||||
$db->write("DELETE FROM users WHERE userId=?",[$userId]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue