From: David Kamholz Date: Mon, 3 Jul 2006 02:13:46 +0000 (+0000) Subject: fix subclassing gotcha introduced with source_name X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1fb2c941d66c82f2704e51f53bca84b9edfc2aa;p=dbsrgits%2FDBIx-Class-Historic.git fix subclassing gotcha introduced with source_name give ResultSetManager test modules more sensible names --- diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index b2921e6..f70f2bc 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -50,6 +50,7 @@ sub table { %{$class->result_source_instance} : (), name => $table, result_class => $class, + source_name => undef, }); } $class->mk_classdata('result_source_instance' => $table); diff --git a/t/40resultsetmanager.t b/t/40resultsetmanager.t index 0b7471a..bdec159 100644 --- a/t/40resultsetmanager.t +++ b/t/40resultsetmanager.t @@ -15,12 +15,12 @@ BEGIN { } } -use DBICTest::Extra; # uses Class::Inspector +use DBICTest::ResultSetManager; # uses Class::Inspector -my $schema = DBICTest::Extra->compose_connection('DB', 'foo'); +my $schema = DBICTest::ResultSetManager->compose_connection('DB', 'foo'); my $rs = $schema->resultset('Foo'); ok( !DB::Foo->can('bar'), 'Foo class does not have bar method' ); ok( $rs->can('bar'), 'Foo resultset class has bar method' ); -isa_ok( $rs, 'DBICTest::Extra::Foo::_resultset', 'Foo resultset class is correct' ); +isa_ok( $rs, 'DBICTest::ResultSetManager::Foo::_resultset', 'Foo resultset class is correct' ); is( $rs->bar, 'good', 'bar method works' ); diff --git a/t/60core.t b/t/60core.t index a4d97d0..b981365 100644 --- a/t/60core.t +++ b/t/60core.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 61; +plan tests => 62; # figure out if we've got a version of sqlite that is older than 3.2.6, in # which case COUNT(DISTINCT()) doesn't work @@ -253,6 +253,9 @@ ok($schema->storage(), 'Storage available'); my @artsn = $schema->resultset('SourceNameArtists')->search({}, { order_by => 'name DESC' }); cmp_ok(@artsn, '==', 4, "Four artists returned"); + + # make sure subclasses that don't set source_name are ok + ok($schema->source('ArtistSubclass', 'ArtistSubclass exists')); } my $newbook = $schema->resultset( 'Bookmark' )->find(1); diff --git a/t/lib/DBICTest/Extra.pm b/t/lib/DBICTest/ResultSetManager.pm similarity index 75% rename from t/lib/DBICTest/Extra.pm rename to t/lib/DBICTest/ResultSetManager.pm index 17418ea..08b3159 100644 --- a/t/lib/DBICTest/Extra.pm +++ b/t/lib/DBICTest/ResultSetManager.pm @@ -1,5 +1,5 @@ package # hide from PAUSE - DBICTest::Extra; + DBICTest::ResultSetManager; use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes("Foo"); diff --git a/t/lib/DBICTest/Extra/Foo.pm b/t/lib/DBICTest/ResultSetManager/Foo.pm similarity index 82% rename from t/lib/DBICTest/Extra/Foo.pm rename to t/lib/DBICTest/ResultSetManager/Foo.pm index 2572ac3..7253ac1 100644 --- a/t/lib/DBICTest/Extra/Foo.pm +++ b/t/lib/DBICTest/ResultSetManager/Foo.pm @@ -1,5 +1,5 @@ package # hide from PAUSE - DBICTest::Extra::Foo; + DBICTest::ResultSetManager::Foo; use base 'DBIx::Class'; __PACKAGE__->load_components(qw/ ResultSetManager Core /); diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index 9de55a1..7c265dc 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -29,6 +29,7 @@ __PACKAGE__->load_classes(qw/ 'SelfRef', 'ArtistUndirectedMap', 'ArtistSourceName', + 'ArtistSubclass', 'Producer', 'CD_to_Producer', ), diff --git a/t/lib/DBICTest/Schema/ArtistSubclass.pm b/t/lib/DBICTest/Schema/ArtistSubclass.pm new file mode 100644 index 0000000..8dd3f6f --- /dev/null +++ b/t/lib/DBICTest/Schema/ArtistSubclass.pm @@ -0,0 +1,8 @@ +package # hide from PAUSE + DBICTest::Schema::ArtistSubclass; + +use base 'DBICTest::Schema::Artist'; + +__PACKAGE__->table(__PACKAGE__->table); + +1; \ No newline at end of file