| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use lib 't/lib', 'extlib', 'lib'; |
|---|
| 5 | use Test::More tests => 11; |
|---|
| 6 | |
|---|
| 7 | use MT::Test; |
|---|
| 8 | my $mt = new MT; |
|---|
| 9 | |
|---|
| 10 | package MT::TestAsset; |
|---|
| 11 | |
|---|
| 12 | our @ISA = qw( MT::Object ); |
|---|
| 13 | |
|---|
| 14 | __PACKAGE__->install_properties({ |
|---|
| 15 | column_defs => { |
|---|
| 16 | id => 'integer not null auto_increment', |
|---|
| 17 | title => 'string(255)', |
|---|
| 18 | }, |
|---|
| 19 | primary_key => 'id', |
|---|
| 20 | class_type => 'file', |
|---|
| 21 | }); |
|---|
| 22 | |
|---|
| 23 | package MT::TestAsset::Image; |
|---|
| 24 | |
|---|
| 25 | our @ISA = qw( MT::TestAsset ); |
|---|
| 26 | |
|---|
| 27 | __PACKAGE__->install_properties({ |
|---|
| 28 | class_type => 'image', |
|---|
| 29 | }); |
|---|
| 30 | |
|---|
| 31 | package MT::TestAsset::Audio; |
|---|
| 32 | |
|---|
| 33 | our @ISA = qw( MT::TestAsset ); |
|---|
| 34 | |
|---|
| 35 | __PACKAGE__->install_properties({ |
|---|
| 36 | column_defs => { |
|---|
| 37 | duration => 'integer', |
|---|
| 38 | }, |
|---|
| 39 | class_type => 'audio', |
|---|
| 40 | }); |
|---|
| 41 | |
|---|
| 42 | package main; |
|---|
| 43 | |
|---|
| 44 | my $file = new MT::TestAsset; |
|---|
| 45 | my $image = new MT::TestAsset::Image; |
|---|
| 46 | my $audio = new MT::TestAsset::Audio; |
|---|
| 47 | |
|---|
| 48 | ok($file->has_column('title'), 'file has title column'); |
|---|
| 49 | ok($image->has_column('title'), 'image has title column'); |
|---|
| 50 | ok($audio->has_column('title'), 'audio has title column'); |
|---|
| 51 | ok(!$file->has_column('duration'), 'file doesn\'t have column duration'); |
|---|
| 52 | ok(!$image->has_column('duration'), 'image doesn\'t have column duration'); |
|---|
| 53 | ok($audio->has_column('duration'), 'audio has column duration'); |
|---|
| 54 | ok($file->class_type eq 'file', 'file class_type is file'); |
|---|
| 55 | ok($image->class_type eq 'image', 'image class_type is image'); |
|---|
| 56 | ok($audio->class_type eq 'audio', 'audio class_type is audio'); |
|---|
| 57 | ok(MT::TestAsset->class_type eq 'file', 'generic asset class_type is file'); |
|---|
| 58 | ok(MT::TestAsset::Image->class_type eq 'image', 'generic image asset class type is image'); |
|---|