root/branches/release-32/t/65-ssi.t @ 1541

Revision 1541, 2.9 kB (checked in by mpaschal, 21 months ago)

Split includes across directories using 3 letters as originally specified
Don't use the file extension when making dirnames for cache keys with fewer than 3 letters
Check in the automated tests I was using
BugzID: 69038

Line 
1#!/usr/bin/perl -w
2
3use strict;
4use warnings;
5
6use lib 'extlib';
7use lib 'lib';
8use lib 't/lib';
9
10use Test::More qw(no_plan);
11
12use MT;
13
14use vars qw( $DB_DIR $T_CFG );
15use MT::Test qw(:db :data);
16
17my $mt = MT->instance( Config => $T_CFG ) or die MT->errstr;
18isa_ok($mt, 'MT');
19
20
21my $blog = MT->model('blog')->load(1);
22
23my $include = MT->model('template')->new;
24$include->blog_id($blog->id);
25$include->name('Included Template');
26$include->type('custom');
27$include->text('template was included at <mt:date format="%X %x"> <mt:getvar name="woot">');
28$include->save;
29
30my $tmpl = MT->model('template')->new;
31$tmpl->blog_id($blog->id);
32$tmpl->text(q(hi <mt:include module="Included Template"> bye));
33
34require MT::Template::Context;
35my $ctx = MT::Template::Context->new;
36my $out = $tmpl->build($ctx, {});
37
38ok(defined $out, 'test template built');
39diag($tmpl->errstr) if !defined $out;
40like($out, qr{ template \s was \s included }xms, 'test template included included template');
41
42
43$tmpl = MT->model('template')->new;
44$tmpl->blog_id($blog->id);
45$tmpl->text(q(hi <mt:include module="Included Template" key="woot" ttl="1000"> bye));
46
47$ctx = MT::Template::Context->new;
48$ctx->{__stash}{vars}{woot} = 'awesome';
49$out = $tmpl->build($ctx, {});
50
51ok(defined $out, 'test template built');
52diag($tmpl->errstr) if !defined $out;
53like($out, qr{ template \s was \s included }xms, 'test template included cached included template');
54like($out, qr{ awesome }xms, 'test template included variable value');
55
56
57my $first_text = $out;
58
59$tmpl = MT->model('template')->new;
60$tmpl->blog_id($blog->id);
61$tmpl->text(q(hi <mt:include module="Included Template" key="woot" ttl="1000"> bye));
62
63$ctx = MT::Template::Context->new;
64$ctx->{__stash}{vars}{woot} = 'terrible';
65$out = $tmpl->build($ctx, {});
66
67ok(defined $out, 'test template built');
68like($out, qr{ template \s was \s included }xms, 'test template included cached included template again');
69like($out, qr{ awesome }xms, 'test template included old cached variable value');
70
71
72$blog->include_system('shtml');
73$blog->save;
74
75$tmpl = MT->model('template')->new;
76$tmpl->blog_id($blog->id);
77$tmpl->text(q(hi <mt:include module="Included Template" key="woot" ttl="1000" ssi="1"> bye));
78
79$ctx = MT::Template::Context->new;
80$ctx->{__stash}{vars}{woot} = 'terrible';
81$out = $tmpl->build($ctx, {});
82
83ok(defined $out, 'test template built');
84my $sitepath = $blog->site_path;
85like($out, qr(\Ahi <!--#include file="${sitepath}includes_c/woo/woot.html" --> bye\z)ms,
86    'test template included template by ssi');
87
88
89$tmpl = MT->model('template')->new;
90$tmpl->blog_id($blog->id);
91$tmpl->text(q(hi <mt:include module="Included Template" key="w" ttl="1000" ssi="1"> bye));
92
93$ctx = MT::Template::Context->new;
94$ctx->{__stash}{vars}{woot} = 'terrible';
95$out = $tmpl->build($ctx, {});
96
97ok(defined $out, 'test template built');
98$sitepath = $blog->site_path;
99like($out, qr(\Ahi <!--#include file="${sitepath}includes_c/w/w.html" --> bye\z)ms,
100    'test template included template by ssi');
101
Note: See TracBrowser for help on using the browser.