X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2F02-Film.t;h=ee28a68dd734ab605c65ef799643a5efc3636236;hb=331a564;hp=a9405bc9873a0fe58091357bbc0d4ddc45cb0b7b;hpb=d651c864c635cf3569fa2ec8e58ebb4298ced8e2;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/02-Film.t b/t/cdbi-t/02-Film.t index a9405bc..ee28a68 100644 --- a/t/cdbi-t/02-Film.t +++ b/t/cdbi-t/02-Film.t @@ -9,7 +9,7 @@ BEGIN { next; } eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 96); + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 98); } INIT { @@ -37,7 +37,7 @@ is(Film->__driver, "SQLite", "Driver set correctly"); ok $@, "Can't get title with no object"; } -eval { my $duh = Film->create; }; +eval { my $duh = Film->insert; }; like $@, qr/create needs a hashref/, "needs a hashref"; ok +Film->create_test_film; @@ -126,6 +126,11 @@ is($blrunner_dc->NumExplodingSheep, undef, 'Sheep correct'); { Film->add_constructor(title_asc => "title LIKE ? ORDER BY title"); Film->add_constructor(title_desc => "title LIKE ? ORDER BY title DESC"); + Film->add_constructor(title_asc_nl => q{ + title LIKE ? + ORDER BY title + LIMIT 1 + }); { my @films = Film->title_asc("Bladerunner%"); @@ -137,6 +142,11 @@ is($blrunner_dc->NumExplodingSheep, undef, 'Sheep correct'); is @films, 2, "We have 2 Bladerunners"; is $films[0]->Title, $blrunner_dc->Title, "Ordered correctly"; } + { + my @films = Film->title_asc_nl("Bladerunner%"); + is @films, 1, "We have 2 Bladerunners"; + is $films[0]->Title, $blrunner->Title, "Ordered correctly"; + } } # Multi-column search @@ -163,11 +173,11 @@ is($blrunner_dc->NumExplodingSheep, undef, 'Sheep correct'); } eval { - my $ishtar = Film->create({ Title => 'Ishtar', Director => 'Elaine May' }); + my $ishtar = Film->insert({ Title => 'Ishtar', Director => 'Elaine May' }); my $mandn = - Film->create({ Title => 'Mikey and Nicky', Director => 'Elaine May' }); + Film->insert({ Title => 'Mikey and Nicky', Director => 'Elaine May' }); my $new_leaf = - Film->create({ Title => 'A New Leaf', Director => 'Elaine May' }); + Film->insert({ 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, @@ -234,7 +244,7 @@ is($btaste->Director, $orig_director, 'discard_changes()'); SKIP: { skip "ActiveState perl produces additional warnings", 3 - if ($^O eq 'Win32'); + if ($^O eq 'MSWin32'); Film->autoupdate(1); my $btaste2 = Film->retrieve($btaste->id); @@ -263,7 +273,7 @@ SKIP: { { # update deleted object my $rt = "Royal Tenenbaums"; - my $ten = Film->create({ title => $rt, Rating => "R" }); + my $ten = Film->insert({ title => $rt, Rating => "R" }); $ten->rating(18); Film->set_sql(drt => "DELETE FROM __TABLE__ WHERE title = ?"); Film->sql_drt->execute($rt); @@ -284,7 +294,7 @@ SKIP: { # Primary key of 0 { - my $zero = Film->create({ Title => 0, Rating => "U" }); + my $zero = Film->insert({ Title => 0, Rating => "U" }); ok defined $zero, "Create 0"; ok my $ret = Film->retrieve(0), "Retrieve 0"; is $ret->Title, 0, "Title OK"; @@ -344,7 +354,7 @@ if (0) { { { - ok my $byebye = DeletingFilm->create( + ok my $byebye = DeletingFilm->insert( { Title => 'Goodbye Norma Jean', Rating => 'PG', @@ -362,9 +372,8 @@ if (0) { } SKIP: { - #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; + skip "Caching has been removed", 5 + if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex"); # my bad taste is your bad taste my $btaste = Film->retrieve('Bad Taste'); @@ -386,7 +395,7 @@ SKIP: { isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste4), "Clearing cache and retrieving again gives new object"; - $btaste=Film->create({ + $btaste=Film->insert({ Title => 'Bad Taste 2', Director => 'Peter Jackson', Rating => 'R',