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