Merge 'trunk' into 'replication_dedux'
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 12-filter.t
index a51d34d..979ad56 100644 (file)
@@ -2,8 +2,13 @@ use strict;
 use Test::More;
 
 BEGIN {
-       eval "use DBD::SQLite";
-       plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 50);
+  eval "use DBIx::Class::CDBICompat;";
+  if ($@) {
+    plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
+    next;
+  }
+  eval "use DBD::SQLite";
+  plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 50);
 }
 
 use lib 't/testlib';
@@ -93,12 +98,11 @@ is $@, '', "No errors";
 # Iterators
 #----------------------------------------------------------------------
 
-SKIP: {
-  skip "Compat layer doesn't have iterator support yet", 33;
+my $it_class = 'DBIx::Class::ResultSet';
 
 sub test_normal_iterator {
        my $it = $film->actors;
-       isa_ok $it, "Class::DBI::Iterator";
+       isa_ok $it, $it_class;
        is $it->count, 3, " - with 3 elements";
        my $i = 0;
        while (my $film = $it->next) {
@@ -112,7 +116,7 @@ test_normal_iterator;
 {
        Film->has_many(actor_ids => [ Actor => 'id' ]);
        my $it = $film->actor_ids;
-       isa_ok $it, "Class::DBI::Iterator";
+       isa_ok $it, $it_class;
        is $it->count, 3, " - with 3 elements";
        my $i = 0;
        while (my $film_id = $it->next) {
@@ -125,6 +129,10 @@ test_normal_iterator;
 # make sure nothing gets clobbered;
 test_normal_iterator;
 
+SKIP: {
+  #skip "dbic iterators don't support slice yet", 12;
+
+
 {
        my @acts = $film->actors->slice(1, 2);
        is @acts, 2, "Slice gives 2 actor";
@@ -146,7 +154,9 @@ test_normal_iterator;
 
 package Class::DBI::My::Iterator;
 
-use base 'Class::DBI::Iterator';
+use vars qw/@ISA/;
+
+@ISA = ($it_class);
 
 sub slice { qw/fred barney/ }
 
@@ -154,6 +164,8 @@ package main;
 
 Actor->iterator_class('Class::DBI::My::Iterator');
 
+delete $film->{related_resultsets};
+
 {
        my @acts = $film->actors->slice(1, 2);
        is @acts, 2, "Slice gives 2 results";