forked from typester/ark-perl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
view_mt.t
67 lines (51 loc) · 1.25 KB
/
view_mt.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use Test::Base;
use FindBin;
{
package TestApp;
use Ark;
package TestApp::Controller::Root;
use Ark 'Controller';
has '+namespace' => default => '';
sub forward :Local {
my ($self, $c) = @_;
$c->forward( $c->view('MT') );
}
sub render :Local {
my ($self, $c) = @_;
my $body = $c->view('MT')->render('render');
$c->res->body($body);
}
sub template :Local {
my ($self, $c) = @_;
$c->view('MT')->template('forward');
$c->forward('forward');
}
sub include :Local {
my ($self, $c) = @_;
$c->forward( $c->view('MT') );
}
package TestApp::View::MT;
use Ark 'View::MT';
has '+include_path' => (
default => sub { ["$FindBin::Bin/view_mt"] },
);
}
plan 'no_plan';
use Ark::Test 'TestApp',
components => [qw/Controller::Root View::MT/];
{
my $content = get('/forward');
is($content, 'index mt', 'forward view ok');
}
{
my $content = get('/render');
is($content, 'render mt', 'render view ok');
}
{
my $content = get('/template');
is($content, 'index mt', 'set template view ok');
}
{
my $content = get('/include');
is($content, 'before included[foo,bar] after', 'include ok');
}