Only load DBICTest::Schema when needed in tests
[dbsrgits/DBIx-Class.git] / t / 60core.t
index 3a674de..d848a91 100644 (file)
@@ -5,8 +5,7 @@ use Test::More;
 use Test::Exception;
 use Test::Warn;
 use lib qw(t/lib);
-use DBICTest;
-use DBIC::SqlMakerTest;
+use DBICTest ':DiffSQL';
 
 my $schema = DBICTest->init_schema();
 
@@ -131,6 +130,13 @@ throws_ok {
 
 is($schema->resultset("Artist")->count, 4, 'count ok');
 
+# test find on an unresolvable condition
+is(
+  $schema->resultset('Artist')->find({ artistid => [ -and => 1, 2 ]}),
+  undef
+);
+
+
 # test find_or_new
 {
   my $existing_obj = $schema->resultset('Artist')->find_or_new({
@@ -243,7 +249,7 @@ is($schema->class("Artist")->field_name_for->{name}, 'artist name', 'mk_classdat
 
 my $search = [ { 'tags.tag' => 'Cheesy' }, { 'tags.tag' => 'Blue' } ];
 
-my( $or_rs ) = $schema->resultset("CD")->search_rs($search, { join => 'tags',
+my $or_rs = $schema->resultset("CD")->search_rs($search, { join => 'tags',
                                                   order_by => 'cdid' });
 is($or_rs->all, 5, 'Joined search with OR returned correct number of rows');
 is($or_rs->count, 5, 'Search count with OR ok');
@@ -292,7 +298,7 @@ is ($collapsed_or_rs->count, 4, 'Collapsed search count with OR ok');
 my $tag_rs = $schema->resultset('Tag')->search(
                [ { 'me.tag' => 'Cheesy' }, { 'me.tag' => 'Blue' } ]);
 
-my $rel_rs = $tag_rs->search_related('cd');
+my $rel_rs = $tag_rs->search_related('cd', {}, { order_by => 'cd.cdid'} );
 
 is($rel_rs->count, 5, 'Related search ok');
 
@@ -570,13 +576,15 @@ lives_ok (sub { my $newlink = $newbook->link}, "stringify to false value doesn't
 {
     my $new_artist = $schema->resultset('Artist')->new({});
     isa_ok( $new_artist, 'DBIx::Class::Row', '$rs->new gives a row object' );
+    lives_ok { $new_artist->insert() } 'inserting without specifying any columns works';
+    $new_artist->discard_changes;
+    $new_artist->delete;
 }
 
-
 # make sure we got rid of the compat shims
 SKIP: {
     my $remove_version = 0.083;
-    skip "Remove in $remove_version", 3 if $DBIx::Class::VERSION < $remove_version;
+    skip "Remove in $remove_version", 3 if DBIx::Class->VERSION < $remove_version;
 
     for (qw/compare_relationship_keys pk_depends_on resolve_condition/) {
       ok (! DBIx::Class::ResultSource->can ($_), "$_ no longer provided by DBIx::Class::ResultSource, removed before $remove_version");
@@ -619,7 +627,7 @@ SKIP: {
 #------------------------------
 #
 SKIP: {
-    skip "Something needs to be done before 0.09", 2 if $DBIx::Class::VERSION < 0.09;
+    skip "Something needs to be done before 0.09", 2 if DBIx::Class->VERSION < 0.09;
 
     my $row = $schema->resultset ('Artist')->next;