Forgotten manifest adjust after a2bd379666
[dbsrgits/DBIx-Class.git] / t / cdbi / object_cache.t
CommitLineData
592cd0b1 1use strict;
4a233f30 2use warnings;
592cd0b1 3use Test::More;
4$| = 1;
5
592cd0b1 6
7INIT {
50891152 8 use lib 't/cdbi/testlib';
592cd0b1 9 use Film;
10}
11
f56e59cd 12plan skip_all => "Object cache is turned off"
13 if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex");
14
15plan tests => 5;
16
17
592cd0b1 18ok +Film->create({
19 Title => 'This Is Spinal Tap',
20 Director => 'Rob Reiner',
21 Rating => 'R',
22});
23
24{
25 my $film1 = Film->retrieve( "This Is Spinal Tap" );
26 my $film2 = Film->retrieve( "This Is Spinal Tap" );
27
28 $film1->Director("Marty DiBergi");
29 is $film2->Director, "Marty DiBergi", 'retrieve returns the same object';
30
31 $film1->discard_changes;
32}
33
34{
35 Film->nocache(1);
8273e845 36
592cd0b1 37 my $film1 = Film->retrieve( "This Is Spinal Tap" );
38 my $film2 = Film->retrieve( "This Is Spinal Tap" );
39
40 $film1->Director("Marty DiBergi");
41 is $film2->Director, "Rob Reiner",
42 'caching turned off';
8273e845 43
592cd0b1 44 $film1->discard_changes;
45}
46
47{
48 Film->nocache(0);
49
50 my $film1 = Film->retrieve( "This Is Spinal Tap" );
51 my $film2 = Film->retrieve( "This Is Spinal Tap" );
52
53 $film1->Director("Marty DiBergi");
54 is $film2->Director, "Marty DiBergi",
55 'caching back on';
56
57 $film1->discard_changes;
58}
59
60
61{
62 Film->nocache(1);
63
64 local $Class::DBI::Weaken_Is_Available = 0;
65
66 my $film1 = Film->retrieve( "This Is Spinal Tap" );
67 my $film2 = Film->retrieve( "This Is Spinal Tap" );
68
69 $film1->Director("Marty DiBergi");
70 is $film2->Director, "Rob Reiner",
71 'CDBI::Weaken_Is_Available turns off all caching';
72
73 $film1->discard_changes;
74}
d9bd5195 75
76done_testing;