[Bast-commits] r5673 -
DBIx-Class/0.08/branches/multi_stuff/t/96multi_create
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Mar 2 16:04:52 GMT 2009
Author: ribasushi
Date: 2009-03-02 16:04:52 +0000 (Mon, 02 Mar 2009)
New Revision: 5673
Added:
DBIx-Class/0.08/branches/multi_stuff/t/96multi_create/m2m.t
Log:
Another failing MC/M2M test
Added: DBIx-Class/0.08/branches/multi_stuff/t/96multi_create/m2m.t
===================================================================
--- DBIx-Class/0.08/branches/multi_stuff/t/96multi_create/m2m.t (rev 0)
+++ DBIx-Class/0.08/branches/multi_stuff/t/96multi_create/m2m.t 2009-03-02 16:04:52 UTC (rev 5673)
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+plan tests => 4;
+
+my $schema = DBICTest->init_schema();
+
+lives_ok ( sub {
+
+ my $prod_rs = $schema->resultset ('Producer');
+ my $prod_count = $prod_rs->count;
+
+ my $cd = $schema->resultset('CD')->first;
+ $cd->add_to_producers ({name => 'new m2m producer'});
+
+ is ($prod_rs->count, $prod_count + 1, 'New producer created');
+ ok ($cd->producers->find ({name => 'new m2m producer'}), 'Producer created with correct name');
+
+ my $cd2 = $schema->resultset('CD')->search ( { cdid => { '!=', $cd->cdid } }, {rows => 1} )->single; # retrieve a cd different from the first
+ $cd2->add_to_producers ({name => 'new m2m producer'}); # attach to an existing producer
+ ok ($cd2->producers->find ({name => 'new m2m producer'}), 'Exsiting producer attached to existing cd');
+
+}, 'Test far-end find_or_create over many_to_many');
+
+1;
More information about the Bast-commits
mailing list