[Jifty-commit] r3053 - in jifty/trunk/t/TestApp: lib/TestApp t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Mar 23 22:30:15 EDT 2007
Author: clkao
Date: Fri Mar 23 22:30:15 2007
New Revision: 3053
Added:
jifty/trunk/t/TestApp/lib/TestApp/View/
jifty/trunk/t/TestApp/lib/TestApp/View/base.pm
jifty/trunk/t/TestApp/lib/TestApp/View/instance.pm
jifty/trunk/t/TestApp/t/15-template-subclass.t
Modified:
jifty/trunk/t/TestApp/lib/TestApp/View.pm
Log:
tests for view subclasses.
Modified: jifty/trunk/t/TestApp/lib/TestApp/View.pm
==============================================================================
--- jifty/trunk/t/TestApp/lib/TestApp/View.pm (original)
+++ jifty/trunk/t/TestApp/lib/TestApp/View.pm Fri Mar 23 22:30:15 2007
@@ -35,4 +35,17 @@
outs('/path_test/td_only - T::D');
};
+
+# for testing subclasses
+template 'entry.html' => sub {
+ my $self = shift;
+ outs("/entry.html=$self")
+};
+
+require TestApp::View::base;
+require TestApp::View::instance;
+import_templates TestApp::View::base under '/base';
+import_templates TestApp::View::instance under '/instance';
+
+
1;
Added: jifty/trunk/t/TestApp/lib/TestApp/View/base.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/lib/TestApp/View/base.pm Fri Mar 23 22:30:15 2007
@@ -0,0 +1,33 @@
+package TestApp::View::base;
+use Jifty::View::Declare -base;
+
+template 'list_ht' => sub {
+ my $self = shift;
+ outs("/base/list=$self");
+ for (0..1) {
+ $self->has_template('view')->();
+ }
+};
+
+template 'list_s' => sub {
+ my $self = shift;
+ outs("/base/list=$self");
+ for (0..1) {
+ show('view');
+ }
+};
+
+template 'list_rg' => sub {
+ my $self = shift;
+ outs("/base/list=$self");
+ for (0..1) {
+ render_region('view-'.$_, path => 'view');
+ }
+};
+
+template 'view' => sub {
+ my $self = shift;
+ outs("/base/view=$self");
+};
+
+1;
Added: jifty/trunk/t/TestApp/lib/TestApp/View/instance.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/lib/TestApp/View/instance.pm Fri Mar 23 22:30:15 2007
@@ -0,0 +1,14 @@
+package TestApp::View::instance;
+use Jifty::View::Declare -base;
+use base 'TestApp::View::base';
+
+template 'myview' => sub {
+
+};
+
+template 'view' => sub {
+ my $self = shift;
+ outs("/instance/view=$self");
+};
+
+1;
Added: jifty/trunk/t/TestApp/t/15-template-subclass.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/15-template-subclass.t Fri Mar 23 22:30:15 2007
@@ -0,0 +1,54 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use Jifty::Test;
+use Jifty::Test::WWW::Mechanize;
+
+my @tests = (
+ {
+ url => "/entry.html",
+ text => '/entry.html=TestApp::View',
+ },
+ {
+ url => "/base/list_s",
+ text => '/base/list=TestApp::View::base'.
+ '/base/view=TestApp::View::base'.
+ '/base/view=TestApp::View::base'
+ },
+ {
+ url => "/base/list_ht",
+ text => '/base/list=TestApp::View::base'.
+ '/base/view=TestApp::View::base'.
+ '/base/view=TestApp::View::base'
+ },
+ {
+ url => "/base/list_rg",
+ text => '/base/list=TestApp::View::base'.
+ in_region('view-0', '/base/view=TestApp::View::base').
+ in_region('view-1', '/base/view=TestApp::View::base')
+ },
+
+
+);
+
+sub in_region {
+ qq|<script type="text/javascript">
+new Region('$_[0]',{},'/base/view',null);
+</script><div id="region-$_[0]">$_[1]</div>|;
+}
+
+plan tests => 2 + scalar(@tests) * 2;
+
+my $server = Jifty::Test->make_server;
+isa_ok( $server, 'Jifty::Server' );
+my $URL = $server->started_ok;
+
+my $mech = Jifty::Test::WWW::Mechanize->new;
+foreach my $test (@tests) {
+ $mech->get_ok( $URL . $test->{url}, "get '$URL: /jifty/jifty/trunk/t/TestApp/t/15-template-subclass.t $test->{url}'" );
+ $mech->content_contains( $test->{text}, "found content '$test->{text}'" );
+}
More information about the Jifty-commit
mailing list