[Bast-commits] r4820 - in DBIx-Class-DynamicDefault/1.000/trunk/t:
. lib/TestSchema
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Thu Sep 18 18:12:41 BST 2008
Author: rafl
Date: 2008-09-18 18:12:41 +0100 (Thu, 18 Sep 2008)
New Revision: 4820
Modified:
DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Affe.pm
Log:
Test setting depending columns.
Modified: DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t 2008-09-18 17:12:05 UTC (rev 4819)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t 2008-09-18 17:12:41 UTC (rev 4820)
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 14;
+use Test::More tests => 17;
use DBICx::TestDatabase;
BEGIN { use_ok('DBIx::Class::DynamicDefault') }
@@ -36,12 +36,15 @@
is($row->quux, -23, 'defaults don\'t get set when a value is specified explicitly on create');
-$row = $rs2->create({ moo => 0, kooh => '123' });
+$row = $rs2->create({ moo => 0, kooh => '123', baz => 'moo' });
is($row->moo, 0, 'no default on create');
is($row->kooh, '123', 'no default on create');
+is($TestSchema::Affe::moo_default_called, 0, 'no update callback on create');
$row->update;
+is($TestSchema::Affe::moo_default_called, 1, 'callback called once to set two columns');
is($row->moo, 1, 'default on update without changes and always_update');
is($row->kooh, 'zomtec', 'on update default without always_update if another col is changed due to always_update');
+is($row->baz, 1, 'moo');
Modified: DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Affe.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Affe.pm 2008-09-18 17:12:05 UTC (rev 4819)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Affe.pm 2008-09-18 17:12:41 UTC (rev 4820)
@@ -5,6 +5,8 @@
use parent qw/DBIx::Class/;
+our $moo_default_called = 0;
+
__PACKAGE__->load_components(qw/DynamicDefault Core/);
__PACKAGE__->table('affe');
@@ -18,6 +20,10 @@
data_type => 'text',
dynamic_default_on_update => 'kooh_default',
},
+ baz => {
+ data_type => 'integer',
+ dynamic_default_on_update => \'moo',
+ },
);
__PACKAGE__->set_primary_key(qw/moo/);
@@ -26,6 +32,7 @@
my $i = 0;
sub moo_default {
+ $moo_default_called++;
return ++$i;
}
}
More information about the Bast-commits
mailing list