From: Brandon L. Black Date: Thu, 27 Jul 2006 05:58:36 +0000 (+0000) Subject: tests for load_namespaces X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=44930c3625222731c1a27a4a4d7c666d778eb59b;p=dbsrgits%2FDBIx-Class-Historic.git tests for load_namespaces --- diff --git a/t/39load_namespaces_four.t b/t/39load_namespaces_four.t new file mode 100644 index 0000000..c8e7463 --- /dev/null +++ b/t/39load_namespaces_four.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +unshift(@INC, './t/lib'); + +plan tests => 9; + +my $warnings; +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTest; + use base qw/DBIx::Class::Schema/; + __PACKAGE__->load_namespaces( default_resultset_base => 'RSBase' ); +}; +ok(!$@) or diag $@; +like($warnings, qr/load_namespaces found ResultSet class C with no corresponding ResultSource/); +like($warnings, qr/load_namespaces found Result class C with no corresponding ResultSource/); + +my $source_a = DBICNSTest->source('A'); +isa_ok($source_a, 'DBIx::Class::ResultSource::Table'); +my $rset_a = DBICNSTest->resultset('A'); +isa_ok($rset_a, 'DBICNSTest::ResultSet::A'); +my $resclass_a = DBICNSTest->resultset('A')->result_class; +is($resclass_a, 'DBICNSTest::Result::A'); + +my $source_b = DBICNSTest->source('B'); +isa_ok($source_b, 'DBIx::Class::ResultSource::Table'); +my $rset_b = DBICNSTest->resultset('B'); +isa_ok($rset_b, 'DBICNSTest::RSBase'); +my $resclass_b = DBICNSTest->resultset('B')->result_class; +is($resclass_b, 'DBICNSTest::ResultSource::B'); diff --git a/t/39load_namespaces_one.t b/t/39load_namespaces_one.t new file mode 100644 index 0000000..cf21fba --- /dev/null +++ b/t/39load_namespaces_one.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +unshift(@INC, './t/lib'); + +plan tests => 9; + +my $warnings; +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTest; + use base qw/DBIx::Class::Schema/; + __PACKAGE__->load_namespaces; +}; +ok(!$@) or diag $@; +like($warnings, qr/load_namespaces found ResultSet class C with no corresponding ResultSource/); +like($warnings, qr/load_namespaces found Result class C with no corresponding ResultSource/); + +my $source_a = DBICNSTest->source('A'); +isa_ok($source_a, 'DBIx::Class::ResultSource::Table'); +my $rset_a = DBICNSTest->resultset('A'); +isa_ok($rset_a, 'DBICNSTest::ResultSet::A'); +my $resclass_a = DBICNSTest->resultset('A')->result_class; +is($resclass_a, 'DBICNSTest::Result::A'); + +my $source_b = DBICNSTest->source('B'); +isa_ok($source_b, 'DBIx::Class::ResultSource::Table'); +my $rset_b = DBICNSTest->resultset('B'); +isa_ok($rset_b, 'DBIx::Class::ResultSet'); +my $resclass_b = DBICNSTest->resultset('B')->result_class; +is($resclass_b, 'DBICNSTest::ResultSource::B'); diff --git a/t/39load_namespaces_three.t b/t/39load_namespaces_three.t new file mode 100644 index 0000000..4c6c464 --- /dev/null +++ b/t/39load_namespaces_three.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +unshift(@INC, './t/lib'); + +plan tests => 9; + +my $warnings; +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTestOther; + use base qw/DBIx::Class::Schema/; + __PACKAGE__->load_namespaces( + resultsource_namespace => '+DBICNSTest::RSrc', + resultset_namespace => '+DBICNSTest::RSet', + result_namespace => '+DBICNSTest::Res' + ); +}; +ok(!$@) or diag $@; +like($warnings, qr/load_namespaces found ResultSet class C with no corresponding ResultSource/); +like($warnings, qr/load_namespaces found Result class C with no corresponding ResultSource/); + +my $source_a = DBICNSTestOther->source('A'); +isa_ok($source_a, 'DBIx::Class::ResultSource::Table'); +my $rset_a = DBICNSTestOther->resultset('A'); +isa_ok($rset_a, 'DBICNSTest::RSet::A'); +my $resclass_a = DBICNSTestOther->resultset('A')->result_class; +is($resclass_a, 'DBICNSTest::Res::A'); + +my $source_b = DBICNSTestOther->source('B'); +isa_ok($source_b, 'DBIx::Class::ResultSource::Table'); +my $rset_b = DBICNSTestOther->resultset('B'); +isa_ok($rset_b, 'DBIx::Class::ResultSet'); +my $resclass_b = DBICNSTestOther->resultset('B')->result_class; +is($resclass_b, 'DBICNSTest::RSrc::B'); diff --git a/t/39load_namespaces_two.t b/t/39load_namespaces_two.t new file mode 100644 index 0000000..a857654 --- /dev/null +++ b/t/39load_namespaces_two.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +unshift(@INC, './t/lib'); + +plan tests => 9; + +my $warnings; +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTest; + use base qw/DBIx::Class::Schema/; + __PACKAGE__->load_namespaces( + resultsource_namespace => 'RSrc', + resultset_namespace => 'RSet', + result_namespace => 'Res' + ); +}; +ok(!$@) or diag $@; +like($warnings, qr/load_namespaces found ResultSet class C with no corresponding ResultSource/); +like($warnings, qr/load_namespaces found Result class C with no corresponding ResultSource/); + +my $source_a = DBICNSTest->source('A'); +isa_ok($source_a, 'DBIx::Class::ResultSource::Table'); +my $rset_a = DBICNSTest->resultset('A'); +isa_ok($rset_a, 'DBICNSTest::RSet::A'); +my $resclass_a = DBICNSTest->resultset('A')->result_class; +is($resclass_a, 'DBICNSTest::Res::A'); + +my $source_b = DBICNSTest->source('B'); +isa_ok($source_b, 'DBIx::Class::ResultSource::Table'); +my $rset_b = DBICNSTest->resultset('B'); +isa_ok($rset_b, 'DBIx::Class::ResultSet'); +my $resclass_b = DBICNSTest->resultset('B')->result_class; +is($resclass_b, 'DBICNSTest::RSrc::B'); diff --git a/t/lib/DBICNSTest/RSBase.pm b/t/lib/DBICNSTest/RSBase.pm new file mode 100644 index 0000000..9786d5f --- /dev/null +++ b/t/lib/DBICNSTest/RSBase.pm @@ -0,0 +1,3 @@ +package DBICNSTest::RSBase; +use base qw/DBIx::Class::ResultSet/; +1; diff --git a/t/lib/DBICNSTest/RSet/A.pm b/t/lib/DBICNSTest/RSet/A.pm new file mode 100644 index 0000000..4cb415f --- /dev/null +++ b/t/lib/DBICNSTest/RSet/A.pm @@ -0,0 +1,3 @@ +package DBICNSTest::RSet::A; +use base qw/DBIx::Class::ResultSet/; +1; diff --git a/t/lib/DBICNSTest/RSet/C.pm b/t/lib/DBICNSTest/RSet/C.pm new file mode 100644 index 0000000..c43a3fe --- /dev/null +++ b/t/lib/DBICNSTest/RSet/C.pm @@ -0,0 +1,3 @@ +package DBICNSTest::RSet::C; +use base qw/DBIx::Class::ResultSet/; +1; diff --git a/t/lib/DBICNSTest/RSrc/A.pm b/t/lib/DBICNSTest/RSrc/A.pm new file mode 100644 index 0000000..532017d --- /dev/null +++ b/t/lib/DBICNSTest/RSrc/A.pm @@ -0,0 +1,6 @@ +package DBICNSTest::RSrc::A; +use base qw/DBIx::Class/; +__PACKAGE__->load_components(qw/PK::Auto Core/); +__PACKAGE__->table('a'); +__PACKAGE__->add_columns('a'); +1; diff --git a/t/lib/DBICNSTest/RSrc/B.pm b/t/lib/DBICNSTest/RSrc/B.pm new file mode 100644 index 0000000..929d8c4 --- /dev/null +++ b/t/lib/DBICNSTest/RSrc/B.pm @@ -0,0 +1,6 @@ +package DBICNSTest::RSrc::B; +use base qw/DBIx::Class/; +__PACKAGE__->load_components(qw/PK::Auto Core/); +__PACKAGE__->table('b'); +__PACKAGE__->add_columns('b'); +1; diff --git a/t/lib/DBICNSTest/Res/A.pm b/t/lib/DBICNSTest/Res/A.pm new file mode 100644 index 0000000..06bec97 --- /dev/null +++ b/t/lib/DBICNSTest/Res/A.pm @@ -0,0 +1,3 @@ +package DBICTest::Res::A; +use base qw/DBIx::Class::Row/; +1; diff --git a/t/lib/DBICNSTest/Res/C.pm b/t/lib/DBICNSTest/Res/C.pm new file mode 100644 index 0000000..ab32e7e --- /dev/null +++ b/t/lib/DBICNSTest/Res/C.pm @@ -0,0 +1,3 @@ +package DBICTest::Res::C; +use base qw/DBIx::Class::Row/; +1; diff --git a/t/lib/DBICNSTest/Result/A.pm b/t/lib/DBICNSTest/Result/A.pm new file mode 100644 index 0000000..71c5209 --- /dev/null +++ b/t/lib/DBICNSTest/Result/A.pm @@ -0,0 +1,3 @@ +package DBICTest::Result::A; +use base qw/DBIx::Class::Row/; +1; diff --git a/t/lib/DBICNSTest/Result/C.pm b/t/lib/DBICNSTest/Result/C.pm new file mode 100644 index 0000000..428c19b --- /dev/null +++ b/t/lib/DBICNSTest/Result/C.pm @@ -0,0 +1,3 @@ +package DBICTest::Result::C; +use base qw/DBIx::Class::Row/; +1; diff --git a/t/lib/DBICNSTest/ResultSet/A.pm b/t/lib/DBICNSTest/ResultSet/A.pm new file mode 100644 index 0000000..c7a86aa --- /dev/null +++ b/t/lib/DBICNSTest/ResultSet/A.pm @@ -0,0 +1,3 @@ +package DBICNSTest::ResultSet::A; +use base qw/DBIx::Class::ResultSet/; +1; diff --git a/t/lib/DBICNSTest/ResultSet/C.pm b/t/lib/DBICNSTest/ResultSet/C.pm new file mode 100644 index 0000000..55ecf1d --- /dev/null +++ b/t/lib/DBICNSTest/ResultSet/C.pm @@ -0,0 +1,3 @@ +package DBICNSTest::ResultSet::C; +use base qw/DBIx::Class::ResultSet/; +1; diff --git a/t/lib/DBICNSTest/ResultSource/A.pm b/t/lib/DBICNSTest/ResultSource/A.pm new file mode 100644 index 0000000..6921ebf --- /dev/null +++ b/t/lib/DBICNSTest/ResultSource/A.pm @@ -0,0 +1,6 @@ +package DBICNSTest::ResultSource::A; +use base qw/DBIx::Class/; +__PACKAGE__->load_components(qw/PK::Auto Core/); +__PACKAGE__->table('a'); +__PACKAGE__->add_columns('a'); +1; diff --git a/t/lib/DBICNSTest/ResultSource/B.pm b/t/lib/DBICNSTest/ResultSource/B.pm new file mode 100644 index 0000000..fb5f309 --- /dev/null +++ b/t/lib/DBICNSTest/ResultSource/B.pm @@ -0,0 +1,6 @@ +package DBICNSTest::ResultSource::B; +use base qw/DBIx::Class/; +__PACKAGE__->load_components(qw/PK::Auto Core/); +__PACKAGE__->table('b'); +__PACKAGE__->add_columns('b'); +1;