skeleton PSGI response test
[scpubgit/App-SCS.git] / t / 02simple.t
1 use strictures 1;
2 use Test::More;
3 use App::SCS;
4 use IO::All;
5
6 my $app = App::SCS->new(
7   config => { root_dir => 't/data' }
8 );
9
10 my $simple1 = $app->pages->get({ path => 'simple/1' });
11
12 ok($simple1, 'Got a page object');
13
14 is(
15   $simple1->html,
16   io->file('t/data/share/pages/simple/1.html')->all,
17   "Correct file loaded"
18 );
19
20 my @page_plugins = @{$simple1->_page_plugins};
21
22 is(scalar(@page_plugins), 2, 'Two plugins applied');
23
24 my ($tp, $pdp) = @page_plugins;
25
26 ok(
27   $tp->isa('App::SCS::Plugin::Core::PagePlugin::Template'),
28   'Template plugin'
29 );
30
31 is($tp->name, 'layout', 'Template name');
32
33 ok(
34   $pdp->isa('App::SCS::Plugin::Core::PagePlugin::PageData'),
35   'PageData plugin'
36 );
37
38 like(
39   $simple1->_html_zoom->to_html,
40   qr{<div id="content">.*<h1>Hello world}s,
41   'Layout woven correctly'
42 );
43
44 like(
45   $simple1->_content_zoom->to_html,
46   qr{<title[^>]*>Simple 1<}s,
47   'Page data interpolated'
48 );
49
50 my $res = $simple1->_psgi_response;
51
52 is(ref($res),'ARRAY','PSGI response');
53 is($res->[0],200,'200 OK');
54
55 done_testing;