Commit | Line | Data |
b9cc2f76 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use FindBin '$Bin'; |
5 | use lib "$Bin/lib"; |
6 | |
7 | use Test::More; |
8 | use Test::Exception; |
9 | use Catalyst::Model::DBIC::Schema; |
10 | use ASchemaClass; |
21d8159f |
11 | use AnotherSchemaClass; |
b9cc2f76 |
12 | |
21d8159f |
13 | # reusing the same app for 2 models, gets a redefined warning |
14 | $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ }; |
b9cc2f76 |
15 | |
16 | ok((my $m = instance(a_schema_option => 'mtfnpy')), 'instance'); |
17 | |
18 | is $m->schema->a_schema_option, 'mtfnpy', 'option was passed from config'; |
19 | |
20 | lives_ok { $m->a_schema_option('pass the crack pipe') } 'delegate called'; |
21 | |
22 | is $m->schema->a_schema_option, 'pass the crack pipe', 'delegation works'; |
23 | |
21d8159f |
24 | ok(($m = instance(schema_class => 'AnotherSchemaClass')), 'instance'); |
25 | |
bd99d89c |
26 | is $m->resultset('User')->rs_config_option, 'configured rs value', |
21d8159f |
27 | 'ResultSet option passed from config'; |
28 | |
29 | done_testing; |
30 | |
b9cc2f76 |
31 | sub instance { |
21d8159f |
32 | MyApp::Model::DB->COMPONENT('MyApp', { |
ae3d05c2 |
33 | traits => 'SchemaProxy', |
b9cc2f76 |
34 | schema_class => 'ASchemaClass', |
35 | connect_info => ['dbi:SQLite:foo.db', '', ''], |
36 | @_, |
37 | }) |
38 | } |
d816d7bf |
39 | |
21d8159f |
40 | BEGIN { |
41 | package MyApp; |
42 | use Catalyst; |
43 | __PACKAGE__->config({ |
bd99d89c |
44 | 'Model::DB::User' => { |
21d8159f |
45 | rs_config_option => 'configured rs value', |
46 | }, |
47 | }); |
48 | } |
49 | |
50 | { |
51 | package MyApp::Model::DB; |
52 | use base 'Catalyst::Model::DBIC::Schema'; |
53 | } |