Catalyst-Plugin-I18N-PathPrefixGeoIP
view release on metacpan or search on metacpan
t/12-switch_language.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Most;
use Test::Deep;
use FindBin;
use Path::Class;
use lib dir($FindBin::Bin)->subdir('lib')->stringify;
use HTTP::Request::Common;
use Catalyst::Test 'TestApp';
use Data::Dumper;
# Each element is a hashref, with the following key-value pairs:
# request_path: The URI of the request.
# new_language: The parameter to $c->switch_language().
# expected: A hashref that contains the expected values after $c->switch_language().
# It contains following key-value pairs:
# language: The expected single value of $c->languages.
# req: The expected value of some $c->req methods. A hashref with the
# following key-value pairs:
# uri: The expected value of $c->req->uri.
# base: The expected value of $c->req->base.
# path: The expected value of $c->req->path.
my @tests = (
{
request_path => '/en/foo/bar',
new_language => 'de',
expected => {
language => 'de',
req => {
uri => 'http://localhost/de/foo/bar',
base => 'http://localhost/de/',
path => 'foo/bar',
},
},
},
{
request_path => '/en/foo/bar',
new_language => 'DE',
expected => {
language => 'de',
req => {
uri => 'http://localhost/de/foo/bar',
base => 'http://localhost/de/',
path => 'foo/bar',
},
},
},
{
request_path => '/language_independent_stuff',
new_language => 'de',
expected => {
language => 'de',
req => {
uri => 'http://localhost/language_independent_stuff',
base => 'http://localhost/',
path => 'language_independent_stuff',
},
},
},
);
{
foreach my $test (@tests) {
my $test_description =
Data::Dumper->new([
+{
map {
( run in 0.769 second using v1.01-cache-2.11-cpan-39bf76dae61 )