From: Peter Rabbitson Date: Wed, 20 May 2015 14:11:39 +0000 (+0200) Subject: Add extra (passing) test for operations on sourceless results X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=908c46a247ef2d3f471f6d24ec16e90080354593;p=dbsrgits%2FDBIx-Class.git Add extra (passing) test for operations on sourceless results This should have been committed with 84b1ec108, reevaluated while reading through cb909f39c of GH#78 --- diff --git a/t/row/sourceless.t b/t/row/sourceless.t new file mode 100644 index 0000000..85ae3ee --- /dev/null +++ b/t/row/sourceless.t @@ -0,0 +1,37 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $row = DBICTest::Schema::CD->new({ title => 'foo' }); + +my @values = qw( foo bar baz ); +for my $i ( 0 .. $#values ) { + { + local $TODO = 'This probably needs to always return 1, on virgin objects... same with get_dirty_columns' + unless $i; + + ok ( $row->is_column_changed('title'), 'uninserted row properly reports "eternally changed" value' ); + is_deeply ( + { $row->get_dirty_columns }, + { title => $values[$i-1] }, + 'uninserted row properly reports "eternally changed" dirty_columns()' + ); + } + + $row->title( $values[$i] ); + + ok( $row->is_column_changed('title'), 'uninserted row properly reports changed value' ); + is( $row->title, $values[$i] , 'Expected value on sourceless row' ); + for my $meth (qw( get_columns get_inflated_columns get_dirty_columns )) { + is_deeply( + { $row->$meth }, + { title => $values[$i] }, + "Expected '$meth' rv", + ) + } +} + +done_testing;