Nuked 08-inheritcols.t since it's duplicated in 01-columns.t
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 02-Film.t
index bec54a2..b31ea5f 100644 (file)
@@ -4,7 +4,7 @@ $| = 1;
 
 BEGIN {
        eval "use DBD::SQLite";
-       plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 93);
+       plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 96);
 }
 
 INIT {
@@ -80,6 +80,9 @@ $gone->update;
        cmp_ok(@films, '==', 2, "We have 2 films in total");
 }
 
+# EXTRA TEST: added by mst to check a bug found by Numa
+cmp_ok(Film->count_all, '==', 2, "count_all confirms 2 films");
+
 my $gone_copy = Film->retrieve('Gone With The Wind');
 ok($gone->NumExplodingSheep == 5, 'update()');
 ok($gone->Rating eq 'NC-17', 'update() again');
@@ -159,6 +162,8 @@ eval {
                Film->create({ Title => 'Mikey and Nicky', Director => 'Elaine May' });
        my $new_leaf =
                Film->create({ Title => 'A New Leaf', Director => 'Elaine May' });
+
+#use Data::Dumper; die Dumper(Film->search( Director => 'Elaine May' ));
        cmp_ok(Film->search(Director => 'Elaine May'), '==', 3,
                "3 Films by Elaine May");
        ok(Film->retrieve('Ishtar')->delete,
@@ -174,7 +179,7 @@ eval {
                cmp_ok(Film->search(Director => 'Elaine May'), '==',
                        0, "0 Films by Elaine May");
                 SKIP: {
-                    skip "No deprecated warnings from DBIx::Class", 1;
+                    skip "No deprecated warnings from compat layer", 1;
                    is $deprecated, 1, "Got a deprecated warning";
                 }
        }
@@ -226,7 +231,7 @@ is($btaste->Director, $orig_director, 'discard_changes()');
        my $btaste2 = Film->retrieve($btaste->id);
        $btaste->NumExplodingSheep(18);
        my @warnings;
-       local $SIG{__WARN__} = sub { push @warnings, @_; };
+       local $SIG{__WARN__} = sub { push(@warnings, @_); };
        {
 
                # unhook from live object cache, so next one is not from cache
@@ -280,7 +285,7 @@ print join("\n", @warnings);
 
 # Change after_update policy
 SKIP: {
-        skip "DBIx::Class compat doesn't handle triggers yet", 4;
+        skip "DBIx::Class compat doesn't handle the exists stuff quite right yet", 4;
        my $bt = Film->retrieve($btaste->id);
        $bt->autoupdate(1);
 
@@ -349,7 +354,7 @@ if (0) {
 }
 
 SKIP: {
-        skip "DBIx::Class doesn't yet have a live objects index", 3;
+        #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;
 
@@ -359,6 +364,10 @@ SKIP: {
        is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
                "Retrieving twice gives ref to same object";
 
+       my ($btaste5) = Film->search(title=>'Bad Taste');
+       is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste5),
+               "Searching also gives ref to same object";
+
        $btaste2->remove_from_object_index;
        my $btaste3 = Film->retrieve('Bad Taste');
        isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste3),
@@ -368,4 +377,15 @@ SKIP: {
        my $btaste4 = Film->retrieve('Bad Taste');
        isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste4),
                "Clearing cache and retrieving again gives new object";
+  $btaste=Film->create({
+               Title             => 'Bad Taste 2',
+               Director          => 'Peter Jackson',
+               Rating            => 'R',
+               NumExplodingSheep => 2,
+       });
+       $btaste2 = Film->retrieve('Bad Taste 2');
+       is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
+               "Creating and retrieving gives ref to same object";
 }