Silence cdbi tests like everything else
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 02-Film.t
index 6a4d7f6..bd42d6e 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
     next;
   }
   eval "use DBD::SQLite";
-  plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 96);
+  plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 98);
 }
 
 INIT {
@@ -126,6 +126,11 @@ is($blrunner_dc->NumExplodingSheep, undef, 'Sheep correct');
 {
        Film->add_constructor(title_asc  => "title LIKE ? ORDER BY title");
        Film->add_constructor(title_desc => "title LIKE ? ORDER BY title DESC");
+    Film->add_constructor(title_asc_nl => q{
+        title LIKE ?
+        ORDER BY title
+        LIMIT 1
+    });
 
        {
                my @films = Film->title_asc("Bladerunner%");
@@ -137,6 +142,11 @@ is($blrunner_dc->NumExplodingSheep, undef, 'Sheep correct');
                is @films, 2, "We have 2 Bladerunners";
                is $films[0]->Title, $blrunner_dc->Title, "Ordered correctly";
        }
+       {
+               my @films = Film->title_asc_nl("Bladerunner%");
+               is @films, 1, "We have 2 Bladerunners";
+               is $films[0]->Title, $blrunner->Title, "Ordered correctly";
+       }
 }
 
 # Multi-column search
@@ -221,16 +231,25 @@ ok(
 );
 
 # Test that a disconnect doesnt harm anything.
-Film->db_Main->disconnect;
-@films = Film->search({ Rating => 'NC-17' });
-ok(@films == 1 && $films[0]->id eq $gone->id, 'auto reconnection');
-
-# Test discard_changes().
-my $orig_director = $btaste->Director;
-$btaste->Director('Lenny Bruce');
-is($btaste->Director, 'Lenny Bruce', 'set new Director');
-$btaste->discard_changes;
-is($btaste->Director, $orig_director, 'discard_changes()');
+{
+    # SQLite is loud on disconnect/reconnect. 
+    # This is solved in DBIC but not in ContextualFetch
+    local $SIG{__WARN__} = sub {
+      warn @_ unless $_[0] =~
+        /active statement handles|inactive database handle/;
+    };
+
+    Film->db_Main->disconnect;
+    @films = Film->search({ Rating => 'NC-17' });
+    ok(@films == 1 && $films[0]->id eq $gone->id, 'auto reconnection');
+
+    # Test discard_changes().
+    my $orig_director = $btaste->Director;
+    $btaste->Director('Lenny Bruce');
+    is($btaste->Director, 'Lenny Bruce', 'set new Director');
+    $btaste->discard_changes;
+    is($btaste->Director, $orig_director, 'discard_changes()');
+}
 
 SKIP: {
        skip "ActiveState perl produces additional warnings", 3
@@ -362,9 +381,8 @@ if (0) {
 }
 
 SKIP: {
-        #skip "DBIx::Class doesn't yet have a live objects index", 3;
-       #skip "Scalar::Util::weaken not available", 3
-               #if !$Class::DBI::Weaken_Is_Available;
+    skip "Caching has been removed", 5
+        if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex");
 
        # my bad taste is your bad taste
        my $btaste  = Film->retrieve('Bad Taste');