X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F46where_attribute.t;h=ba1c7d09ebaf631099b7f25c3ca4cc173250619d;hb=e8452b02f9db53148f3d0bc6679a107a9c956174;hp=6ed31256e726e142522b5bae26858727ba1683e7;hpb=65c2b042016f9bd215b8159586da02f9457ebf96;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/46where_attribute.t b/t/46where_attribute.t index 6ed3125..ba1c7d0 100644 --- a/t/46where_attribute.t +++ b/t/46where_attribute.t @@ -1,18 +1,20 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; -use Data::Dumper; -use lib qw(t/lib); + use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 16; - # select from a class with resultset_attributes my $resultset = $schema->resultset('BooksInLibrary'); is($resultset, 3, "select from a class with resultset_attributes okay"); +$resultset = $resultset->search({}, { where => undef }); +is($resultset, 3, "where condition not obliterated"); + # now test out selects through a resultset my $owner = $schema->resultset('Owners')->find({name => "Newton"}); my $programming_perl = $owner->books->find_or_create({ title => "Programming Perl" }); @@ -72,3 +74,16 @@ eval {$collection->add_to_objects({ value => "Wheel", type => "round" })}; if ($@) { print $@ } ok( !$@, 'many_to_many add_to_$rel($hash) did not throw'); is($round_objects->count, $round_count+1, 'many_to_many add_to_$rel($hash) count correct'); + +# test set_$rel +$round_count = $round_objects->count(); +$pointy_count = $pointy_objects->count(); +my @all_pointy_objects = $pointy_objects->all; +# doing a set on pointy objects with its current set should not change any counts +eval {$collection->set_pointy_objects(\@all_pointy_objects)}; +if ($@) { print $@ } +ok( !$@, 'many_to_many set_$rel(\@objects) did not throw'); +is($pointy_objects->count, $pointy_count, 'many_to_many set_$rel($hash) count correct'); +is($round_objects->count, $round_count, 'many_to_many set_$rel($hash) other rel count correct'); + +done_testing;