File: result-class-dwim.t

package info (click to toggle)
libdbix-class-helpers-perl 2.013002-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 420 kB
  • sloc: perl: 1,931; sql: 73; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!perl

use strict;
use warnings;

use lib 't/lib';
use Test::More;
use Test::Deep;

use TestSchema;
my $schema = TestSchema->deploy_or_connect();
$schema->prepopulate;

my $rs = $schema->resultset('Foo');

my $expect = [ $rs->search(undef, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' })->all ];

ok scalar @{$expect}, 'make sure test environment is not ruined forever';

cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HashRefInflator works';

cmp_deeply [ $rs->search(undef, { result_class => '::HashRefInflator' })->all ], $expect, '::HRI works';

my $rs2 = $rs->search(undef);
$rs2->result_class('::HRI');
cmp_deeply [ $rs2->all ], $expect, '::HRI also works from result_class accessor';

done_testing;