remove session_class and psgix.session per discussion on IRC :)
[catagits/Web-Session.git] / t / 004_basic_file_w_customs.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use File::Spec;
6 use Test::Requires 'YAML';
7
8 use Test::More;
9
10 use Plack::Request;
11 use Plack::Session;
12 use Plack::Session::State::Cookie;
13 use Plack::Session::Store::File;
14
15 use t::lib::TestSession;
16
17 my $TMP = File::Spec->catdir('t', 'tmp');
18 if ( !-d $TMP ) {
19     mkdir $TMP;
20 }
21
22 t::lib::TestSession::run_all_tests(
23     store  => Plack::Session::Store::File->new(
24         dir          => $TMP,
25         serializer   => sub { YAML::DumpFile( reverse @_ ) }, # YAML takes it's args the opposite of Storable
26         deserializer => sub { YAML::LoadFile( @_ ) },
27     ),
28     state  => Plack::Session::State->new,
29     env_cb => sub {
30         open my $in, '<', \do { my $d };
31         my $env = {
32             'psgi.version'    => [ 1, 0 ],
33             'psgi.input'      => $in,
34             'psgi.errors'     => *STDERR,
35             'psgi.url_scheme' => 'http',
36             SERVER_PORT       => 80,
37             REQUEST_METHOD    => 'GET',
38             QUERY_STRING      => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
39         };
40     },
41 );
42
43 unlink $_ foreach glob( File::Spec->catdir($TMP, '*') );
44
45 done_testing;