Two more sets of might_have - has_many relationships for extra tests
Peter Rabbitson [Mon, 17 Nov 2008 01:59:53 +0000 (01:59 +0000)]
t/99dbic_sqlt_parser.t
t/lib/DBICTest/Schema.pm
t/lib/DBICTest/Schema/Artwork.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/CD.pm
t/lib/DBICTest/Schema/Image.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/LyricVersion.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Lyrics.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Track.pm
t/lib/sqlite.sql

index 42eeb92..bbac5e3 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
     eval "use DBD::mysql; use SQL::Translator 0.09;";
     plan $@
         ? ( skip_all => 'needs SQL::Translator 0.09 for testing' )
-        : ( tests => 102 );
+        : ( tests => 114 );
 }
 
 my $schema = DBICTest->init_schema();
index 08f396f..d217e47 100644 (file)
@@ -20,6 +20,10 @@ __PACKAGE__->load_classes(qw/
   /,
   { 'DBICTest::Schema' => [qw/
     LinerNotes
+    Artwork
+    Image
+    Lyrics
+    LyricVersion
     OneKey
     #dummy
     TwoKeys
diff --git a/t/lib/DBICTest/Schema/Artwork.pm b/t/lib/DBICTest/Schema/Artwork.pm
new file mode 100644 (file)
index 0000000..f6e00d2
--- /dev/null
@@ -0,0 +1,16 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Artwork;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('cd_artwork');
+__PACKAGE__->add_columns(
+  'cd_id' => {
+    data_type => 'integer',
+  },
+);
+__PACKAGE__->set_primary_key('cd_id');
+__PACKAGE__->belongs_to('cd', 'DBICTest::Schema::CD', 'cd_id');
+__PACKAGE__->has_many('images', 'DBICTest::Schema::Image', 'artwork_id');
+
+1;
index 68337bb..6175be4 100644 (file)
@@ -53,6 +53,8 @@ __PACKAGE__->might_have(
     liner_notes => 'DBICTest::Schema::LinerNotes', undef,
     { proxy => [ qw/notes/ ] },
 );
+__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
+
 __PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
 __PACKAGE__->many_to_many(
     producers_sorted => cd_to_producer => 'producer',
diff --git a/t/lib/DBICTest/Schema/Image.pm b/t/lib/DBICTest/Schema/Image.pm
new file mode 100644 (file)
index 0000000..8df5add
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Image;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('images');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'artwork_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+  'name' => {
+    data_type => 'varchar',
+    size => 100,
+  },
+  'data' => {
+    data_type => 'blob',
+    is_nullable => 1,
+  },
+);
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/LyricVersion.pm b/t/lib/DBICTest/Schema/LyricVersion.pm
new file mode 100644 (file)
index 0000000..d2f9769
--- /dev/null
@@ -0,0 +1,24 @@
+package # hide from PAUSE
+    DBICTest::Schema::LyricVersion;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('lyric_versions');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'lyric_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+  'text' => {
+    data_type => 'varchar',
+    size => 100,
+  },
+);
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->belongs_to('lyric', 'DBICTest::Schema::Lyrics', 'lyric_id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/Lyrics.pm b/t/lib/DBICTest/Schema/Lyrics.pm
new file mode 100644 (file)
index 0000000..3e4024e
--- /dev/null
@@ -0,0 +1,21 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Lyrics;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('lyrics');
+__PACKAGE__->add_columns(
+  'lyric_id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'track_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+);
+__PACKAGE__->set_primary_key('lyric_id');
+__PACKAGE__->belongs_to('track', 'DBICTest::Schema::Track', 'track_id');
+__PACKAGE__->has_many('lyric_versions', 'DBICTest::Schema::LyricVersion', 'lyric_id');
+
+1;
index 353cbea..ffbd2fd 100644 (file)
@@ -36,5 +36,6 @@ __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd');
 
 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
+__PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
 
 1;
index b3f0f0f..fcdae19 100644 (file)
@@ -1,6 +1,6 @@
 -- 
 -- Created by SQL::Translator::Producer::SQLite
--- Created on Sun Nov 16 10:43:11 2008
+-- Created on Mon Nov 17 02:53:11 2008
 -- 
 BEGIN TRANSACTION;
 
@@ -29,6 +29,15 @@ CREATE INDEX artist_undirected_map_idx_id1_ ON artist_undirected_map (id1);
 CREATE INDEX artist_undirected_map_idx_id2_ ON artist_undirected_map (id2);
 
 --
+-- Table: cd_artwork
+--
+CREATE TABLE cd_artwork (
+  cd_id INTEGER PRIMARY KEY NOT NULL
+);
+
+CREATE INDEX cd_artwork_idx_cd_id_cd_artwor ON cd_artwork (cd_id);
+
+--
 -- Table: bookmark
 --
 CREATE TABLE bookmark (
@@ -185,6 +194,18 @@ CREATE TABLE genre (
 CREATE UNIQUE INDEX genre_name_genre ON genre (name);
 
 --
+-- Table: images
+--
+CREATE TABLE images (
+  id INTEGER PRIMARY KEY NOT NULL,
+  artwork_id integer NOT NULL,
+  name varchar(100) NOT NULL,
+  data blob
+);
+
+CREATE INDEX images_idx_artwork_id_images ON images (artwork_id);
+
+--
 -- Table: liner_notes
 --
 CREATE TABLE liner_notes (
@@ -205,6 +226,27 @@ CREATE TABLE link (
 
 
 --
+-- Table: lyric_versions
+--
+CREATE TABLE lyric_versions (
+  id INTEGER PRIMARY KEY NOT NULL,
+  lyric_id integer NOT NULL,
+  text varchar(100) NOT NULL
+);
+
+CREATE INDEX lyric_versions_idx_lyric_id_ly ON lyric_versions (lyric_id);
+
+--
+-- Table: lyrics
+--
+CREATE TABLE lyrics (
+  lyric_id INTEGER PRIMARY KEY NOT NULL,
+  track_id integer NOT NULL
+);
+
+CREATE INDEX lyrics_idx_track_id_lyrics ON lyrics (track_id);
+
+--
 -- Table: noprimarykey
 --
 CREATE TABLE noprimarykey (