diff --git a/agg-t/user/10-add_column.t b/agg-t/user/10-add_column.t index 1f1a073..538123f 100644 --- a/agg-t/user/10-add_column.t +++ b/agg-t/user/10-add_column.t @@ -258,6 +258,24 @@ fixtures_ok 'basic', 'installed the basic fixtures from configuration files'; } "value returned by 'title' method is undef"; } -#FIXME other methods/options (trigger, ...) +# tests for the trigger method + +{ + my $artist1 = Schema->resultset('Artist')->find({ artist_id => 1 }); + + $artist1->is_active(0); + + lives_ok { + $artist1->last_album('Foo Bar'); + } "setting the attribute with the trigger does not throw"; + + cmp_deeply( + $artist1->is_active, + 1, + "the trigger set the 'is_active' attribute" + ); +} + +#FIXME other methods/options done_testing; diff --git a/t/lib/TestSchema/Result/Artist.pm b/t/lib/TestSchema/Result/Artist.pm index d3b919f..f073a9c 100644 --- a/t/lib/TestSchema/Result/Artist.pm +++ b/t/lib/TestSchema/Result/Artist.pm @@ -113,6 +113,20 @@ has favourite_color => ( }, ); +# used for testing the trigger method +has last_album => ( + isa => 'Maybe[Str]', + is => 'rw', + add_column => { + is_nullable => 1, + }, + trigger => sub { + my ($self, $new_value, $old_value) = (shift, @_); + + $self->is_active(1); + }, +); + sub _build_initials { my ($self) = (shift, @_);