"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99dbfile.t" (15 Sep 2009, 1243 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use Test::More;
    2 use Test::Deep;
    3 use File::Temp qw[tempdir];
    4 use Cwd qw[getcwd];
    5 
    6 plan skip_all => "Optional module (DB_File) not installed"
    7   unless eval {
    8                require DB_File;
    9               };
   10 
   11 my $package = 'Apache::Session::DB_File';
   12 
   13 plan tests => 8;
   14 
   15 use_ok $package;
   16 
   17 my $origdir = getcwd;
   18 my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   19 chdir( $tempdir );
   20 
   21 my %session;
   22 my %tie_params = (
   23     FileName      => './text.db',
   24     LockDirectory => '.',
   25 );
   26 
   27 tie %session, $package, undef, { %tie_params };
   28 
   29 ok( tied(%session), "The session is tied" );
   30 
   31 ok(  exists($session{_session_id}), "Session id exists"     );
   32 ok( defined($session{_session_id}), "Session id is defined" );
   33 
   34 my $id = $session{_session_id};
   35 
   36 my $foo = 'bar';
   37 my $baz = [ qw[tom dick harry] ];
   38 
   39 $session{foo} = $foo;
   40 $session{baz} = $baz;
   41 
   42 untie %session;
   43 undef %session;
   44 
   45 tie %session, $package, $id, { %tie_params };
   46 
   47 ok( tied(%session), "The session is tied again" );
   48 
   49 is( $session{_session_id}, $id, "Session IDs match" );
   50 
   51 cmp_deeply $session{foo}, $foo, "Foo matches";
   52 cmp_deeply $session{baz}, $baz, "Baz matches";
   53 
   54 tied(%session)->delete;
   55 untie %session;
   56 undef %session;
   57 
   58 chdir( $origdir );