Merge pull request #7 from tokuhirom/master
[catagits/Web-Session.git] / t / 005a_basic_w_cache_store.t
CommitLineData
7ea446f1 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8use Plack::Request;
9use Plack::Session::State;
10use Plack::Session::Store::Cache;
11
12use t::lib::TestSessionHash;
13
14{
15 package TestCache;
16
17 sub new {
18 bless {} => shift;
19 }
20
21 sub set {
22 my ($self, $key, $val ) = @_;
23
24 $self->{$key} = $val;
25 }
26
27 sub get {
28 my ($self, $key ) = @_;
29
30 $self->{$key};
31 }
32
33 sub remove {
34 my ($self, $key ) = @_;
35
36 delete $self->{$key};
37 }
38}
39
40t::lib::TestSessionHash::run_all_tests(
41 store => Plack::Session::Store::Cache->new( cache => TestCache->new ),
42 state => Plack::Session::State->new,
43 env_cb => sub {
44 open my $in, '<', \do { my $d };
45 my $env = {
46 'psgi.version' => [ 1, 0 ],
47 'psgi.input' => $in,
48 'psgi.errors' => *STDERR,
49 'psgi.url_scheme' => 'http',
50 SERVER_PORT => 80,
51 REQUEST_METHOD => 'GET',
52 QUERY_STRING => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
53 };
54 },
55);
56
57
58done_testing;