fix some edge cases for use_moose option, and more tests
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 20invocations.t
index 9d5ad65..fe52379 100644 (file)
@@ -103,14 +103,52 @@ my @invocations = (
             [ $make_dbictest_db::dsn ],
         );
         DBICTest::Schema::12->clone;
-    }
+    },
+    'no_skip_load_external' => sub {
+        # By default we should pull in t/lib/DBICTest/Schema/13/Foo.pm $skip_me since t/lib is in @INC
+        use DBIx::Class::Schema::Loader;
+        DBIx::Class::Schema::Loader::make_schema_at(
+            'DBICTest::Schema::13',
+            { really_erase_my_files => 1, naming => 'current' },
+            [ $make_dbictest_db::dsn ],
+        );
+        DBICTest::Schema::13->clone;
+    },
+    'skip_load_external' => sub {
+        # When we explicitly skip_load_external t/lib/DBICTest/Schema/14/Foo.pm should be ignored
+        use DBIx::Class::Schema::Loader;
+        DBIx::Class::Schema::Loader::make_schema_at(
+            'DBICTest::Schema::14',
+            { really_erase_my_files => 1, naming => 'current', skip_load_external => 1 },
+            [ $make_dbictest_db::dsn ],
+        );
+        DBICTest::Schema::14->clone;
+    },
+    'moose' => sub {
+        package DBICTest::Schema::8;
+        use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
+        __PACKAGE__->connect(
+            $make_dbictest_db::dsn,
+            { loader_options => { use_moose => 1 } }
+        );
+    },
 );
 
 # 4 tests per k/v pair
-plan tests => 2 * @invocations;
+plan tests => 2 * @invocations + 2;  # + 2 more manual ones below.
 
 while(@invocations >= 2) {
     my $style = shift @invocations;
     my $subref = shift @invocations;
     test_schema($style, &$subref);
 }
+
+{
+    no warnings 'once';
+
+    is($DBICTest::Schema::13::Foo::skip_me, "bad mojo",
+        "external content loaded");
+    is($DBICTest::Schema::14::Foo::skip_me, undef,
+        "external content not loaded with skip_load_external => 1");
+}