From: Toby Corkindale Date: Thu, 4 Jun 2009 08:35:57 +0000 (+0000) Subject: New test which attempts to add a new relationship to an existing class, after X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6ec786f4251cc6ea59e5b2eec949f44916ee709;p=dbsrgits%2FDBIx-Class-Historic.git New test which attempts to add a new relationship to an existing class, after the schema has been initialised. Currently the test fails, as the relationship is not added. Discussion on IRC indicates this probably *should* work. --- diff --git a/t/relationship/afterthought.t b/t/relationship/afterthought.t new file mode 100644 index 0000000..fb2bd82 --- /dev/null +++ b/t/relationship/afterthought.t @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +use Test::More tests => 2; +use lib qw(t/lib); +use DBICTest; + +=head1 DESCRIPTION + +Attempt to add a relationship to a class *after* they've been initialised.. + +=cut + +my $schema = DBICTest->init_schema(); + +my @previous_rels = sort $schema->source('Artist')->relationships; + +my $class = $schema->class('Artist'); +$class->belongs_to('rank' => $schema->class('Lyrics')); + +# Now check we have the relationship: +my $source = $schema->source('Artist'); + +is_deeply( + [sort $source->relationships], + [sort(@previous_rels, 'rank')], + 'Found rank in relationships' +); + +ok($source->relationship_info('rank'), "We have relationship info for rank"); +