summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-04-25 22:08:50 +0200
committerfranck cuny <franck@lumberjaph.net>2010-04-25 22:08:50 +0200
commitb03e09d01466a7e720c0c16c4319a3853b29005c (patch)
tree2c8193d9c379d9394fd2c4b911ddf788c9cd5c70
parentlanguages method to set various languages; l method to localize some text; POD (diff)
downloaddancer-plugin-i18n-b03e09d01466a7e720c0c16c4319a3853b29005c.tar.gz
a simple application to test
Diffstat (limited to '')
-rw-r--r--t/01_basic.t40
-rw-r--r--t/lib/TestApp.pm16
-rw-r--r--t/lib/logs/development.log0
-rw-r--r--t/lib/views/index.tt3
4 files changed, 59 insertions, 0 deletions
diff --git a/t/01_basic.t b/t/01_basic.t
new file mode 100644
index 0000000..72bfcc6
--- /dev/null
+++ b/t/01_basic.t
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+
+#use lib ('t/lib');
+use Test::More tests => 2;
+
+use HTTP::Request;
+use LWP::UserAgent;
+use Plack::Loader;
+use Dancer::Config 'setting';
+#use TestApp;
+
+use Test::TCP;
+
+my $app = sub {
+    my $env = shift;
+    my $request = Dancer::Request->new($env);
+    Dancer->dance($request);
+};
+
+Test::TCP::test_tcp(
+    client => sub {
+        my $port = shift;
+        my $req  = HTTP::Request->new(GET => "http://127.0.0.1:$port/");
+	$req->header( 'Accept-Language' => 'fr' );
+        my $ua   = LWP::UserAgent->new;
+        my $res = $ua->request($req);
+	like $res->content, qr/first we got bonjour/, 'french content';
+	like $res->content, qr/then we have hallo/, 'german content';
+    },
+    server => sub {
+        use t::lib::TestApp;
+        my $port = shift;
+        setting apphandler => 'PSGI';
+	setting template => 'template_toolkit';
+        Dancer::Config->load;
+        Plack::Loader->auto( port => $port )->run($app);
+    }
+);
+
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm
new file mode 100644
index 0000000..966ec30
--- /dev/null
+++ b/t/lib/TestApp.pm
@@ -0,0 +1,16 @@
+package TestApp;
+
+use Dancer;
+use Dancer::Plugin::I18n;
+
+get '/' => sub { template 'index'; };
+
+package TestApp::I18N::de;
+use base 'TestApp::I18N';
+our %Lexicon = ( hello => 'hallo' );
+
+package TestApp::I18N::fr;
+use base 'TestApp::I18N';
+our %Lexicon = ( hello => 'bonjour' );
+
+1;
diff --git a/t/lib/logs/development.log b/t/lib/logs/development.log
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/t/lib/logs/development.log
diff --git a/t/lib/views/index.tt b/t/lib/views/index.tt
new file mode 100644
index 0000000..8260dab
--- /dev/null
+++ b/t/lib/views/index.tt
@@ -0,0 +1,3 @@
+first we got <% l('hello') %>
+<% languages('de') %>
+then we have <% l('hello') %>