Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / t / row / sourceless.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use DBICTest;
9
10 my $row = DBICTest::Schema::CD->new({ title => 'foo' });
11
12 my @values = qw( foo bar baz );
13 for my $i ( 0 .. $#values ) {
14   {
15     local $TODO = 'This probably needs to always return 1, on virgin objects... same with get_dirty_columns'
16       unless $i;
17
18     ok ( $row->is_column_changed('title'), 'uninserted row properly reports "eternally changed" value' );
19     is_deeply (
20       { $row->get_dirty_columns },
21       { title => $values[$i-1] },
22       'uninserted row properly reports "eternally changed" dirty_columns()'
23     );
24   }
25
26   $row->title( $values[$i] );
27
28   ok( $row->is_column_changed('title'), 'uninserted row properly reports changed value' );
29   is( $row->title, $values[$i] , 'Expected value on sourceless row' );
30   for my $meth (qw( get_columns get_inflated_columns get_dirty_columns )) {
31     is_deeply(
32       { $row->$meth },
33       { title => $values[$i] },
34       "Expected '$meth' rv",
35     )
36   }
37 }
38
39 done_testing;