Move the Subclassing POD under Examples
[dbsrgits/DBIx-Class.git] / t / 78self_referencial.t
CommitLineData
70350518 1use strict;
8273e845 2use warnings;
70350518 3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $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
28plan tests => 4;
29
30my $item = $schema->resultset("SelfRef")->find( 1 );
31is( $item->name, 'First', 'proper start item' );
32
33my @aliases = $item->aliases;
34
35is( scalar @aliases, 1, 'proper number of aliases' );
36
37my $orig = $aliases[ 0 ]->self_ref;
38my $alias = $aliases[ 0 ]->alias;
39
40is( $orig->name, 'First', 'proper original' );
41is( $alias->name, 'Second', 'proper alias' );
42