Commit | Line | Data |
70350518 |
1 | use strict; |
8273e845 |
2 | use warnings; |
70350518 |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
a47e1233 |
8 | my $schema = DBICTest->init_schema(); |
70350518 |
9 | |
10 | # this test will check to see if you can have 2 columns |
11 | # in the same class pointing at the same other class |
12 | # |
13 | # example: |
14 | # |
15 | # +---------+ +--------------+ |
16 | # | SelfRef | | SelfRefAlias | |
17 | # +---------+ 1-M +--------------+ |
18 | # | id |-------| self_ref | --+ |
19 | # | name | | alias | --+ |
20 | # +---------+ +--------------+ | |
21 | # /|\ | |
22 | # | | |
23 | # +--------------------------------+ |
24 | # |
25 | # see http://use.perl.org/~LTjake/journal/24876 for the |
26 | # issue with CDBI |
27 | |
28 | plan tests => 4; |
29 | |
30 | my $item = $schema->resultset("SelfRef")->find( 1 ); |
31 | is( $item->name, 'First', 'proper start item' ); |
32 | |
33 | my @aliases = $item->aliases; |
34 | |
35 | is( scalar @aliases, 1, 'proper number of aliases' ); |
36 | |
37 | my $orig = $aliases[ 0 ]->self_ref; |
38 | my $alias = $aliases[ 0 ]->alias; |
39 | |
40 | is( $orig->name, 'First', 'proper original' ); |
41 | is( $alias->name, 'Second', 'proper alias' ); |
42 | |