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 {
};
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";
my @film = Film->search({ sheep => 1 });
is @film, 2, "Can search with modified accessor";
};
+is $@, '', "No errors";
{