NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Testing whole scripts (Score:1)
Re:Testing whole scripts (Score:1)
# corresponds to a Session.pm file I have.
# It could certainly be more robust, and test
# more options than just some simple scalars.
#!/usr/bin/perl -w
use strict;
use constant SAVEPATH=>'/tmp';
use Test::More tests=>7;
BEGIN {
use_ok( 'TW::Session' );
}
my $saved_session_id;
CREATE: {
my $session = new TW::Session( SavePath=>SAVEPATH );
isa_ok( $session, 'TW::Session', 'Created first session' );
$session->{yankee} = 'doodle';
is( $session->{yankee}, 'doodle', 'Stored the value' );
$saved_session_id = $session->id;
}
REREAD: {
my $session = new TW::Session( SID => $saved_session_id, SavePath=>SAVEPATH );
isa_ok( $session, 'TW::Session', 'Instantiated 2nd session instance' );
is( $session->id, $saved_session_id, 'IDs match' );
is( $session->{yankee}, 'doodle', 'Retrieved the value' );
# Check the link method
is( $session->link( 'Click', 'target' ),
"<a href=\"target?SID=$saved_session_id\">Click</a>",
'link() builds correctly' );
my $sess_filename = SAVEPATH . "/sess_$saved_session_id";
$session->delete; # Can't really test this one, but let's clean up anyway.
ok( ! -e $sess_filename, "File $sess_filename was deleted" );
}
--
xoa
Reply to This
Parent