diff --git a/lib/WebGUI/Test.pm b/lib/WebGUI/Test.pm index 76e187816..8551c6463 100644 --- a/lib/WebGUI/Test.pm +++ b/lib/WebGUI/Test.pm @@ -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.