removing largely unnecessary dep on MooseX::Method::Signatures
[dbsrgits/DBIx-Class-ResultSet-WithMetaData.git] / t / custom_methods.t
CommitLineData
46845551 1#!perl
2
3b599f0b 3use Test::More tests => 3;
46845551 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();
46845551 13 is_deeply($artist_rs, [
14 {
15 'artistid' => '1',
16 'name' => 'Caterwauler McCrae'
17 },
18 {
19 'artistid' => '2',
20 'name' => 'Random Boy Band'
21 },
22 {
23 'artistid' => '3',
24 'name' => 'We Are Goth'
25 }
26 ], 'ordered display returned as expected');
27}
28
29{
30 my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->display();
31 is_deeply($artists, [
32 {
33 'artistid' => '1',
34 'name' => 'Caterwauler McCrae',
35 'substr' => 'Cat'
36 },
37 {
38 'artistid' => '2',
39 'name' => 'Random Boy Band',
40 'substr' => 'Ran'
41 },
42 {
43 'artistid' => '3',
44 'name' => 'We Are Goth',
45 'substr' => 'We '
46 }
47 ], 'display with substring okay');
48}
49
79b18b81 50{
51 my $artists = $schema->resultset('Artist')->order_by(col => 'artistid')->with_substr->search({}, { prefetch => 'cds', rows => 1 })->display();
52 use Data::Dumper; print Dumper($artists); exit;
53 is_deeply($artists, [
54 {
55 'artistid' => '1',
56 'name' => 'Caterwauler McCrae',
57 'substr' => 'Cat'
58 },
59 {
60 'artistid' => '2',
61 'name' => 'Random Boy Band',
62 'substr' => 'Ran'
63 },
64 {
65 'artistid' => '3',
66 'name' => 'We Are Goth',
67 'substr' => 'We '
68 }
69 ], 'display with substring okay');
70}
71
46845551 72
73