From: Luke Saunders Date: Mon, 16 Aug 2010 10:11:15 +0000 (+0200) Subject: failing test for object inflator X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d83e732b5f5add55448cb2cb60e980c1c57c5be;p=dbsrgits%2FDBIx-Class-ResultSet-WithMetaData.git failing test for object inflator --- diff --git a/t/custom_methods.t b/t/custom_methods.t index 1fd689d..d8b70dd 100644 --- a/t/custom_methods.t +++ b/t/custom_methods.t @@ -71,6 +71,27 @@ ok(my $schema = DBICTest->init_schema(), 'got schema'); ], 'display with substring using _with_meta_key okay'); } +{ + my $artists = $schema->resultset('Artist')->search({}, { order_by => 'artistid' })->with_substr_key_obj->display(); + is_deeply($artists, [ + { + 'artistid' => '1', + 'name' => 'Caterwauler McCrae', + 'substr' => 'Cat' + }, + { + 'artistid' => '2', + 'name' => 'Random Boy Band', + 'substr' => 'Ran' + }, + { + 'artistid' => '3', + 'name' => 'We Are Goth', + 'substr' => 'We ' + } + ], 'display with substring using _with_meta_key with object okay'); +} + # { # my $artists = $schema->resultset('Artist')->search({}, { order_by => 'artistid' })->with_substr_old->display(); # is_deeply($artists, [ diff --git a/t/lib/DBICTest/Schema/ResultSet/Artist.pm b/t/lib/DBICTest/Schema/ResultSet/Artist.pm index a3688f2..20ac92d 100644 --- a/t/lib/DBICTest/Schema/ResultSet/Artist.pm +++ b/t/lib/DBICTest/Schema/ResultSet/Artist.pm @@ -27,6 +27,16 @@ method with_substr_key () { return $self; } +method with_substr_key_obj () { + $self->_with_meta_key( + substr => sub { + my ($hash, $obj) = @_; + return substr($obj->name, 0, 3); + } + ); + return $self; +} + method with_substr_old () { foreach my $row ($self->all) { my $substr = substr($row->name, 0, 3);