Add a test for another expected warning
[dbsrgits/DBIx-Class.git] / t / 63register_class.t
1 use strict;
2 use warnings;  
3
4 use Test::More tests => 3;
5 use lib qw(t/lib);
6 use DBICTest;
7 use DBICTest::Schema;
8 use DBICTest::Schema::Artist;
9
10 DBICTest::Schema::Artist->source_name('MyArtist');
11 {
12     my $w;
13     local $SIG{__WARN__} = sub { $w = shift };
14     DBICTest::Schema->register_class('FooA', 'DBICTest::Schema::Artist');
15     like ($w, qr/use register_extra_source/, 'Complain about using register_class on an already-registered class');
16 }
17
18 my $schema = DBICTest->init_schema();
19
20 my $a = $schema->resultset('FooA')->search;
21 is($a->count, 3, 'have 3 artists');
22 is($schema->class('FooA'), 'DBICTest::FooA', 'Correct artist class');
23
24 # clean up
25 DBICTest::Schema->_unregister_source('FooA');