Rework WebGUI::Test::getPage2 to be a wrapper around WebGUI::Test::Mechanize; this is still just

a crutch for converting tests, though really, it's enough shorter that it probably should live on.
getPage should be deprecated and replaced with getPage2 which should then be renamed.  Joy.
Anyway, WebGUI::Test::Mechanize had a bit of chicken-and-egg going on with not being able to
modify things in its session until after a request with a valid session cookie was made.
It's now more forgiving.
Reworked t/Asset/AssetExportHtml.t slightly to use getPage2 as it currently stands.
This commit is contained in:
Scott Walters 2011-05-11 15:26:32 -04:00
parent d2c8670098
commit 72bac90f93
3 changed files with 34 additions and 41 deletions

View file

@ -58,10 +58,15 @@ sub new {
sub session {
my $self = shift;
if( @_ ) {
$self->{_webgui_session} = shift; # take session as an arg
$self->{_webgui_sessionId} ||= $self->{_webgui_session}->getId;
}
return $self->{_webgui_session}
if $self->{_webgui_session};
my $session = WebGUI::Session->open($self->{_webgui_config}, undef, $self->sessionId);
my $session = WebGUI::Session->open($self->{_webgui_config}, undef, $self->sessionId) or die;
$self->{_webgui_session} = $session;
$self->{_webgui_sessionId} ||= $session->getId; # sessionId() sets it from
return $session;
}
@ -78,7 +83,9 @@ sub sessionId {
}
});
if (! $sessionId) {
die "Unable to find session cookie!";
# die "Unable to find session cookie!";
# when called from session() above, there is no session yet and no sessionId; that's okay
return; # empty list; make WebGUI::Session generate one for us
}
$self->{_webgui_sessionId} = $sessionId;
return $sessionId;