Merge 'reorganize_tests' into 'DBIx-Class-current'
[dbsrgits/DBIx-Class.git] / t / run / 28result_set_column.tl
CommitLineData
70350518 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8my $schema = DBICTest::init_schema();
2bb7b40b 9
cec13963 10plan tests => 8;
2bb7b40b 11
12my $rs = $cd = $schema->resultset("CD")->search({});
13
14my $rs_title = $rs->get_column('title');
15my $rs_year = $rs->get_column('year');
16
17is($rs_title->next, 'Spoonful of bees', "next okay");
18
19my @all = $rs_title->all;
20cmp_ok(scalar @all, '==', 5, "five titles returned");
21
22cmp_ok($rs_year->max, '==', 2001, "max okay for year");
23is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title");
24
25cmp_ok($rs_year->sum, '==', 9996, "three artists returned");
26
cec13963 27my $psrs = $schema->resultset('CD')->search({},
28 {
29 '+select' => \'COUNT(*)',
30 '+as' => 'count'
31 }
32);
33ok(defined($psrs->get_column('count')), '+select/+as count');
34
35$psrs = $schema->resultset('CD')->search({},
36 {
37 '+select' => [ \'COUNT(*)', 'title' ],
38 '+as' => [ 'count', 'addedtitle' ]
39 }
40);
41ok(defined($psrs->get_column('count')), '+select/+as arrayref count');
42ok(defined($psrs->get_column('addedtitle')), '+select/+as title');
2bb7b40b 43