custom rs methods working
[dbsrgits/DBIx-Class-ResultSet-WithMetaData.git] / t / custom_methods.t
CommitLineData
46845551 1#!perl
2
3use Test::More tests => 2;
4use lib qw(t/lib);
5use DBICTest;
6use Data::Dumper;
7
8# set up and populate schema
9ok(my $schema = DBICTest->init_schema(), 'got schema');
10
11{
12 my $artist_rs = $schema->resultset('Artist')->order_by(col => 'artistid')->display();
13 warn Dumper($artist_rs);
14 is_deeply($artist_rs, [
15 {
16 'artistid' => '1',
17 'name' => 'Caterwauler McCrae'
18 },
19 {
20 'artistid' => '2',
21 'name' => 'Random Boy Band'
22 },
23 {
24 'artistid' => '3',
25 'name' => 'We Are Goth'
26 }
27 ], 'ordered display returned as expected');
28}
29
30{
31 my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->display();
32 is_deeply($artists, [
33 {
34 'artistid' => '1',
35 'name' => 'Caterwauler McCrae',
36 'substr' => 'Cat'
37 },
38 {
39 'artistid' => '2',
40 'name' => 'Random Boy Band',
41 'substr' => 'Ran'
42 },
43 {
44 'artistid' => '3',
45 'name' => 'We Are Goth',
46 'substr' => 'We '
47 }
48 ], 'display with substring okay');
49}
50
51
52