Extra intro pod
[dbsrgits/DBIx-Class.git] / t / create / set_column.t
1 use warnings;
2 use strict;
3
4 use Test::More;
5 use Test::Exception;
6
7 use lib qw(t/lib);
8 use DBICTest;
9
10 my $schema = DBICTest->init_schema();
11
12 TODO: {
13     local $TODO = 'call accessors when calling create() or update()';
14
15     my $row =
16       $schema->resultset('Track')->new_result( { title => 'foo', cd => 1 } );
17     $row->increment(1);
18     $row->insert;
19     is( $row->increment, 2 );
20
21     $row =
22       $schema->resultset('Track')
23       ->create( { title => 'bar', cd => 1, increment => 1 } );
24     is( $row->increment, 2 );
25
26     # $row isa DBICTest::Schema::Track
27     $row->get_from_storage;
28     is( $row->increment, 2 );
29
30     $row->update( { increment => 3 } );
31     $row->get_from_storage;
32     is( $row->increment, 4 );
33
34     $row->increment(3);
35     $row->get_from_storage;
36     is( $row->increment, 4 );
37
38     throws_ok (sub {
39         $row =
40           $schema->resultset('Track')
41           ->create( { title => 'bar', cd => 2, set_increment => 1 } );
42     }, qr/no such column/i);
43 }
44
45 done_testing;