Merge pull request #7 from tokuhirom/master
[catagits/Web-Session.git] / t / 004_basic_file_w_customs.t
CommitLineData
f331b3e0 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use File::Spec;
9bb20750 6use Test::Requires 'YAML';
f331b3e0 7
8use Test::More;
9
f331b3e0 10use Plack::Request;
11use Plack::Session;
12use Plack::Session::State::Cookie;
13use Plack::Session::Store::File;
14
15use t::lib::TestSession;
16
17my $TMP = File::Spec->catdir('t', 'tmp');
40cc4851 18if ( !-d $TMP ) {
19 mkdir $TMP;
20}
f331b3e0 21
22t::lib::TestSession::run_all_tests(
85265792 23 store => Plack::Session::Store::File->new(
f331b3e0 24 dir => $TMP,
25 serializer => sub { YAML::DumpFile( reverse @_ ) }, # YAML takes it's args the opposite of Storable
26 deserializer => sub { YAML::LoadFile( @_ ) },
27 ),
85265792 28 state => Plack::Session::State->new,
29 env_cb => sub {
f331b3e0 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',
85265792 38 QUERY_STRING => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
f331b3e0 39 };
f331b3e0 40 },
41);
42
43unlink $_ foreach glob( File::Spec->catdir($TMP, '*') );
44
45done_testing;