release 0.63
[catagits/Catalyst-Model-DBIC-Schema.git] / t / 09schema_options.t
CommitLineData
b9cc2f76 1use strict;
2use warnings;
3
4use FindBin '$Bin';
5use lib "$Bin/lib";
6
7use Test::More;
8use Test::Exception;
9use Catalyst::Model::DBIC::Schema;
10use ASchemaClass;
21d8159f 11use 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
16ok((my $m = instance(a_schema_option => 'mtfnpy')), 'instance');
17
18is $m->schema->a_schema_option, 'mtfnpy', 'option was passed from config';
19
20lives_ok { $m->a_schema_option('pass the crack pipe') } 'delegate called';
21
22is $m->schema->a_schema_option, 'pass the crack pipe', 'delegation works';
23
21d8159f 24ok(($m = instance(schema_class => 'AnotherSchemaClass')), 'instance');
25
bd99d89c 26is $m->resultset('User')->rs_config_option, 'configured rs value',
21d8159f 27 'ResultSet option passed from config';
28
29done_testing;
30
b9cc2f76 31sub 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 40BEGIN {
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}