X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Finflate%2Fhri_torture.t;h=ceee197b0e55079861ea0bf101be7d8dae696fc4;hb=52864fbd5;hp=04237f92ab9dddcbacb17f4b3d6676f26ccdf5d9;hpb=b8ced1f527fe09d52ba7bd4c8e2820fddb278e20;p=dbsrgits%2FDBIx-Class.git diff --git a/t/inflate/hri_torture.t b/t/inflate/hri_torture.t index 04237f9..ceee197 100644 --- a/t/inflate/hri_torture.t +++ b/t/inflate/hri_torture.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Deep; use lib qw(t/lib); use DBICTest; @@ -48,17 +49,33 @@ for (1,2) { $schema->resultset('CD')->create({ artist => 1, year => 1977, title => "fuzzy_$_" }); } -my $rs = $schema->resultset('CD'); +{ + package DBICTest::HRI::Subclass; + use base 'DBIx::Class::ResultClass::HashRefInflator'; +} + +{ + package DBICTest::HRI::Around; + use base 'DBIx::Class::ResultClass::HashRefInflator'; + + sub inflate_result { shift->next::method(@_) } +} -is_deeply - $rs->search({}, { +for my $rs ( + $schema->resultset('CD')->search_rs({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }), + $schema->resultset('CD')->search_rs({}, { result_class => 'DBICTest::HRI::Subclass' }), + $schema->resultset('CD')->search_rs({}, { result_class => 'DBICTest::HRI::Around' }), +) { + +cmp_deeply + [ $rs->search({}, { columns => { year => 'me.year', 'single_track.cd.artist.name' => 'artist.name', }, join => { single_track => { cd => 'artist' } }, order_by => [qw/me.cdid artist.artistid/], - })->all_hri, + })->all ], [ { single_track => undef, @@ -87,11 +104,11 @@ is_deeply year => 1977 }, ], - 'plain 1:1 descending chain' + 'plain 1:1 descending chain ' . $rs->result_class ; -is_deeply - $rs->search({}, { +cmp_deeply + [ $rs->search({}, { columns => { 'artist' => 'me.artist', 'title' => 'me.title', @@ -102,7 +119,7 @@ is_deeply }, join => { single_track => { cd => { artist => { cds => 'tracks' } } } }, order_by => [qw/me.cdid artist.artistid cds.cdid tracks.trackid/], - })->all_hri, + })->all ], [ { artist => 1, @@ -323,11 +340,11 @@ is_deeply year => 1977 } ], - 'non-collapsing 1:1:1:M:M chain', + 'non-collapsing 1:1:1:M:M chain ' . $rs->result_class, ; -is_deeply - $rs->search({}, { +cmp_deeply + [ $rs->search({}, { columns => { 'artist' => 'me.artist', 'title' => 'me.title', @@ -339,7 +356,7 @@ is_deeply join => { single_track => { cd => { artist => { cds => 'tracks' } } } }, order_by => [qw/me.cdid artist.artistid cds.cdid tracks.trackid/], collapse => {}, #hashref to keep older DBIC versions happy (doesn't actually work) - })->all_hri, + })->all ], [ { artist => 1, @@ -430,7 +447,9 @@ is_deeply year => 1977 } ], - 'collapsing 1:1:1:M:M chain', + 'collapsing 1:1:1:M:M chain ' . $rs->result_class, ; +} + done_testing;