[Bast-commits] r5164 - DBIx-Class/0.08/trunk/t/cdbi-t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Nov 20 11:01:14 GMT 2008


Author: ribasushi
Date: 2008-11-20 11:01:14 +0000 (Thu, 20 Nov 2008)
New Revision: 5164

Modified:
   DBIx-Class/0.08/trunk/t/cdbi-t/15-accessor.t
Log:
CDBI-compat tests by Dave Horwoth:

    OK. I've attached a patch to t/cdbi-t/15-accessor.t that does several
    things:

    (1) Fixes the way the arguments are built so the sheep argument is
    correct in the tests.

    (2) Adds explicit tests for the number of sheep so we can be sure which
    database record is actually returned.

    (3) Adds tests for find_or_create() with modified accessor names.

    (4) Fixes the test for search() to report all errors

    I still don't fully understand what's going on in the output below but I
    think they are genuine test failures. I'd appreciate it if somebody else
    could run the tests to make sure the results are not some artefact of my
    test environment. I also attached a copy of the modified test script so
    you don't even have to apply the patch first :)

    I don't know what the DestroyWarning at the end is all about.



Modified: DBIx-Class/0.08/trunk/t/cdbi-t/15-accessor.t
===================================================================
--- DBIx-Class/0.08/trunk/t/cdbi-t/15-accessor.t	2008-11-20 10:37:47 UTC (rev 5163)
+++ DBIx-Class/0.08/trunk/t/cdbi-t/15-accessor.t	2008-11-20 11:01:14 UTC (rev 5164)
@@ -8,7 +8,7 @@
         next;
     }
     eval "use DBD::SQLite";
-    plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 55);
+    plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 75);
 }
 
 INIT {
@@ -57,25 +57,68 @@
 };
 
 eval {
-    my $data = $data;
+    my $data = { %$data };
     $data->{NumExplodingSheep} = 1;
     ok my $bt = Film->create($data), "Modified accessor - with column name";
     isa_ok $bt, "Film";
+    is $bt->sheep, 1, 'sheep bursting violently';
 };
 is $@, '', "No errors";
 
 eval {
-    my $data = $data;
-    $data->{sheep} = 1;
+    my $data = { %$data };
+    $data->{sheep} = 2;
     ok my $bt = Film->create($data), "Modified accessor - with accessor";
     isa_ok $bt, "Film";
+    is $bt->sheep, 2, 'sheep bursting violently';
 };
 is $@, '', "No errors";
 
 eval {
+    my $data = { %$data };
+    $data->{NumExplodingSheep} = 1;
+    ok my $bt = Film->find_or_create($data),
+		"find_or_create Modified accessor - find with column name";
+    isa_ok $bt, "Film";
+    is $bt->sheep, 1, 'sheep bursting violently';
+};
+is $@, '', "No errors";
+
+eval {
+    my $data = { %$data };
+    $data->{sheep} = 1;
+    ok my $bt = Film->find_or_create($data),
+		"find_or_create Modified accessor - find with accessor";
+    isa_ok $bt, "Film";
+    is $bt->sheep, 1, 'sheep bursting violently';
+};
+is $@, '', "No errors";
+
+eval {
+    my $data = { %$data };
+    $data->{NumExplodingSheep} = 3;
+    ok my $bt = Film->find_or_create($data),
+		"find_or_create Modified accessor - create with column name";
+    isa_ok $bt, "Film";
+    is $bt->sheep, 3, 'sheep bursting violently';
+};
+is $@, '', "No errors";
+
+eval {
+    my $data = { %$data };
+    $data->{sheep} = 4;
+    ok my $bt = Film->find_or_create($data),
+		"find_or_create Modified accessor - create with accessor";
+    isa_ok $bt, "Film";
+    is $bt->sheep, 4, 'sheep bursting violently';
+};
+is $@, '', "No errors";
+
+eval {
     my @film = Film->search({ sheep => 1 });
     is @film, 2, "Can search with modified accessor";
 };
+is $@, '', "No errors";
 
 {
 




More information about the Bast-commits mailing list