Massive cleanup of DateTime test dependencies, other interim
[dbsrgits/DBIx-Class.git] / t / storage / on_connect_call.t
index 880fa3b..bea5085 100644 (file)
@@ -10,7 +10,7 @@ use DBIx::Class::Storage::DBI;
 
 # !!! do not replace this with done_testing - tests reside in the callbacks
 # !!! number of calls is important
-use Test::More tests => 11;
+use Test::More tests => 16;
 # !!!
 
 my $schema = DBICTest::Schema->clone;
@@ -78,3 +78,21 @@ my $schema = DBICTest::Schema->clone;
   $schema->storage->ensure_connected;
   $schema->storage->disconnect; # this should not fire any tests
 }
+
+{
+  ok $schema->connection(
+    sub { DBI->connect(DBICTest->_database) },
+    {
+      # method list form
+      on_connect_call => [ sub { ok 1, "on_connect_call after DT parser" }, ],
+      on_disconnect_call => [ sub { ok 1, "on_disconnect_call after DT parser" }, ],
+    },
+  ), 'connection()';
+
+  ok (! $schema->storage->connected, 'start disconnected');
+
+  $schema->storage->_determine_driver;  # this should connect due to the coderef
+
+  ok ($schema->storage->connected, 'determine driver connects');
+  $schema->storage->disconnect;
+}