X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2F18self_referencial.tl;h=5759aca34e3d3679f73d5c056563e3d18454c091;hb=70350518bbb31e5ac22fb3cb73d3e17409fcd332;hp=b061adba929c519c8138028b58d75d39e27651ee;hpb=4b8dcc58874223164d4a379a5db4a9cb737d7c7a;p=dbsrgits%2FDBIx-Class.git diff --git a/t/run/18self_referencial.tl b/t/run/18self_referencial.tl index b061adb..5759aca 100644 --- a/t/run/18self_referencial.tl +++ b/t/run/18self_referencial.tl @@ -1,39 +1,42 @@ -sub run_tests { -my $schema = shift; - -# this test will check to see if you can have 2 columns -# in the same class pointing at the same other class -# -# example: -# -# +---------+ +--------------+ -# | SelfRef | | SelfRefAlias | -# +---------+ 1-M +--------------+ -# | id |-------| self_ref | --+ -# | name | | alias | --+ -# +---------+ +--------------+ | -# /|\ | -# | | -# +--------------------------------+ -# -# see http://use.perl.org/~LTjake/journal/24876 for the -# issue with CDBI - -plan tests => 4; - -my $item = $schema->resultset("SelfRef")->find( 1 ); -is( $item->name, 'First', 'proper start item' ); - -my @aliases = $item->aliases; - -is( scalar @aliases, 1, 'proper number of aliases' ); - -my $orig = $aliases[ 0 ]->self_ref; -my $alias = $aliases[ 0 ]->alias; - -is( $orig->name, 'First', 'proper original' ); -is( $alias->name, 'Second', 'proper alias' ); - -} - -1; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + +# this test will check to see if you can have 2 columns +# in the same class pointing at the same other class +# +# example: +# +# +---------+ +--------------+ +# | SelfRef | | SelfRefAlias | +# +---------+ 1-M +--------------+ +# | id |-------| self_ref | --+ +# | name | | alias | --+ +# +---------+ +--------------+ | +# /|\ | +# | | +# +--------------------------------+ +# +# see http://use.perl.org/~LTjake/journal/24876 for the +# issue with CDBI + +plan tests => 4; + +my $item = $schema->resultset("SelfRef")->find( 1 ); +is( $item->name, 'First', 'proper start item' ); + +my @aliases = $item->aliases; + +is( scalar @aliases, 1, 'proper number of aliases' ); + +my $orig = $aliases[ 0 ]->self_ref; +my $alias = $aliases[ 0 ]->alias; + +is( $orig->name, 'First', 'proper original' ); +is( $alias->name, 'Second', 'proper alias' ); +