CDBI-compat tests by Dave Horwoth:
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 15-accessor.t
index 91d6145..ab7263d 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
         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,18 +57,60 @@ my $data = {
 };
 
 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";
 
@@ -76,6 +118,7 @@ eval {
     my @film = Film->search({ sheep => 1 });
     is @film, 2, "Can search with modified accessor";
 };
+is $@, '', "No errors";
 
 {