root/branches/release-41/t/48-cache.t @ 2681

Revision 2681, 1.2 kB (checked in by bchoate, 17 months ago)

Fixes for cache tests.

  • Property svn:keywords set to Id Revision
Line 
1use strict;
2
3use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib';
4use Test::More tests => 8;
5
6use MT::Test qw(:db :data);
7use MT;
8
9require MT::Category;
10my $cat_cache = MT::Category->cache(blog_id => 1);
11ok($cat_cache, "category cache exists for blog id 1");
12
13# make sure order is consistent
14@$cat_cache = sort { $a->[1] cmp $b->[1] } @$cat_cache;
15
16# check one of the elements
17is($cat_cache->[0][0], '2', "category id is 2");
18is($cat_cache->[0][1], 'bar', "category name is 'bar'");
19is($cat_cache->[0][2], '0', "no parent for 'bar' category");
20
21require MT::Tag;
22my $tag_cache = MT::Tag->cache(blog_id => 1, class => 'MT::Entry');
23ok($tag_cache, "tag cache exists for blog id 1");
24
25is(@$tag_cache, 5, "number of tags in cache is 5"); # relies on test data
26
27my $entry = MT::Entry->load(1);
28$entry->tags($entry->get_tags(), 'newtag');
29$entry->save;
30
31$tag_cache = MT::Tag->cache(blog_id => 1, class => 'MT::Entry');
32ok(grep('newtag', @$tag_cache), "newtag is in cache");
33
34my $cat = new MT::Category;
35$cat->label("New category");
36$cat->blog_id(1);
37$cat->save;
38
39my $new_cat_cache_count = (scalar @$cat_cache) + 1;
40$cat_cache = MT::Category->cache(blog_id => 1);
41is((scalar @$cat_cache), $new_cat_cache_count, "category cache count incremented");
42
431;
Note: See TracBrowser for help on using the browser.