adding in tests for the raw HASH session
[catagits/Web-Session.git] / t / 005a_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::State;
10 use Plack::Session::Store::Cache;
11
12 use 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
40 t::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
58 done_testing;