root/Apache-Session-PHP/trunk/t/01_session.t

Revision 555 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 use strict;
2 use Test::More tests => 8;
3
4 use Apache::Session::PHP;
5 use PHP::Session;
6
7 # init
8
9 my %session;
10 tie %session, 'Apache::Session::PHP', undef, {
11     SavePath => 't',
12 };
13
14 $session{foo} = "bar";
15 $session{bar} = { 'bar' => 1, 'baz' => 2 };
16
17 my $sid = $session{_session_id};
18 untie %session;
19
20 # reload
21
22 tie %session, 'Apache::Session::PHP', $sid, {
23     SavePath => 't',
24 };
25
26 is $session{foo}, 'bar';
27 is_deeply $session{bar}, { 'bar' => 1, 'baz' => 2 };
28
29 untie %session;
30
31 # from PHP::Session
32
33 ok my $php = PHP::Session->new($sid, { save_path => 't' });
34 is $php->get('foo'), 'bar';
35 is_deeply $php->get('bar'), { 'bar' => 1, 'baz' => 2 };
36 $php->set(xxx => 'yyy');
37 $php->save;
38
39 # from A::S::PHP again
40
41 tie %session, 'Apache::Session::PHP', $sid, {
42     SavePath => 't',
43 };
44
45 is $session{foo}, 'bar';
46 is_deeply $session{bar}, { 'bar' => 1, 'baz' => 2 };
47 is $session{xxx}, 'yyy';
48
49 tied(%session)->delete;
50
51 untie %session;
52
53
54
55
Note: See TracBrowser for help on using the browser.