root/branches/boomer/t/48-cache.t @ 1098

Revision 1098, 1.2 kB (checked in by hachi, 2 years ago)

Branching for boomer from release-19, rev 62318

  • Property svn:keywords set to Id Revision
Line 
1use strict;
2
3use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib';
4use Test::More tests => 9;
5
6use vars qw($T_CFG);
7use MT::Test qw(:db :data);
8
9
10$T_CFG = -r 't/mysql.cfg' ? 't/mysql.cfg' : $ENV{HOME} .'/mysql-test.cfg';
11$T_CFG = -r 't/mt.cfg' ? 't/mt.cfg' : $ENV{HOME} .'/mt-test.cfg';
12
13use MT;
14
15require MT::Category;
16my $cat_cache = MT::Category->cache(blog_id => 1);
17ok($cat_cache);
18
19# make sure order is consistent
20@$cat_cache = sort { $a->[1] cmp $b->[1] } @$cat_cache;
21
22# check one of the elements
23is($cat_cache->[0][0], '2');
24is($cat_cache->[0][1], 'bar');
25is($cat_cache->[0][2], '0');
26
27require MT::Tag;
28my $tag_cache = MT::Tag->cache(blog_id => 1, class => 'MT::Entry');
29ok($tag_cache);
30
31is($tag_cache->{grandpa}, 1);
32is($tag_cache->{verse}, MT::Object->driver->can('count_group_by') ? 5 : 1);
33
34my $entry = MT::Entry->load(1);
35$entry->tags($entry->get_tags(), 'newtag');
36$entry->save;
37
38$tag_cache = MT::Tag->cache(blog_id => 1, class => 'MT::Entry');
39is($tag_cache->{newtag}, 1);
40
41my $cat = new MT::Category;
42$cat->label("New category");
43$cat->blog_id(1);
44$cat->save;
45
46my $new_cat_cache_count = (scalar @$cat_cache) + 1;
47$cat_cache = MT::Category->cache(blog_id => 1);
48is((scalar @$cat_cache), $new_cat_cache_count);
49
501;
Note: See TracBrowser for help on using the browser.