Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / storage / prefer_stringification.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
b5ce6748 3use warnings;
4use strict;
5
6use Test::More;
7
c0329273 8
b5ce6748 9use DBICTest;
10
11{
12 package # hideee
13 DBICTest::CrazyInt;
14
15 use overload
16 '0+' => sub { 666 },
17 '""' => sub { 999 },
18 fallback => 1,
19 ;
20}
21
22# check DBI behavior when fed a stringifiable/nummifiable value
23{
24 my $crazynum = bless {}, 'DBICTest::CrazyInt';
25 cmp_ok( $crazynum, '==', 666 );
26 cmp_ok( $crazynum, 'eq', 999 );
27
28 my $schema = DBICTest->init_schema( no_populate => 1 );
29 $schema->storage->dbh_do(sub {
30 $_[1]->do('INSERT INTO artist (name) VALUES (?)', {}, $crazynum );
31 });
32
33 is( $schema->resultset('Artist')->next->name, 999, 'DBI preferred stringified version' );
34}
35done_testing;