first tests for identifier remapping and a slight refactoring
[dbsrgits/DBIx-Class.git] / t / dq / remap.t
CommitLineData
1f005975 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use Test::Warn;
7use lib qw(t/lib);
8use Data::Query::ExprDeclare;
9use Data::Query::ExprHelpers;
10use DBICTest;
11use DBIC::SqlMakerTest;
12
13my $schema = DBICTest->init_schema();
14
15$schema->source($_)->resultset_class('DBIx::Class::ResultSet::WithDQMethods')
16 for qw(CD Tag);
17
18my $cds = $schema->resultset('CD');
19
20is_deeply(
21 [ $cds->_remap_identifiers(Identifier('name')) ],
22 [ Identifier('me', 'name'), [] ],
23 'Remap column on me'
24);
25
26is_deeply(
27 [ $cds->_remap_identifiers(Identifier('artist', 'name')) ],
28 [ Identifier('artist', 'name'), [ { artist => {} } ] ],
29 'Remap column on rel'
30);
31
32is_deeply(
33 [ $cds->search({}, { join => { single_track => { cd => 'artist' } } })
34 ->_remap_identifiers(Identifier('artist', 'name')) ],
35 [ Identifier('artist_2', 'name'), [ { artist => {} } ] ],
36 'Remap column on rel with re-alias'
37);
38
39done_testing;