fix subclassing gotcha introduced with source_name
David Kamholz [Mon, 3 Jul 2006 02:13:46 +0000 (02:13 +0000)]
give ResultSetManager test modules more sensible names

lib/DBIx/Class/ResultSourceProxy/Table.pm
t/40resultsetmanager.t
t/60core.t
t/lib/DBICTest/ResultSetManager.pm [moved from t/lib/DBICTest/Extra.pm with 75% similarity]
t/lib/DBICTest/ResultSetManager/Foo.pm [moved from t/lib/DBICTest/Extra/Foo.pm with 82% similarity]
t/lib/DBICTest/Schema.pm
t/lib/DBICTest/Schema/ArtistSubclass.pm [new file with mode: 0644]

index b2921e6..f70f2bc 100644 (file)
@@ -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);
index 0b7471a..bdec159 100644 (file)
@@ -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' );
index a4d97d0..b981365 100644 (file)
@@ -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);
similarity index 75%
rename from t/lib/DBICTest/Extra.pm
rename to t/lib/DBICTest/ResultSetManager.pm
index 17418ea..08b3159 100644 (file)
@@ -1,5 +1,5 @@
 package # hide from PAUSE 
-    DBICTest::Extra;
+    DBICTest::ResultSetManager;
 use base 'DBIx::Class::Schema';
 
 __PACKAGE__->load_classes("Foo");
similarity index 82%
rename from t/lib/DBICTest/Extra/Foo.pm
rename to t/lib/DBICTest/ResultSetManager/Foo.pm
index 2572ac3..7253ac1 100644 (file)
@@ -1,5 +1,5 @@
 package # hide from PAUSE 
-    DBICTest::Extra::Foo;
+    DBICTest::ResultSetManager::Foo;
 use base 'DBIx::Class';
 
 __PACKAGE__->load_components(qw/ ResultSetManager Core /);
index 9de55a1..7c265dc 100644 (file)
@@ -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 (file)
index 0000000..8dd3f6f
--- /dev/null
@@ -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