X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2F02-Film.t;h=d303f35e3482e67d015e6bad7bf4f2b3b5e9ebcf;hb=86ef9f0d42674723bd1f2a23090a2ffe23d2aea3;hp=68ee88d5861e54f184c5da6072badac028c30d0b;hpb=12bbb33986a29dc27dd3e2b9d082a87f50124ec1;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/cdbi-t/02-Film.t b/t/cdbi-t/02-Film.t index 68ee88d..d303f35 100644 --- a/t/cdbi-t/02-Film.t +++ b/t/cdbi-t/02-Film.t @@ -3,8 +3,13 @@ use Test::More; $| = 1; BEGIN { - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 93); + 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 => 96); } INIT { @@ -28,7 +33,8 @@ is(Film->__driver, "SQLite", "Driver set correctly"); { eval { my $id = Film->title }; - like $@, qr/class method/, "Can't get title with no object"; + #like $@, qr/class method/, "Can't get title with no object"; + ok $@, "Can't get title with no object"; } eval { my $duh = Film->create; }; @@ -80,6 +86,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 +168,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 +185,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"; } } @@ -221,12 +232,15 @@ is($btaste->Director, 'Lenny Bruce', 'set new Director'); $btaste->discard_changes; is($btaste->Director, $orig_director, 'discard_changes()'); -{ +SKIP: { + skip "ActiveState perl produces additional warnings", 3 + if ($^O eq 'MSWin32'); + Film->autoupdate(1); 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 @@ -238,7 +252,6 @@ is($btaste->Director, $orig_director, 'discard_changes()'); $btaste3->NumExplodingSheep(13); } is @warnings, 1, "DESTROY without update warns"; -print join("\n", @warnings); Film->autoupdate(0); } @@ -349,7 +362,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 +372,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 +385,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"; + }