From ff2344cdad661850a6997c8b41c1dd4f5691e2c2 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 3 Oct 2006 23:27:08 +0000 Subject: [PATCH] Added comments to the POD in Var.pm that creating a Var object overwrites the Session Id. This is by design. Added a check to Style.pm so that if no params are passed to setLink that it won't die by trying to deref undef into a hashref. First set of tests for Session/Style added. --- lib/WebGUI/Session/Style.pm | 4 ++- lib/WebGUI/Session/Var.pm | 2 +- t/Session/Style.t | 51 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 t/Session/Style.t diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index 62d7e1e32..d622e21be 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -248,7 +248,8 @@ Sets a tag into the of this rendered page for this page view. This =head3 url -The URL to the document you are linking. +The URL to the document you are linking. Only one link can be set per url. If a link to this URL exists, +the old link will remain and this method will return undef. =head3 params @@ -260,6 +261,7 @@ sub setLink { my $self = shift; my $url = shift; my $params = shift; + $params = {} unless (defined $params and ref $params eq 'HASH'); return undef if ($self->{_link}{$url}); my $tag = ' 7; # increment this value for each test you create + +my $session = WebGUI::Test->session; + +# put your tests here + +my $style = $session->style; + +isa_ok($style, 'WebGUI::Session::Style', 'session has correct object type'); + +#################################################### +# +# sent +# +#################################################### + +is($style->sent, undef, 'sent should start off being undefined at session creation'); +is($style->sent(1), '1', 'sent: set to true (1)'); +is($style->sent(), '1', 'sent: return true (1)'); +is($style->sent('gone'), 'gone', 'sent: set to true ("gone")'); +is($style->sent(), 'gone', 'sent: return true ("gone")'); + +$style->sent(0); ##Set to unsent to we don't trigger any other code, yet + +#################################################### +# +# setLink +# +#################################################### + +is($style->setLink(), 0, 'setLink returns the result of the conditional check for already sent'); + +END { +}