Browse files

Some starter unit tests

  • Loading branch information...
1 parent d992885 commit 3da27bc04196d25b4af33ea4eadb5df862565da0 @rayners rayners committed Apr 18, 2009
Showing with 55 additions and 0 deletions.
  1. +12 −0 plugins/FeaturedAssets/t/00-compile.t
  2. +12 −0 plugins/FeaturedAssets/t/01-schema.t
  3. +31 −0 plugins/FeaturedAssets/t/10-tags.t
View
12 plugins/FeaturedAssets/t/00-compile.t
@@ -0,0 +1,12 @@
+
+use lib qw( t/lib lib extlib );
+
+use strict;
+use warnings;
+
+use MT::Test;
+use Test::More tests => 2;
+
+require MT;
+ok(MT->component ('featuredassets'), "FeaturedAssets loaded");
+require_ok ('FeaturedAssets::Plugin');
View
12 plugins/FeaturedAssets/t/01-schema.t
@@ -0,0 +1,12 @@
+
+use lib qw( t/lib lib extlib );
+
+use strict;
+use warnings;
+
+use MT::Test qw( :db );
+use Test::More tests => 2;
+
+require MT::Asset;
+ok (MT::Asset->has_column ('is_featured'), "mt_asset has is_featured column");
+ok (MT::Asset->is_meta_column ('is_featured'), "mt_asset's is_featured column is meta");
View
31 plugins/FeaturedAssets/t/10-tags.t
@@ -0,0 +1,31 @@
+
+use lib qw( t/lib lib extlib );
+
+use strict;
+use warnings;
+
+use MT::Test qw( :db :data );
+use Test::More qw(no_plan);
+
+require MT::Asset;
+my $asset = MT::Asset->load(1);
+
+ok( !$asset->is_featured, "Asset #1 is not featured" );
+
+tmpl_out_like(
+ '<mt:assetisfeatured>Featured!<mt:else>Not!</mt:assetisfeatured>',
+ {},
+ { asset => $asset },
+ qr/^Not!$/,
+ "mt:assetisfeatured is false for a non-featured asset"
+);
+
+$asset->is_featured(1);
+
+tmpl_out_like(
+ '<mt:assetisfeatured>Featured!<mt:else>Not!</mt:assetisfeatured>',
+ {},
+ { asset => $asset },
+ qr/^Featured!$/,
+ "mt:assetisfeatured is true for a featured asset"
+);

0 comments on commit 3da27bc

Please sign in to comment.