X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2F04-lazy.t;h=7b5a24ce05a211ccf07e0aeffdc2ca42e75f6db8;hb=28f7f7d31e0d17c5362935ac52f7e67a189ddf0f;hp=39d3efda9155f530b436873c401b925451c3c7af;hpb=1d7e89b8623b1ae271aac80651d16dc7c655b15a;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/04-lazy.t b/t/cdbi-t/04-lazy.t index 39d3efd..7b5a24c 100644 --- a/t/cdbi-t/04-lazy.t +++ b/t/cdbi-t/04-lazy.t @@ -1,6 +1,8 @@ +#!/usr/bin/perl -w + use strict; use Test::More; - +use Test::Warn; #---------------------------------------------------------------------- # Test lazy loading @@ -13,7 +15,7 @@ BEGIN { next; } eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 34); + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 36); } INIT { @@ -80,6 +82,10 @@ eval { # Multiple false columns ok($@, $@); +warning_is { + Lazy->columns( TEMP => qw(that) ); +} "Declaring column that as TEMP but it already exists"; + # Test that create() and update() throws out columns that changed { my $l = Lazy->create({ @@ -113,7 +119,8 @@ ok($@, $@); # Now again for inflated values -{ +SKIP: { + skip "Requires Date::Simple", 5 unless eval "use Date::Simple; 1; "; Lazy->has_a( orp => 'Date::Simple', inflate => sub { Date::Simple->new($_[0] . '-01-01') }, @@ -148,3 +155,30 @@ ok($@, $@); $l->delete; } + + +# Test that a deleted object works +{ + Lazy->search()->delete_all; + my $l = Lazy->create({ + this => 99, + that => 2, + oop => 3, + opop => 4, + }); + + # Delete the object without it knowing. + Lazy->db_Main->do(qq[ + DELETE + FROM @{[ Lazy->table ]} + WHERE this = 99 + ]); + + $l->eep; + + # The problem was when an object had an inflated object + # loaded. _flesh() would set _column_data to undef and + # get_column() would think nothing was there. + # I'm too lazy to set up the proper inflation test. + ok !exists $l->{_column_data}{orp}; +}