add user() sub to get a safe user for testing

This commit is contained in:
Doug Bell 2010-12-21 14:29:27 -06:00
parent 9cb5c088b0
commit 580193596e

View file

@ -44,6 +44,7 @@ use Monkey::Patch qw( patch_object );
use Scope::Guard;
use WebGUI::Paths -inc;
use namespace::clean;
use WebGUI::User;
our @EXPORT = qw(cleanupGuard addToCleanup);
our @EXPORT_OK = qw(session config collateral);
@ -293,6 +294,23 @@ sub asset {
#----------------------------------------------------------------------------
=head2 user ( props )
Create a safe user to use for testing. The user will be removed after the test
is run.
=cut
sub user {
my ( $class, %props ) = @_;
my $user = WebGUI::User->create( $class->session );
$user->update( %props );
addToCleanup( $user );
return $user;
}
#----------------------------------------------------------------------------
=head2 config
Returns the config object from the session.