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