Test for failing code related to many to many in MySQL
[dbsrgits/DBIx-Class.git] / t / 71mysql.t
index 467b4d3..475dc0f 100644 (file)
@@ -2,6 +2,7 @@ use strict;
 use warnings;  
 
 use Test::More;
+use Test::Exception;
 use lib qw(t/lib);
 use DBICTest;
 use DBI::Const::GetInfoType;
@@ -13,7 +14,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
 plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => 10;
+plan tests => 11;
 
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
@@ -23,6 +24,18 @@ $dbh->do("DROP TABLE IF EXISTS artist;");
 
 $dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10));");
 
+$dbh->do("DROP TABLE IF EXISTS cd;");
+
+$dbh->do("CREATE TABLE cd (cdid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, artist INTEGER, title TEXT, year INTEGER, genreid INTEGER, single_track INTEGER);");
+
+$dbh->do("DROP TABLE IF EXISTS producer;");
+
+$dbh->do("CREATE TABLE producer (producerid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name TEXT);");
+
+$dbh->do("DROP TABLE IF EXISTS cd_to_producer;");
+
+$dbh->do("CREATE TABLE cd_to_producer (cd INTEGER,producer INTEGER);");
+
 #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
 
 # This is in Core now, but it's here just to test that it doesn't break
@@ -119,8 +132,13 @@ NULLINSEARCH: {
     => 'Nothing Found!';
 }
     
+my $cd = $schema->resultset ('CD')->create ({});
+
+my $producer = $schema->resultset ('Producer')->create ({});
+
+lives_ok { $cd->set_producers ([ $cd ]) } 'set_relationship doesnt die';
 
 # clean up our mess
 END {
     #$dbh->do("DROP TABLE artist") if $dbh;
-}
\ No newline at end of file
+}