implement DBI store
[catagits/Web-Session.git] / t / 006_basic_w_dbi_store.t
CommitLineData
6f28db48 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use File::Spec;
6use File::Temp qw(tempdir);
7
8use Test::Requires qw(DBI DBD::SQLite);
9use Test::More;
10
11use Plack::Request;
12use Plack::Session;
13use Plack::Session::State::Cookie;
14use Plack::Session::Store::DBI;
15
16use t::lib::TestSession;
17
18my $tmp = tempdir(CLEANUP => 1);
19my $file = File::Spec->catfile($tmp, "006_basic_w_dbi_store.db");
20my $dbh = DBI->connect( "dbi:SQLite:$file", undef, undef, {RaiseError => 1, AutoCommit => 1} );
21$dbh->do(<<EOSQL);
22CREATE TABLE sessions (
23 id CHAR(72) PRIMARY KEY,
24 session_data TEXT
25);
26EOSQL
27$dbh->disconnect;
28
29t::lib::TestSession::run_all_tests(
30 store => Plack::Session::Store::DBI->new( connect_info => [ "dbi:SQLite:dbname=$file" ] ),
31 state => Plack::Session::State->new,
32 env_cb => sub {
33 open my $in, '<', \do { my $d };
34 my $env = {
35 'psgi.version' => [ 1, 0 ],
36 'psgi.input' => $in,
37 'psgi.errors' => *STDERR,
38 'psgi.url_scheme' => 'http',
39 SERVER_PORT => 80,
40 REQUEST_METHOD => 'GET',
41 QUERY_STRING => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
42 };
43 },
44);
45
46
47done_testing;