X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Finflate%2Fhri_torture.t;h=92aa2d8af72fc3fab2370eb3609897b245da540e;hb=cc8ffd7bfc8a375545f35c8be3c224cf365ee7e7;hp=04237f92ab9dddcbacb17f4b3d6676f26ccdf5d9;hpb=ce556881780369e33743ef86a0cb183e976d3d19;p=dbsrgits%2FDBIx-Class.git diff --git a/t/inflate/hri_torture.t b/t/inflate/hri_torture.t index 04237f9..92aa2d8 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,50 +49,50 @@ 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(@_) } +} + +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' }), +) { -is_deeply - $rs->search({}, { +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, - year => 1981 - }, - { - single_track => undef, - year => 1976 - }, - { - single_track => { - cd => { - artist => { - name => "JMJ" - } - } + { year => 1981, single_track => undef }, + { year => 1976, single_track => undef }, + { year => 1978, single_track => { + cd => { + artist => { name => "JMJ" } }, - year => 1978 - }, - { - single_track => undef, - year => 1977 - }, - { - single_track => undef, - year => 1977 - }, + }}, + { year => 1977, single_track => undef }, + { year => 1977, single_track => undef }, + ], - '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,232 +103,165 @@ 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, - single_track => undef, - title => "Magnetic Fields", - year => 1981 + artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "Oxygene", - year => 1976 + artist => 1, title => "Oxygene", year => 1976, single_track => undef, }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m3" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m4" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 2, - tracks => { + artistid => 1, cds => { + cdid => 2, tracks => { title => "o2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 2, - tracks => { + artistid => 1, cds => { + cdid => 2, tracks => { title => "o1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e3" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 4, - tracks => undef + artistid => 1, cds => { + cdid => 4, tracks => undef } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 5, - tracks => undef + artistid => 1, cds => { + cdid => 5, tracks => undef } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => undef, - title => "fuzzy_1", - year => 1977 + artist => 1, title => "fuzzy_1", year => 1977, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "fuzzy_2", - year => 1977 + artist => 1, title => "fuzzy_2", year => 1977, single_track => undef, } ], - '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', @@ -338,99 +272,62 @@ 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, + collapse => 1, + })->all ], [ { - artist => 1, - single_track => undef, - title => "Magnetic Fields", - year => 1981 + artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "Oxygene", - year => 1976 + artist => 1, title => "Oxygene", year => 1976, single_track => undef, }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => [ + artistid => 1, cds => [ { - cdid => 1, - tracks => [ - { - title => "m1" - }, - { - title => "m2" - }, - { - title => "m3" - }, - { - title => "m4" - } + cdid => 1, tracks => [ + { title => "m1" }, + { title => "m2" }, + { title => "m3" }, + { title => "m4" }, ] }, { - cdid => 2, - tracks => [ - { - title => "o2" - }, - { - title => "o1" - } + cdid => 2, tracks => [ + { title => "o2" }, + { title => "o1" }, ] }, { - cdid => 3, - tracks => [ - { - title => "e1" - }, - { - title => "e2" - }, - { - title => "e3" - } + cdid => 3, tracks => [ + { title => "e1" }, + { title => "e2" }, + { title => "e3" }, ] }, { - cdid => 4, - tracks => [] + cdid => 4, tracks => [], }, { - cdid => 5, - tracks => [] + cdid => 5, tracks => [], } ] } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => undef, - title => "fuzzy_1", - year => 1977 + artist => 1, title => "fuzzy_1", year => 1977, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "fuzzy_2", - year => 1977 + artist => 1, title => "fuzzy_2", year => 1977, single_track => undef, } ], - 'collapsing 1:1:1:M:M chain', + 'collapsing 1:1:1:M:M chain ' . $rs->result_class, ; +} + done_testing;