[Catalyst-commits] r11265 - in Catalyst-View-PDF-API2/trunk/t: .
lib lib/TestApp lib/TestApp/Controller lib/TestApp/View
lib/TestApp/View/PDF lib/script
ferz at dev.catalyst.perl.org
ferz at dev.catalyst.perl.org
Fri Aug 28 13:23:17 GMT 2009
Author: ferz
Date: 2009-08-28 13:23:16 +0000 (Fri, 28 Aug 2009)
New Revision: 11265
Added:
Catalyst-View-PDF-API2/trunk/t/00-load.t
Catalyst-View-PDF-API2/trunk/t/01-livetest.t
Catalyst-View-PDF-API2/trunk/t/lib/
Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/PDF/
Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/PDF/API2.pm
Catalyst-View-PDF-API2/trunk/t/lib/script/
Catalyst-View-PDF-API2/trunk/t/lib/script/testapp_test.pl
Log:
Fixed pod and something else, but it doesn't work yet.
Added: Catalyst-View-PDF-API2/trunk/t/00-load.t
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/00-load.t (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/00-load.t 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,6 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More tests => 1;
+use ok 'Catalyst::View::PDF::API2';
Added: Catalyst-View-PDF-API2/trunk/t/01-livetest.t
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/01-livetest.t (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/01-livetest.t 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More tests => 9;
+
+# setup library path
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+
+# make sure testapp works
+use ok 'TestApp';
+
+# a live test against TestApp, the test application
+use Test::WWW::Mechanize::Catalyst 'TestApp';
+my $mech = Test::WWW::Mechanize::Catalyst->new;
+$mech->get_ok('http://localhost/', 'get main page');
+$mech->content_like(qr/it works/i, 'see if it has our text');
+
+$mech->get_ok('http://localhost/pdf_test/', 'pdf test');
Added: Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp/Controller/Root.pm 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,83 @@
+package TestApp::Controller::Root;
+use strict;
+use warnings;
+
+__PACKAGE__->config(namespace => q{});
+
+use base 'Catalyst::Controller';
+
+use TestApp::View::PDF::API2;
+
+# your actions replace this one
+sub main :Path { $_[1]->res->body('<h1>It works</h1>') }
+
+sub pdf_test : Global {
+ my ($self, $c) = @_;
+
+
+ $c->stash( {
+ data => "This is a test page",
+ pdf_template=>'test_page.tt2',
+
+ };
+
+ my $view = new TestApp::View::Download::Plain;
+
+ $c->res->body(''.$view->render($c,'',$c->stash));
+}
+
+sub _generate_csv_test_data {
+ my ($self, $c) = @_;
+
+ my $data = {
+ 'array' => [
+ ['a','b','c','d'],
+ ['1','2','3','4'],
+ [' ',"\n","\t",'!'],
+ ['@',',','"',"'"]
+ ],
+ 'content' => '',
+ };
+
+ my $csv = Text::CSV->new ({
+ quote_char => '"',
+ escape_char => '"',
+ sep_char => ',',
+ eol => "\n",
+ binary => 1,
+ allow_loose_quotes => 1,
+ allow_loose_escapes => 1,
+ allow_whitespace => 1,
+ });
+
+ foreach my $row(@{$data->{'array'}}) {
+ $csv->combine(@{$row});
+ $data->{'content'} .= $csv->string();
+ }
+
+ return $data;
+}
+
+sub _generate_plain_test_data {
+ my ($self, $c) = @_;
+
+ my $content =<<"TEST";
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum tempus augue interdum neque. Curabitur ac libero. Aliquam faucibus mi a lectus. Sed et elit. Etiam volutpat suscipit quam. Phasellus sit am
+et odio. Sed faucibus magna quis diam. Nulla facilisi. Vivamus id erat porttitor elit aliquam ornare. Integer tincidunt varius lacus. Pellentesque sit amet mauris id ligula faucibus semper. Maecenas eros. Cur
+abitur hendrerit ligula ac nulla. Mauris dolor eros, pellentesque vel, varius porttitor, convallis non, lectus.
+
+Curabitur lacinia laoreet felis. Vivamus a urna. Aenean adipiscing aliquam velit. Aliquam varius bibendum nulla. Praesent quis tortor nec nisi scelerisque facilisis. Cras tristique. Phasellus mi libero, vulpu
+tate ac, hendrerit ac, iaculis at, elit. Pellentesque ac ante sit amet orci viverra condimentum. Fusce aliquam semper justo. Integer tincidunt. Pellentesque habitant morbi tristique senectus et netus et males
+uada fames ac turpis egestas. Nullam id lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur ut felis non mauris auctor viverra. Fusce dignissim. Morbi qui
+s magna.
+
+Proin scelerisque, lacus blandit consequat sodales, augue ligula laoreet quam, condimentum pretium velit diam eget lorem. Suspendisse potenti. Nam rhoncus mi vitae tortor. Sed eget neque. Fusce sagittis. Null
+a rutrum nibh et justo. Suspendisse dolor libero, rhoncus a, pretium id, feugiat eget, velit. Aenean accumsan. Nunc vel nulla. Mauris semper consectetuer velit. Vivamus semper. Nulla fermentum sapien nec feli
+s. Aenean iaculis felis nec ipsum. Aliquam tristique. Nam ut quam. Suspendisse ornare tristique arcu. Morbi pellentesque dolor eget lorem. Morbi ac nunc euismod lorem porttitor hendrerit. Lorem ipsum dolor si
+t amet, consectetuer adipiscing elit.
+TEST
+
+ return $content;
+}
+
+1;
Added: Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/PDF/API2.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/PDF/API2.pm (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp/View/PDF/API2.pm 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,7 @@
+package TestApp::View::PDF::API2;
+
+use FindBin;
+use lib "$FindBin::Bin/../../../../lib";
+use base 'Catalyst::View::PDF::API2';
+
+1;
Added: Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/lib/TestApp.pm 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,17 @@
+package TestApp;
+use strict;
+use warnings;
+
+use Catalyst;
+
+$DB::single=1;
+
+__PACKAGE__->config('View::PDF' => {
+ INCLUDE_PATH => __PACKAGE__->path_to('root','pdf_templates')
+});
+
+
+
+__PACKAGE__->setup;
+
+1;
Added: Catalyst-View-PDF-API2/trunk/t/lib/script/testapp_test.pl
===================================================================
--- Catalyst-View-PDF-API2/trunk/t/lib/script/testapp_test.pl (rev 0)
+++ Catalyst-View-PDF-API2/trunk/t/lib/script/testapp_test.pl 2009-08-28 13:23:16 UTC (rev 11265)
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/..";
+use Catalyst::Test 'TestApp';
+
+print request($ARGV[0])->content . "\n";
+
+1;
More information about the Catalyst-commits
mailing list