oops, small POD typo
[dbsrgits/DBIx-Class.git] / t / 92storage.t
CommitLineData
efe6365b 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
baa31d2f 8{
9 package DBICTest::ExplodingStorage::Sth;
10 use strict;
11 use warnings;
12
13 sub execute { die "Kablammo!" }
14
15 sub bind_param {}
16
17 package DBICTest::ExplodingStorage;
18 use strict;
19 use warnings;
20 use base 'DBIx::Class::Storage::DBI::SQLite';
21
22 my $count = 0;
23 sub sth {
24 my ($self, $sql) = @_;
25 return bless {}, "DBICTest::ExplodingStorage::Sth" unless $count++;
26 return $self->next::method($sql);
27 }
28
29 sub connected {
30 return 0 if $count == 1;
31 return shift->next::method(@_);
32 }
33}
34
35plan tests => 3;
efe6365b 36
37my $schema = DBICTest->init_schema();
38
39is( ref($schema->storage), 'DBIx::Class::Storage::DBI::SQLite',
40 'Storage reblessed correctly into DBIx::Class::Storage::DBI::SQLite' );
41
baa31d2f 42
43my $storage = $schema->storage;
44$storage->ensure_connected;
45
46bless $storage, "DBICTest::ExplodingStorage";
47$schema->storage($storage);
48
49eval {
50 $schema->resultset('Artist')->create({ name => "Exploding Sheep" })
51};
52
53is($@, "", "Exploding \$sth->execute was caught");
54
55is(1, $schema->resultset('Artist')->search({name => "Exploding Sheep" })->count,
56 "And the STH was retired");
57
58
efe6365b 591;