test for connecting through schema_base_class
Ben Tilly [Sat, 9 Jul 2011 19:24:57 +0000 (12:24 -0700)]
Add test for applying schema_base_class to dynamic schemas at
'connection' time.

t/60schema_base_dispatched.t [new file with mode: 0644]
t/lib/TestSchemaBaseClass.pm [new file with mode: 0644]

diff --git a/t/60schema_base_dispatched.t b/t/60schema_base_dispatched.t
new file mode 100644 (file)
index 0000000..abba311
--- /dev/null
@@ -0,0 +1,21 @@
+# test that the class in schema_base_class gets used when loading the schema
+# by Ben Tilly (  btilly -at|   gmail.com )
+
+use strict;
+use Test::More tests => 1;
+use DBIx::Class::Schema::Loader qw(make_schema_at);
+use lib 't/lib';
+use make_dbictest_db;
+
+make_schema_at(
+    'DBICTest::Schema::_test_schema_base',
+    {
+        really_erase_my_files => 1,
+       naming => 'current',
+       use_namespaces => 0,
+       schema_base_class => 'TestSchemaBaseClass',
+    },
+    [ $make_dbictest_db::dsn ],
+);
+
+ok($TestSchemaBaseClass::test_ok, "Connected using schema_base_class.");
diff --git a/t/lib/TestSchemaBaseClass.pm b/t/lib/TestSchemaBaseClass.pm
new file mode 100644 (file)
index 0000000..82e36dc
--- /dev/null
@@ -0,0 +1,16 @@
+package TestSchemaBaseClass;
+use base DBIx::Class::Schema;
+
+our $test_ok = 0;
+
+sub connection {
+    my ($self, @info) = @_;
+
+    if ($info[0] =~ /^dbi/) {
+        $test_ok = 1;
+    }
+
+    return $self->next::method(@info);
+}
+
+1;