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