Commit | Line | Data |
97c96475 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use Test::Exception; |
6 | use lib qw(t/lib); |
7 | use DBICTest; |
8 | |
9 | my $schema = DBICTest->init_schema(); |
10 | |
11 | my $cd = $schema->resultset('CD')->find(2); |
12 | is($cd->notes, $cd->liner_notes->notes, 'notes proxy ok'); |
13 | is($cd->artist_name, $cd->artist->name, 'artist_name proxy ok'); |
14 | |
15 | my $track = $cd->tracks->first; |
16 | is($track->cd_title, $track->cd->title, 'cd_title proxy ok'); |
17 | is($track->cd_title, $cd->title, 'cd_title proxy II ok'); |
18 | is($track->year, $cd->year, 'year proxy ok'); |
19 | |
20 | my $tag = $schema->resultset('Tag')->first; |
21 | is($tag->year, $tag->cd->year, 'year proxy II ok'); |
22 | is($tag->cd_title, $tag->cd->title, 'cd_title proxy III ok'); |
23 | |
24 | my $bookmark = $schema->resultset('Bookmark')->create ({ |
25 | link => { url => 'http://cpan.org', title => 'CPAN' }, |
26 | }); |
27 | my $link = $bookmark->link; |
28 | ok($bookmark->link_id == $link->id, 'link_id proxy ok'); |
29 | is($bookmark->link_url, $link->url, 'link_url proxy ok'); |
30 | is($bookmark->link_title, $link->title, 'link_title proxy ok'); |
31 | |
32 | my $cd_source_class = $schema->class('CD'); |
33 | throws_ok { |
34 | $cd_source_class->add_relationship('artist_regex', |
35 | 'DBICTest::Schema::Artist', { |
36 | 'foreign.artistid' => 'self.artist' |
37 | }, { proxy => qr/\w+/ } |
38 | ) } qr/unable \s to \s process \s the \s \'proxy\' \s argument/ix, |
39 | 'proxy attr with a regex ok'; |
40 | throws_ok { |
41 | $cd_source_class->add_relationship('artist_sub', |
42 | 'DBICTest::Schema::Artist', { |
43 | 'foreign.artistid' => 'self.artist' |
44 | }, { proxy => sub {} } |
45 | ) } qr/unable \s to \s process \s the \s \'proxy\' \s argument/ix, |
46 | 'proxy attr with a sub ok'; |
47 | |
48 | done_testing; |