diff --git a/examples/login/t/login.t b/examples/login/t/login.t
index 52134adc30..68aa33dcff 100644
--- a/examples/login/t/login.t
+++ b/examples/login/t/login.t
@@ -7,16 +7,23 @@ my $t = Test::Mojo->new('LoginApp');
$t->ua->max_redirects(1);
subtest 'Test login workflow' => sub {
- $t->get_ok('/')->status_is(200)->element_exists('form input[name="user"]')->element_exists('form input[name="pass"]')
+ $t->get_ok('/')
+ ->status_is(200)
+ ->element_exists('form input[name="user"]')
+ ->element_exists('form input[name="pass"]')
->element_exists('form input[type="submit"]');
- $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'})->status_is(200)
+ $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'})
+ ->status_is(200)
->text_like('html body' => qr/Welcome sebastian/);
$t->get_ok('/protected')->status_is(200)->text_like('a' => qr/Logout/);
- $t->get_ok('/logout')->status_is(200)->element_exists('form input[name="user"]')
- ->element_exists('form input[name="pass"]')->element_exists('form input[type="submit"]');
+ $t->get_ok('/logout')
+ ->status_is(200)
+ ->element_exists('form input[name="user"]')
+ ->element_exists('form input[name="pass"]')
+ ->element_exists('form input[type="submit"]');
};
done_testing();
diff --git a/lib/Mojolicious/Command/version.pm b/lib/Mojolicious/Command/version.pm
index 2ce70456b9..286ca87ab6 100644
--- a/lib/Mojolicious/Command/version.pm
+++ b/lib/Mojolicious/Command/version.pm
@@ -41,8 +41,10 @@ EOF
# Check latest version on CPAN
my $latest = eval {
- $self->app->ua->max_redirects(10)->tap(sub { $_->proxy->detect })
- ->get('fastapi.metacpan.org/v1/release/Mojolicious')->result->json->{version};
+ $self->app->ua->max_redirects(10)
+ ->tap(sub { $_->proxy->detect })
+ ->get('fastapi.metacpan.org/v1/release/Mojolicious')
+ ->result->json->{version};
} or return;
my $msg = 'This version is up to date, have fun!';
diff --git a/t/mojo/promise.t b/t/mojo/promise.t
index bbc44c0ee6..345c7ccdce 100644
--- a/t/mojo/promise.t
+++ b/t/mojo/promise.t
@@ -116,7 +116,9 @@ subtest 'Resolved chained' => sub {
subtest 'Rejected chained' => sub {
my $promise = Mojo::Promise->new;
my @errors;
- $promise->then(undef, sub {"$_[0]:1"})->then(sub {"$_[0]:2"}, sub {"$_[0]:fail"})->then(sub {"$_[0]:3"})
+ $promise->then(undef, sub {"$_[0]:1"})
+ ->then(sub {"$_[0]:2"}, sub {"$_[0]:fail"})
+ ->then(sub {"$_[0]:3"})
->then(sub { push @errors, "$_[0]:4" });
$promise->reject('tset');
Mojo::IOLoop->one_tick;
@@ -226,7 +228,10 @@ subtest 'Clone' => sub {
subtest 'Exception in chain' => sub {
my $promise = Mojo::Promise->new;
my (@results, @errors);
- $promise->then(sub {@_})->then(sub {@_})->then(sub { die "test: $_[0]\n" })->then(sub { push @results, 'fail' })
+ $promise->then(sub {@_})
+ ->then(sub {@_})
+ ->then(sub { die "test: $_[0]\n" })
+ ->then(sub { push @results, 'fail' })
->catch(sub { @errors = @_ });
$promise->resolve('works');
Mojo::IOLoop->one_tick;
diff --git a/t/mojo/websocket.t b/t/mojo/websocket.t
index 0dc02085e6..4806be6407 100644
--- a/t/mojo/websocket.t
+++ b/t/mojo/websocket.t
@@ -356,8 +356,10 @@ subtest 'Promises' => sub {
$ua->websocket_p('/foo')->then(sub { $result = 'test failed' })->catch(sub { $result = shift })->wait;
is $result, 'WebSocket handshake failed', 'right result';
$result = undef;
- $ua->websocket_p($ua->server->url->to_abs->scheme('wsss'))->then(sub { $result = 'test failed' })
- ->catch(sub { $result = shift })->wait;
+ $ua->websocket_p($ua->server->url->to_abs->scheme('wsss'))
+ ->then(sub { $result = 'test failed' })
+ ->catch(sub { $result = shift })
+ ->wait;
is $result, 'Unsupported protocol: wsss', 'right result';
};
diff --git a/t/mojolicious/app.t b/t/mojolicious/app.t
index 506981c4a9..eeabc1f31c 100644
--- a/t/mojolicious/app.t
+++ b/t/mojolicious/app.t
@@ -165,14 +165,20 @@ is $t->app->plugins->emit_chain(custom_chain => 4), 8, 'hook has been emitted';
is $t->app->start(qw(test_command --to)), 'works too!', 'right result';
# Plugin::Test::SomePlugin2::register (security violation)
-$t->get_ok('/plugin-test-some_plugin2/register')->status_isnt(404)->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_unlike(qr/Something/)
+$t->get_ok('/plugin-test-some_plugin2/register')
+ ->status_isnt(404)
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_unlike(qr/Something/)
->content_like(qr/Class "MojoliciousTest::Plugin::Test::SomePlugin2" is not a controller/);
# Plugin::Test::SomePlugin2::register (security violation again)
my $logs = $t->app->log->capture('trace');
-$t->get_ok('/plugin-test-some_plugin2/register')->status_isnt(404)->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_unlike(qr/Something/)
+$t->get_ok('/plugin-test-some_plugin2/register')
+ ->status_isnt(404)
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_unlike(qr/Something/)
->content_like(qr/Class "MojoliciousTest::Plugin::Test::SomePlugin2" is not a controller/);
like $logs, qr/Class "MojoliciousTest::Plugin::Test::SomePlugin2" is not a controller/, 'right message';
undef $logs;
@@ -180,50 +186,93 @@ undef $logs;
# Foo::fun (with a lot of different tests)
my $url = $t->ua->server->url;
$url->path('/fun/time');
-$t->get_ok($url => {'X-Test' => 'Hi there!'})->status_isnt(404)->status_is(200)->status_is(200, 'with description')
- ->status_isnt(500)->status_isnt(500, 'with description')->header_is('X-Bender' => undef)
- ->header_is(Server => 'Mojolicious (Perl)')->header_is(Server => 'Mojolicious (Perl)', 'with description')
- ->header_isnt(Server => 'Whatever')->header_isnt(Server => 'Whatever', 'with description')
- ->header_like(Server => qr/Mojolicious/)->header_like(Server => qr/Mojolicious/, 'with description')
- ->header_unlike(Server => qr/Bender/)->header_unlike(Server => qr/Bender/, 'with description')
- ->content_type_is('text/html;charset=UTF-8')->content_type_is('text/html;charset=UTF-8', 'with description')
- ->content_type_isnt('text/plain')->content_type_isnt('text/plain', 'with description')->content_type_like(qr/html/)
- ->content_type_like(qr/html/, 'with description')->content_type_unlike(qr/plain/)
- ->content_type_unlike(qr/plain/, 'with description')->content_isnt('Have')->content_isnt('Have', 'with description')
- ->content_is('
Have fun!
')->content_is('Have fun!
', 'with description')->content_like(qr/fun/)
- ->content_like(qr/fun/, 'with description')->content_unlike(qr/boring/)
- ->content_unlike(qr/boring/, 'with description')->element_exists('p')->element_exists('p', 'with description')
- ->element_exists_not('b')->element_exists_not('b', 'with description')->text_is('p', 'Have fun!')
- ->text_is('p', 'Have fun!', 'with description')->text_is('notfound', undef)->text_isnt('p', 'Have')
- ->text_isnt('p', 'Have', 'with description')->text_like('p', qr/fun/)->text_like('p', qr/fun/, 'with description')
- ->text_unlike('p', qr/boring/)->text_unlike('p', qr/boring/, 'with description');
+$t->get_ok($url => {'X-Test' => 'Hi there!'})
+ ->status_isnt(404)
+ ->status_is(200)
+ ->status_is(200, 'with description')
+ ->status_isnt(500)
+ ->status_isnt(500, 'with description')
+ ->header_is('X-Bender' => undef)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(Server => 'Mojolicious (Perl)', 'with description')
+ ->header_isnt(Server => 'Whatever')
+ ->header_isnt(Server => 'Whatever', 'with description')
+ ->header_like(Server => qr/Mojolicious/)
+ ->header_like(Server => qr/Mojolicious/, 'with description')
+ ->header_unlike(Server => qr/Bender/)
+ ->header_unlike(Server => qr/Bender/, 'with description')
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_type_is('text/html;charset=UTF-8', 'with description')
+ ->content_type_isnt('text/plain')
+ ->content_type_isnt('text/plain', 'with description')
+ ->content_type_like(qr/html/)
+ ->content_type_like(qr/html/, 'with description')
+ ->content_type_unlike(qr/plain/)
+ ->content_type_unlike(qr/plain/, 'with description')
+ ->content_isnt('Have')
+ ->content_isnt('Have', 'with description')
+ ->content_is('Have fun!
')
+ ->content_is('Have fun!
', 'with description')
+ ->content_like(qr/fun/)
+ ->content_like(qr/fun/, 'with description')
+ ->content_unlike(qr/boring/)
+ ->content_unlike(qr/boring/, 'with description')
+ ->element_exists('p')
+ ->element_exists('p', 'with description')
+ ->element_exists_not('b')
+ ->element_exists_not('b', 'with description')
+ ->text_is('p', 'Have fun!')
+ ->text_is('p', 'Have fun!', 'with description')
+ ->text_is('notfound', undef)
+ ->text_isnt('p', 'Have')
+ ->text_isnt('p', 'Have', 'with description')
+ ->text_like('p', qr/fun/)
+ ->text_like('p', qr/fun/, 'with description')
+ ->text_unlike('p', qr/boring/)
+ ->text_unlike('p', qr/boring/, 'with description');
# Foo::joy (testing HTML attributes in template)
-$t->get_ok('/fun/joy')->status_is(200)->attr_is('p.joy', 'style', 'background-color: darkred;')
- ->attr_is('p.joy', 'style', 'background-color: darkred;', 'with description')->attr_is('p.joy', 'data-foo', '0')
- ->attr_is('p.joy', 'data-empty', '')->attr_is('notfound', 'style', undef)
- ->attr_isnt('p.joy', 'style', 'float: left;')->attr_isnt('p.joy', 'style', 'float: left;', 'with description')
- ->attr_like('p.joy', 'style', qr/color/)->attr_like('p.joy', 'style', qr/color/, 'with description')
- ->attr_unlike('p.joy', 'style', qr/^float/)->attr_unlike('p.joy', 'style', qr/^float/, 'with description');
+$t->get_ok('/fun/joy')
+ ->status_is(200)
+ ->attr_is('p.joy', 'style', 'background-color: darkred;')
+ ->attr_is('p.joy', 'style', 'background-color: darkred;', 'with description')
+ ->attr_is('p.joy', 'data-foo', '0')
+ ->attr_is('p.joy', 'data-empty', '')
+ ->attr_is('notfound', 'style', undef)
+ ->attr_isnt('p.joy', 'style', 'float: left;')
+ ->attr_isnt('p.joy', 'style', 'float: left;', 'with description')
+ ->attr_like('p.joy', 'style', qr/color/)
+ ->attr_like('p.joy', 'style', qr/color/, 'with description')
+ ->attr_unlike('p.joy', 'style', qr/^float/)
+ ->attr_unlike('p.joy', 'style', qr/^float/, 'with description');
# Foo::baz (missing action without template)
$logs = $t->app->log->capture('trace');
-$t->get_ok('/foo/baz')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')->content_unlike(qr/Something/)
+$t->get_ok('/foo/baz')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_unlike(qr/Something/)
->content_like(qr/Route without action and nothing to render/);
like $logs, qr/Action not found in controller/, 'right message';
undef $logs;
# Foo::yada (action-less template)
-$t->get_ok('/foo/yada')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/yada')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/look ma! no action!/);
# SyntaxError::foo (syntax error in controller)
-$t->get_ok('/syntax_error/foo')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/syntax_error/foo')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Missing right curly/);
# Foo::syntaxerror (syntax error in template)
$logs = $t->app->log->capture('trace');
-$t->get_ok('/foo/syntaxerror')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/syntaxerror')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Missing right curly/);
like $logs, qr/Rendering template "syntaxerror.html.epl"/, 'right message';
like $logs, qr/Missing right curly/, 'right message';
@@ -233,119 +282,181 @@ like $logs, qr/500 Internal Server Error/, 'right messa
undef $logs;
# Exceptional::this_one_dies (action dies)
-$t->get_ok('/exceptional/this_one_dies')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional/this_one_dies')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("doh!\n\n");
# Exceptional::this_one_might_die (bridge dies)
-$t->get_ok('/exceptional_too/this_one_dies')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional_too/this_one_dies')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("double doh!\n\n");
# Exceptional::this_one_dies (action behind bridge dies)
-$t->get_ok('/exceptional_too/this_one_dies' => {'X-DoNotDie' => 1})->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is("doh!\n\n");
+$t->get_ok('/exceptional_too/this_one_dies' => {'X-DoNotDie' => 1})
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is("doh!\n\n");
# Exceptional::this_one_does_not_exist (action does not exist)
-$t->get_ok('/exceptional/this_one_does_not_exist')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional/this_one_does_not_exist')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Exceptional::this_one_does_not_exist (action behind bridge does not exist)
-$t->get_ok('/exceptional_too/this_one_does_not_exist' => {'X-DoNotDie' => 1})->status_is(404)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Page Not Found/);
+$t->get_ok('/exceptional_too/this_one_does_not_exist' => {'X-DoNotDie' => 1})
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Page Not Found/);
# Foo::fun
-$t->get_ok('/fun/time' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is('X-Bender' => undef)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('Have fun!
');
+$t->get_ok('/fun/time' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => undef)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('Have fun!
');
# Foo::fun
$url = $t->ua->server->url;
$logs = $t->app->log->capture('trace');
$url->path('/fun/time');
-$t->get_ok($url => {'X-Test' => 'Hi there!'})->status_is(200)->header_is('X-Bender' => undef)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('Have fun!
');
+$t->get_ok($url => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => undef)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('Have fun!
');
like $logs, qr!Rendering cached template "foo/fun\.html\.ep" from DATA section!, 'right message';
undef $logs;
# Foo::fun
-$t->get_ok('/happy/fun/time' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is('X-Bender' => undef)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('Have fun!
');
+$t->get_ok('/happy/fun/time' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => undef)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('Have fun!
');
# Foo::test
-$t->get_ok('/foo/test' => {'X-Test' => 'Hi there!'})->status_is(200)
- ->header_is('X-Bender' => 'Bite my shiny metal ass!')->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/test' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => 'Bite my shiny metal ass!')
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr!/bar/test!);
# Foo::index
-$t->get_ok('/foo' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr|\s+23\nHello Mojo from the template /foo! He|);
# Foo::Bar::index
-$t->get_ok('/foo-bar' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo-bar' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr|Hello Mojo from the other template /foo-bar!|);
# Foo::something
-$t->put_ok('/somethingtest' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->put_ok('/somethingtest' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/test4/42');
-$t->post_ok('/somethingtest?_method=PUT' => {'X-Test' => 'Hi there!'})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('/test4/42');
-$t->get_ok('/somethingtest?_method=PUT' => {'X-Test' => 'Hi there!'})->status_is(500)
+$t->post_ok('/somethingtest?_method=PUT' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('/test4/42');
+$t->get_ok('/somethingtest?_method=PUT' => {'X-Test' => 'Hi there!'})
+ ->status_is(500)
->content_like(qr/Controller "MojoliciousTest::Somethingtest" does not exist/);
# Foo::url_for_missing
-$t->get_ok('/something_missing' => {'X-Test' => 'Hi there!'})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('does_not_exist');
+$t->get_ok('/something_missing' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('does_not_exist');
# Foo::templateless
-$t->get_ok('/foo/templateless' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/templateless' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Hello Mojo from a templateless renderer!/);
# Foo::withlayout
-$t->get_ok('/foo/withlayout' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/withlayout' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Same old in green Seems to work!/);
# Foo::withBlock
-$t->get_ok('/withblock.txt' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_isnt('text/html')->content_type_is('text/plain;charset=UTF-8')
+$t->get_ok('/withblock.txt' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_isnt('text/html')
+ ->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/Hello Baerbel\.\s+Hello Wolfgang\./);
# MojoliciousTest2::Foo::test
-$t->get_ok('/test2' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is('X-Bender' => 'Bite my shiny metal ass!')
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr!/test2!);
+$t->get_ok('/test2' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => 'Bite my shiny metal ass!')
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr!/test2!);
# MojoliciousTestController::index
-$t->get_ok('/test3' => {'X-Test' => 'Hi there!'})->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test3' => {'X-Test' => 'Hi there!'})
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Namespace "MojoliciousTest2::Foo" requires a controller/);
# MojoliciousTest::Foo::Bar (no action)
-$t->get_ok('/test1' => {'X-Test' => 'Hi there!'})->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test1' => {'X-Test' => 'Hi there!'})
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Controller "MojoliciousTest::Controller::Foo::Bar" requires an action/);
# MojoliciousTestController::index (no namespace)
-$t->get_ok('/test6' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is('X-Bender' => 'Bite my shiny metal ass!')
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('/test6');
+$t->get_ok('/test6' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is('X-Bender' => 'Bite my shiny metal ass!')
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('/test6');
# MojoliciousTest::Foo::Bar::test (controller class shortcut)
-$t->get_ok('/test7' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test7' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Class works!\n");
# MojoliciousTest::Foo::Bar::test (controller class)
-$t->get_ok('/test8' => {'X-Test' => 'Hi there!'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test8' => {'X-Test' => 'Hi there!'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Class works!\n");
# MojoliciousTest3::Bar::index (controller class in development namespace)
-$t->get_ok('/test9')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test9')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Development namespace works!');
# MojoliciousTest3::Baz::index (controller class precedence)
-$t->get_ok('/test10')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test10')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Development namespace has high precedence!');
# 404
-$t->get_ok('/' => {'X-Test' => 'Hi there!'})->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/' => {'X-Test' => 'Hi there!'})
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Static file /another/file (no extension)
-$t->get_ok('/another/file')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('application/octet-stream')->content_like(qr/Hello Mojolicious!/);
+$t->get_ok('/another/file')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('application/octet-stream')
+ ->content_like(qr/Hello Mojolicious!/);
# Static directory /another
$logs = $t->app->log->capture('trace');
@@ -359,68 +470,99 @@ my $size = Mojo::Asset::File->new(path => $path)->size;
my $mtime = Mojo::Date->new(Mojo::Asset::File->new(path => $path)->mtime)->to_string;
# Static file /hello.txt
-$t->get_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Last-Modified' => $mtime)->header_like('ETag' => qr/^"\w+"$/)->header_is('Content-Length' => $size)
- ->content_type_is('text/plain;charset=UTF-8')->content_like(qr/Hello Mojo from a development static file!/);
+$t->get_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Last-Modified' => $mtime)
+ ->header_like('ETag' => qr/^"\w+"$/)
+ ->header_is('Content-Length' => $size)
+ ->content_type_is('text/plain;charset=UTF-8')
+ ->content_like(qr/Hello Mojo from a development static file!/);
# Try to access a file which is not under the web root via path traversal
-$t->get_ok('/../../mojolicious/secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/../../mojolicious/secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal (goes
# back and forth one directory)
-$t->get_ok('/another/../../../mojolicious/secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/another/../../../mojolicious/secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal
# (triple dot)
-$t->get_ok('/.../mojolicious/secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/.../mojolicious/secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal
# (backslashes)
-$t->get_ok('/..\\..\\mojolicious\\secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/..\\..\\mojolicious\\secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal
# (escaped backslashes)
-$t->get_ok('/..%5C..%5Cmojolicious%5Csecret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/..%5C..%5Cmojolicious%5Csecret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Check that backslashes in query or fragment parts don't block access
$t->get_ok('/another/file?one=\\1#two=\\2')->status_is(200)->content_like(qr/Hello Mojolicious!/);
# Check If-Modified-Since
-$t->get_ok('/hello.txt' => {'If-Modified-Since' => $mtime})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/hello.txt' => {'If-Modified-Since' => $mtime})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('');
# Check If-None-Match
my $etag = $t->tx->res->headers->etag;
-$t->get_ok('/hello.txt' => {'If-None-Match' => $etag})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/hello.txt' => {'If-None-Match' => $etag})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('');
# Check weak If-None-Match against strong ETag
-$t->get_ok('/hello.txt' => {'If-None-Match' => qq{W/"$etag"}})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Hello Mojo from a development static file!/);
+$t->get_ok('/hello.txt' => {'If-None-Match' => qq{W/"$etag"}})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Hello Mojo from a development static file!/);
# Check If-None-Match and If-Last-Modified
-$t->get_ok('/hello.txt' => {'If-None-Match' => $etag, 'If-Last-Modified' => $mtime})->status_is(304)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('');
+$t->get_ok('/hello.txt' => {'If-None-Match' => $etag, 'If-Last-Modified' => $mtime})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('');
# Bad If-None-Match with correct If-Modified-Since
-$t->get_ok('/hello.txt' => {'If-None-Match' => '"123"', 'If-Modified-Since' => $mtime})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Hello Mojo from a development static file!/);
+$t->get_ok('/hello.txt' => {'If-None-Match' => '"123"', 'If-Modified-Since' => $mtime})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Hello Mojo from a development static file!/);
# Bad If-Modified-Since with correct If-None-Match
-$t->get_ok('/hello.txt' => {'If-Modified-Since' => Mojo::Date->new(23), 'If-None-Match' => $etag})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Hello Mojo from a development static file!/);
+$t->get_ok('/hello.txt' => {'If-Modified-Since' => Mojo::Date->new(23), 'If-None-Match' => $etag})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Hello Mojo from a development static file!/);
# Embedded development static file
-$t->get_ok('/some/static/file.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/some/static/file.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Development static file with high precedence.\n");
# Embedded development template
-$t->get_ok('/just/some/template')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/just/some/template')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Development template with high precedence.\n");
{
@@ -454,7 +596,9 @@ like $tx->res->body, qr|Hello Mojo from the template /foo! Hello World!|, 'right
$t = Test::Mojo->new('SingleFileTestApp');
# SingleFileTestApp::Foo::index
-$t->get_ok('/foo')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Same old in green Seems to work!/);
# SingleFileTestApp (helper)
@@ -470,16 +614,23 @@ $t->get_ok('/foo/conf')->status_is(200)->header_is(Server => 'Mojolicious (Perl)
$t->get_ok('/foo/data_template')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is("23 works!\n");
# SingleFileTestApp::Foo::data_template
-$t->get_ok('/foo/data_template2')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/data_template2')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("This one works too!\n");
# SingleFileTestApp::Foo::data_static
-$t->get_ok('/foo/data_static')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/data_static')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("And this one... ALL GLORY TO THE HYPNOTOAD!\n");
# SingleFileTestApp::Foo::routes
-$t->get_ok('/foo/routes')->status_is(200)->header_is('X-Bender' => 'Bite my shiny metal ass!')
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('/foo/routes');
+$t->get_ok('/foo/routes')
+ ->status_is(200)
+ ->header_is('X-Bender' => 'Bite my shiny metal ass!')
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('/foo/routes');
# SingleFileTestApp::Redispatch::handler
$t->app->log->level('trace')->unsubscribe('message');
@@ -495,7 +646,9 @@ $t->get_ok('/redispatch/render')->status_is(200)->header_is(Server => 'Mojolicio
$t->get_ok('/redispatch/secret')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Redispatch!');
# SingleFileTestApp::Redispatch::secret
-$t->get_ok('/redispatch/secret?rly=1')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/redispatch/secret?rly=1')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Secret!');
subtest 'Override deployment plugins' => sub {
@@ -507,15 +660,21 @@ subtest 'Override deployment plugins' => sub {
$t = Test::Mojo->new('MojoliciousTest');
# MojoliciousTestController::Foo::plugin_upper_case
-$t->get_ok('/plugin/upper_case')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/plugin/upper_case')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('WELCOME aboard!');
# MojoliciousTestController::Foo::plugin_camel_case
-$t->get_ok('/plugin/camel_case')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/plugin/camel_case')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Welcome aboard!');
# MojoliciousTestController::Foo::stage2
-$t->get_ok('/staged' => {'X-Pass' => 1})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/staged' => {'X-Pass' => 1})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Welcome aboard!');
# MojoliciousTestController::Foo::stage1
@@ -523,8 +682,11 @@ $t->get_ok('/staged')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
# MojoliciousTestController::Foo::suspended
$logs = $t->app->log->capture('trace');
-$t->get_ok('/suspended')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Suspended' => '0, 1, 1, 2')->content_is('Have fun!
');
+$t->get_ok('/suspended')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('X-Suspended' => '0, 1, 1, 2')
+ ->content_is('Have fun!
');
like $logs, qr!GET "/suspended"!, 'right message';
like $logs, qr/Routing to controller "MojoliciousTest::Foo" and action "suspended"/, 'right message';
like $logs, qr/Routing to controller "MojoliciousTest::Foo" and action "fun"/, 'right message';
@@ -549,11 +711,16 @@ $t->get_ok('/shortcut/ctrl')->status_is(200)->header_is(Server => 'Mojolicious (
$t->get_ok('/shortcut/act')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('act');
# Session with domain
-$t->get_ok('/foo/session')->status_is(200)->header_like('Set-Cookie' => qr/; domain=\.example\.com/)
- ->header_like('Set-Cookie' => qr!; path=/bar!)->content_is('Bender rockzzz!');
+$t->get_ok('/foo/session')
+ ->status_is(200)
+ ->header_like('Set-Cookie' => qr/; domain=\.example\.com/)
+ ->header_like('Set-Cookie' => qr!; path=/bar!)
+ ->content_is('Bender rockzzz!');
# Mixed formats
-$t->get_ok('/rss.xml')->status_is(200)->content_type_is('application/rss+xml')
+$t->get_ok('/rss.xml')
+ ->status_is(200)
+ ->content_type_is('application/rss+xml')
->content_like(qr!<\?xml version="1.0" encoding="UTF-8"\?>!);
# Missing controller has no side effects
diff --git a/t/mojolicious/charset_lite_app.t b/t/mojolicious/charset_lite_app.t
index 4197add697..4e7ac3e8aa 100644
--- a/t/mojolicious/charset_lite_app.t
+++ b/t/mojolicious/charset_lite_app.t
@@ -59,20 +59,29 @@ my $t = Test::Mojo->new;
$t->post_ok('/' => form => {foo => 'yatta'})->status_is(200)->content_is('foo: yatta');
# Send raw Shift_JIS octets (like browsers do)
-$t->post_ok('/' => form => {foo => $yatta_sjis} => charset => undef)->status_is(200)
- ->content_type_unlike(qr/application/)->content_type_like(qr/Shift_JIS/)->content_like(qr/$yatta/);
+$t->post_ok('/' => form => {foo => $yatta_sjis} => charset => undef)
+ ->status_is(200)
+ ->content_type_unlike(qr/application/)
+ ->content_type_like(qr/Shift_JIS/)
+ ->content_like(qr/$yatta/);
# Send raw Shift_JIS octets (like browsers do, multipart message)
$t->post_ok('/' => {'Content-Type' => 'multipart/form-data'} => form => {foo => $yatta_sjis} => charset => undef)
- ->status_is(200)->content_type_like(qr/Shift_JIS/)->content_like(qr/$yatta/);
+ ->status_is(200)
+ ->content_type_like(qr/Shift_JIS/)
+ ->content_like(qr/$yatta/);
# Send as string
-$t->post_ok('/' => form => {foo => $yatta} => charset => 'shift_jis')->status_is(200)->content_type_like(qr/Shift_JIS/)
+$t->post_ok('/' => form => {foo => $yatta} => charset => 'shift_jis')
+ ->status_is(200)
+ ->content_type_like(qr/Shift_JIS/)
->content_like(qr/$yatta/);
# Send as string (multipart message)
$t->post_ok('/' => {'Content-Type' => 'multipart/form-data'} => form => {foo => $yatta} => charset => 'shift_jis')
- ->status_is(200)->content_type_like(qr/Shift_JIS/)->content_like(qr/$yatta/);
+ ->status_is(200)
+ ->content_type_like(qr/Shift_JIS/)
+ ->content_like(qr/$yatta/);
# Unicode renderer
$t->get_ok('/unicode')->status_is(200)->content_type_is('text/plain;charset=UTF-8')->content_is($yatta);
diff --git a/t/mojolicious/dispatcher_lite_app.t b/t/mojolicious/dispatcher_lite_app.t
index e60bf66114..e59a31efab 100644
--- a/t/mojolicious/dispatcher_lite_app.t
+++ b/t/mojolicious/dispatcher_lite_app.t
@@ -127,7 +127,9 @@ subtest 'Normal route' => sub {
};
subtest 'Normal static file' => sub {
- $t->get_ok('/test.txt')->status_is(200)->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
+ $t->get_ok('/test.txt')
+ ->status_is(200)
+ ->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is("Normal static file!\n");
};
@@ -144,22 +146,30 @@ subtest 'Custom dispatcher' => sub {
};
subtest 'Static file' => sub {
- $t->get_ok('/res.txt')->status_is(200)->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
+ $t->get_ok('/res.txt')
+ ->status_is(200)
+ ->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is("Static response!\n");
};
subtest ' Custom response' => sub {
- $t->get_ok('/res.txt?route=1')->status_is(202)->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
+ $t->get_ok('/res.txt?route=1')
+ ->status_is(202)
+ ->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('Custom response!');
};
subtest 'Conditional response' => sub {
- $t->get_ok('/res.txt?route=1&res=1')->status_is(201)->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
+ $t->get_ok('/res.txt?route=1&res=1')
+ ->status_is(201)
+ ->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('Conditional response!');
};
subtest 'Another custom dispatcher' => sub {
- $t->get_ok('/custom_too')->status_is(200)->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
+ $t->get_ok('/custom_too')
+ ->status_is(200)
+ ->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('this works too');
};
diff --git a/t/mojolicious/embedded_lite_app.t b/t/mojolicious/embedded_lite_app.t
index 3b7254dfe5..3451499313 100644
--- a/t/mojolicious/embedded_lite_app.t
+++ b/t/mojolicious/embedded_lite_app.t
@@ -260,7 +260,8 @@ subtest 'Stream from myapp.pl with Unicode prefix' => sub {
};
subtest 'URL from myapp.pl with Unicode prefix' => sub {
- $t->get_ok('/x/♥/url/☃')->status_is(200)
+ $t->get_ok('/x/♥/url/☃')
+ ->status_is(200)
->content_is('/x/%E2%99%A5/url/%E2%98%83.json -> /x/%E2%99%A5/%E2%98%83/stream!');
};
@@ -326,7 +327,9 @@ EOF
};
subtest 'Host from myapp.pl with domain' => sub {
- $t->get_ok('/host' => {Host => 'mojolicious.org'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/host' => {Host => 'mojolicious.org'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('mojolicious.org');
};
@@ -344,7 +347,9 @@ EOF
};
subtest 'Host from myapp.pl with domain again' => sub {
- $t->get_ok('/host' => {Host => 'mojolicious.org'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/host' => {Host => 'mojolicious.org'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('mojolicious.org');
};
@@ -362,17 +367,23 @@ EOF
};
subtest 'Host from myapp.pl with wildcard domain' => sub {
- $t->get_ok('/host' => {Host => 'ExAmPlE.CoM'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/host' => {Host => 'ExAmPlE.CoM'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('ExAmPlE.CoM');
};
subtest 'Host from myapp.pl with wildcard domain again' => sub {
- $t->get_ok('/host' => {Host => 'www.example.com'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/host' => {Host => 'www.example.com'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('www.example.com');
};
subtest 'Host from myapp.pl with wildcard domain again' => sub {
- $t->get_ok('/host' => {Host => 'foo.bar.example.com'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/host' => {Host => 'foo.bar.example.com'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('foo.bar.example.com');
};
@@ -390,7 +401,9 @@ EOF
};
subtest 'Host from myapp.pl with wildcard domain and Unicode prefix' => sub {
- $t->get_ok('/♥/123/host' => {Host => 'foo-bar.de'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/♥/123/host' => {Host => 'foo-bar.de'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('foo-bar.de');
};
@@ -399,7 +412,9 @@ subtest 'Echo from myapp.pl with wildcard domain and Unicode prefix' => sub {
};
subtest 'Host from myapp.pl with wildcard domain and Unicode prefix again' => sub {
- $t->get_ok('/♥/123/host' => {Host => 'www.foo-bar.de'})->status_is(200)->header_is('X-Message' => 'it works!')
+ $t->get_ok('/♥/123/host' => {Host => 'www.foo-bar.de'})
+ ->status_is(200)
+ ->header_is('X-Message' => 'it works!')
->content_is('www.foo-bar.de');
};
@@ -424,8 +439,10 @@ subtest 'Another invalid domain' => sub {
};
subtest 'Embedded WebSocket' => sub {
- $t->websocket_ok('/x/♥/url_for')->send_ok('ws_test')
- ->message_ok->message_like(qr!^ws://127\.0\.0\.1:\d+/x/%E2%99%A5/url_for$!)->send_ok('index')
+ $t->websocket_ok('/x/♥/url_for')
+ ->send_ok('ws_test')
+ ->message_ok->message_like(qr!^ws://127\.0\.0\.1:\d+/x/%E2%99%A5/url_for$!)
+ ->send_ok('index')
->message_ok->message_like(qr!^http://127\.0\.0\.1:\d+/x/%E2%99%A5$!)->finish_ok;
};
diff --git a/t/mojolicious/exception_lite_app.t b/t/mojolicious/exception_lite_app.t
index 40f52afa4b..a1486c85c7 100644
--- a/t/mojolicious/exception_lite_app.t
+++ b/t/mojolicious/exception_lite_app.t
@@ -208,14 +208,20 @@ subtest 'Dead included template' => sub {
};
subtest 'Dead template with layout' => sub {
- $t->get_ok('/dead_template_with_layout')->status_is(500)->content_like(qr/dead template with layout!/)
- ->content_like(qr/line 2/)->content_unlike(qr/Green/);
+ $t->get_ok('/dead_template_with_layout')
+ ->status_is(500)
+ ->content_like(qr/dead template with layout!/)
+ ->content_like(qr/line 2/)
+ ->content_unlike(qr/Green/);
like $log, qr/dead template with layout!/, 'right result';
};
subtest 'Dead action' => sub {
- $t->get_ok('/dead_action')->status_is(500)->content_type_is('text/html;charset=UTF-8')
- ->content_like(qr!get '/dead_action'!)->content_like(qr/dead action!/)
+ $t->get_ok('/dead_action')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_like(qr!get '/dead_action'!)
+ ->content_like(qr/dead action!/)
->text_is('#error' => "dead action!\n");
like $log, qr/dead action!/, 'right result';
};
@@ -225,18 +231,26 @@ subtest 'Dead action with different format' => sub {
};
subtest 'Dead action with unsupported format' => sub {
- $t->get_ok('/dead_action.json')->status_is(500)->content_type_is('text/html;charset=UTF-8')
- ->content_like(qr!get '/dead_action'!)->content_like(qr/dead action!/);
+ $t->get_ok('/dead_action.json')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_like(qr!get '/dead_action'!)
+ ->content_like(qr/dead action!/);
};
subtest 'Dead action with custom exception rendering' => sub {
- $t->get_ok('/dead_action' => {Accept => 'text/plain'})->status_is(500)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/dead_action' => {Accept => 'text/plain'})
+ ->status_is(500)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/^dead action!\n/);
};
subtest 'Action dies twice' => sub {
- $t->get_ok('/double_dead_action_☃')->status_is(500)->content_like(qr!get '/double_dead_action_☃'!)
- ->content_like(qr/File.+lite_app\.t\", line \d/)->content_like(qr/double dead action!/);
+ $t->get_ok('/double_dead_action_☃')
+ ->status_is(500)
+ ->content_like(qr!get '/double_dead_action_☃'!)
+ ->content_like(qr/File.+lite_app\.t\", line \d/)
+ ->content_like(qr/double dead action!/);
};
subtest 'Trapped exception' => sub {
@@ -256,33 +270,46 @@ subtest 'Exception in helper' => sub {
};
subtest 'Missing template' => sub {
- $t->get_ok('/missing_template')->status_is(500)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/missing_template')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
->content_like(qr/Route without action and nothing to render/);
};
subtest 'Missing template with different format' => sub {
- $t->get_ok('/missing_template.xml')->status_is(500)->content_type_is('application/xml')
+ $t->get_ok('/missing_template.xml')
+ ->status_is(500)
+ ->content_type_is('application/xml')
->content_is("bad\n");
};
subtest 'Missing template with unsupported format' => sub {
- $t->get_ok('/missing_template.json')->status_is(500)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/missing_template.json')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
->content_like(qr/Route without action and nothing to render/);
};
subtest 'Missing template with custom rendering' => sub {
- $t->get_ok('/missing_template.txt')->status_is(500)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/missing_template.txt')
+ ->status_is(500)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Missing template, whatever.');
};
subtest 'Missing template (failed rendering)' => sub {
- $t->get_ok('/missing_template/too')->status_is(500)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/missing_template/too')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
->content_like(qr/Could not render a response/);
};
subtest 'Missing helper (correct context)' => sub {
- $t->get_ok('/missing_helper')->status_is(500)->content_type_is('text/html;charset=UTF-8')
- ->content_like(qr/Server Error/)->content_like(qr/shift->missing_helper/);
+ $t->get_ok('/missing_helper')
+ ->status_is(500)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_like(qr/Server Error/)
+ ->content_like(qr/shift->missing_helper/);
};
subtest 'Reuse exception' => sub {
@@ -298,39 +325,57 @@ subtest 'Reuse exception' => sub {
subtest 'JSON exceptions' => sub {
$t->app->mode('development');
is $t->app->exception_format('json')->exception_format, 'json', 'right exception format';
- $t->get_ok('/dead_template')->status_is(500)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/dead_template')
+ ->status_is(500)
+ ->content_type_is('application/json;charset=UTF-8')
->json_like('/error', qr/dead template!/);
- $t->get_ok('/does_not_exist')->status_is(404)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/does_not_exist')
+ ->status_is(404)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({error => 'Not Found'});
my $stash;
$t->app->hook(after_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/txt/exception')->status_is(500)->header_is('X-Text' => 'txt')
- ->content_type_is('text/plain;charset=UTF-8')->content_like(qr/Text exception/);
+ $t->get_ok('/txt/exception')
+ ->status_is(500)
+ ->header_is('X-Text' => 'txt')
+ ->content_type_is('text/plain;charset=UTF-8')
+ ->content_like(qr/Text exception/);
ok $stash->{exception}, 'exception exists in stash';
isa_ok $stash->{exception}, 'Mojo::Exception', 'is stash exception correct type?';
$t->app->mode('production');
- $t->get_ok('/dead_template')->status_is(500)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/dead_template')
+ ->status_is(500)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({error => 'Internal Server Error'});
- $t->get_ok('/does_not_exist')->status_is(404)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/does_not_exist')
+ ->status_is(404)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({error => 'Not Found'});
};
subtest 'Text exceptions' => sub {
$t->app->mode('development');
is $t->app->exception_format('txt')->exception_format, 'txt', 'right exception format';
- $t->get_ok('/dead_template')->status_is(500)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/dead_template')
+ ->status_is(500)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/dead template!/);
$t->get_ok('/does_not_exist')->status_is(404)->content_type_is('text/plain;charset=UTF-8')->content_is('Not Found');
my $stash;
$t->app->hook(after_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/txt/exception')->status_is(500)->header_is('X-Text' => 'txt')
- ->content_type_is('text/plain;charset=UTF-8')->content_like(qr/Text exception/);
+ $t->get_ok('/txt/exception')
+ ->status_is(500)
+ ->header_is('X-Text' => 'txt')
+ ->content_type_is('text/plain;charset=UTF-8')
+ ->content_like(qr/Text exception/);
ok $stash->{exception}, 'exception exists in stash';
isa_ok $stash->{exception}, 'Mojo::Exception', 'is stash exception correct type?';
$t->app->mode('production');
- $t->get_ok('/dead_template')->status_is(500)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/dead_template')
+ ->status_is(500)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Internal Server Error');
$t->get_ok('/does_not_exist')->status_is(404)->content_type_is('text/plain;charset=UTF-8')->content_is('Not Found');
};
diff --git a/t/mojolicious/group_lite_app.t b/t/mojolicious/group_lite_app.t
index a8ed526642..e9dea77f00 100644
--- a/t/mojolicious/group_lite_app.t
+++ b/t/mojolicious/group_lite_app.t
@@ -194,7 +194,9 @@ $t->reset_session;
$t->get_ok('/multi')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is("\n\n\n\n\n\n\n\n");
# Multiple cookies with same name (again)
-$t->get_ok('/multi')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/multi')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("two\nthree\none\ntwo\nfive\nsix\nfour\nfive\n");
# Missing action behind bridge
@@ -213,15 +215,25 @@ undef $logs;
$t->get_ok('/suspended?ok=0')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('stopped!');
# Authenticated with header
-$t->get_ok('/with_under' => {'X-Bender' => 'Rodriguez'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Under' => '23, 24')->header_like('X-Under' => qr/23, 24/)->content_is('Unders are cool!');
+$t->get_ok('/with_under' => {'X-Bender' => 'Rodriguez'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('X-Under' => '23, 24')
+ ->header_like('X-Under' => qr/23, 24/)
+ ->content_is('Unders are cool!');
# Authenticated with header too
-$t->get_ok('/with_under_too' => {'X-Bender' => 'Rodriguez'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('X-Under' => '23, 24')->header_like('X-Under' => qr/23, 24/)->content_is('Unders are cool too!');
+$t->get_ok('/with_under_too' => {'X-Bender' => 'Rodriguez'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('X-Under' => '23, 24')
+ ->header_like('X-Under' => qr/23, 24/)
+ ->content_is('Unders are cool too!');
# Not authenticated with header
-$t->get_ok('/with_under_too')->status_is(401)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/with_under_too')
+ ->status_is(401)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Unauthorized/);
# Not authenticated with parameter
@@ -229,14 +241,18 @@ $t->get_ok('/param_auth')->status_is(200)->header_is(Server => 'Mojolicious (Per
is $stash->{_name}, undef, 'no "_name" value';
# Authenticated with parameter
-$t->get_ok('/param_auth?name=Bender')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/param_auth?name=Bender')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Bender!\n");
# Not authenticated with parameter
$t->get_ok('/param_auth/too')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is("Not Bender!\n");
# Authenticated with parameter too
-$t->get_ok('/param_auth/too?name=Bender')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/param_auth/too?name=Bender')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('You could be Bender too!');
# No cookies, session or flash
@@ -246,7 +262,8 @@ is $stash->{_name}, 'stash', 'right "_name" value';
# Cookies, session and flash
$logs = $t->app->log->capture('trace');
-$t->get_ok('/bridge2stash')->status_is(200)
+$t->get_ok('/bridge2stash')
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!flash!\n");
like $logs, qr/Cookie "foo" is not signed/, 'right message';
like $logs, qr/Cookie "bad" has bad signature/, 'right message';
@@ -264,7 +281,8 @@ is $t->tx->res->cookie('mojolicious')->samesite, undef, 'no SameSite value';
$t->reset_session;
my $session = b("☃☃☃☃☃")->encode->b64_encode('');
my $hmac = $session->clone->hmac_sha1_sum($t->app->secrets->[0]);
-$t->get_ok('/bridge2stash' => {Cookie => "mojolicious=$session--$hmac"})->status_is(200)
+$t->get_ok('/bridge2stash' => {Cookie => "mojolicious=$session--$hmac"})
+ ->status_is(200)
->content_is("stash too!!!!!!!!\n");
# Not collecting cookies
@@ -283,12 +301,14 @@ $t->get_ok('/mojo/logo-white.png')->status_is(200);
$t->get_ok('/mojo/logo-white.png')->status_is(200);
# With cookies, session and flash again
-$t->get_ok('/bridge2stash')->status_is(200)
+$t->get_ok('/bridge2stash')
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!flash!\n");
# With cookies and session but no flash (rotating secrets)
$t->app->secrets(['test2', 'test1']);
-$t->get_ok('/bridge2stash' => {'X-Flash2' => 1})->status_is(200)
+$t->get_ok('/bridge2stash' => {'X-Flash2' => 1})
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!!\n");
ok $t->tx->res->cookie('mojolicious')->expires < time, 'session cookie expires';
@@ -306,20 +326,26 @@ $t->get_ok('/late/session')->status_is(200)->content_is('works!');
$t->get_ok('/late/session')->status_is(200)->content_is('works!');
# Counter
-$t->get_ok('/with/under/count' => {'X-Bender' => 'Rodriguez'})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->header_is('X-Under' => 1)->content_is("counter\n");
+$t->get_ok('/with/under/count' => {'X-Bender' => 'Rodriguez'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('X-Under' => 1)
+ ->content_is("counter\n");
is $stash->{_name}, undef, 'no "_name" value';
# Cookies, session and no flash again
-$t->get_ok('/bridge2stash' => {'X-Flash' => 1})->status_is(200)
+$t->get_ok('/bridge2stash' => {'X-Flash' => 1})
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!!\n");
# With cookies, session and flash
-$t->get_ok('/bridge2stash')->status_is(200)
+$t->get_ok('/bridge2stash')
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!flash!\n");
# With cookies and session but no flash
-$t->get_ok('/bridge2stash' => {'X-Flash2' => 1})->status_is(200)
+$t->get_ok('/bridge2stash' => {'X-Flash2' => 1})
+ ->status_is(200)
->content_is("stash too!cookie!!signed_cookie!!bad_cookie--12345678!session!!\n");
# Prefix
@@ -362,7 +388,9 @@ $t->get_ok('/authgroup?ok=1')->status_is(200)->content_type_is('text/html;charse
$t->get_ok('/authgroup')->status_is(200)->content_type_is('text/html;charset=UTF-8')->content_is("You're not ok.");
# Authenticated by group (with format)
-$t->get_ok('/authgroup.txt?ok=1')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+$t->get_ok('/authgroup.txt?ok=1')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is("You're ok.");
# Not authenticated by group (with format)
@@ -372,7 +400,9 @@ $t->get_ok('/authgroup.txt')->status_is(200)->content_type_is('text/plain;charse
$t->get_ok('/noauthgroup')->status_is(200)->content_is("Whatever one.\n");
# Disabled format detection
-$t->get_ok('/no_format')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+$t->get_ok('/no_format')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is('No format detection.');
# Invalid format
@@ -382,11 +412,15 @@ $t->get_ok('/no_format.txt')->status_is(404)->content_type_is('text/html;charset
$t->get_ok('/some_formats')->status_is(404)->content_type_is('text/html;charset=UTF-8')->content_is("Oops!\n");
# Format "txt" has been detected
-$t->get_ok('/some_formats.txt')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+$t->get_ok('/some_formats.txt')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Some format detection.');
# Format "json" has been detected
-$t->get_ok('/some_formats.json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+$t->get_ok('/some_formats.json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->content_is('Some format detection.');
# Invalid format
@@ -396,7 +430,9 @@ $t->get_ok('/some_formats.xml')->status_is(404)->content_type_is('text/html;char
$t->get_ok('/no_real_format')->status_is(404)->content_type_is('text/html;charset=UTF-8')->content_is("Oops!\n");
# No format detected
-$t->get_ok('/no_real_format.xml')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+$t->get_ok('/no_real_format.xml')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is('No real format.');
# Invalid format
diff --git a/t/mojolicious/layouted_lite_app.t b/t/mojolicious/layouted_lite_app.t
index 8756f96587..ff9cdf2d86 100644
--- a/t/mojolicious/layouted_lite_app.t
+++ b/t/mojolicious/layouted_lite_app.t
@@ -118,17 +118,23 @@ subtest '"0" content reassignment' => sub {
};
subtest 'Template with layout' => sub {
- $t->get_ok('/works')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/works')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is("DefaultJust worksThis just works!\n\n");
};
subtest 'Different layout' => sub {
- $t->get_ok('/works?green=1')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/works?green=1')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is("GreenJust worksThis just works!\n\n");
};
subtest 'Extended' => sub {
- $t->get_ok('/works?blue=1')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/works?blue=1')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is("BlueJust worksThis just works!\n\n");
};
@@ -149,7 +155,8 @@ subtest 'Extended missing template' => sub {
};
subtest 'Extended missing template (not found)' => sub {
- $t->get_ok('/doesreallynotexist?green=1')->status_is(404)
+ $t->get_ok('/doesreallynotexist?green=1')
+ ->status_is(404)
->content_is("GreenNot found happenedNot found happened!\n\n");
};
@@ -170,32 +177,46 @@ subtest 'Extended dead action' => sub {
};
subtest 'Template inheritance' => sub {
- $t->get_ok('/template_inheritance')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/template_inheritance')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Works!\n
\nSidebar!\nHello World!\n\nDefault footer!\n");
};
subtest 'Just the layout' => sub {
- $t->get_ok('/layout_without_inheritance')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/layout_without_inheritance')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("\nDefault header!\nDefault sidebar!\n\nDefault footer!\n");
};
subtest 'Double inheritance' => sub {
- $t->get_ok('/double_inheritance')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/double_inheritance')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Works!\n
\nSidebar too!\n" . "Hello World!\n\nDefault footer!\n");
};
subtest 'Triple inheritance' => sub {
- $t->get_ok('/triple_inheritance')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/triple_inheritance')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is(
"Works!\n
\nSidebar too!\n" . "New .\nShared content!\n\nDefault footer!\n");
};
subtest 'Mixed inheritance (with layout)' => sub {
- $t->get_ok('/mixed_inheritance/first')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/mixed_inheritance/first')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Default\n Default header\nStuff\n\n Default footer\n\n");
- $t->get_ok('/mixed_inheritance/second')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/mixed_inheritance/second')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Green New header\nStuff\n\n Default footer\n\n");
- $t->get_ok('/mixed_inheritance/third')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/mixed_inheritance/third')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Default New header\nStuff\n New footer\n\n");
};
@@ -204,49 +225,71 @@ subtest 'Template from plugin' => sub {
};
subtest 'Nested included templates' => sub {
- $t->get_ok('/nested-includes')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/nested-includes')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted Nested \n[\n 1,\n 2\n]\nthere
!\n\n\n\n");
};
subtest 'Included template with localized stash values' => sub {
- $t->get_ok('/localized/include')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('text/html;charset=UTF-8')->content_is("lmth\n\noof\n\n\n123 2dezilacol\noof 1dezilacol");
+ $t->get_ok('/localized/include')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_is("lmth\n\noof\n\n\n123 2dezilacol\noof 1dezilacol");
};
subtest 'Filter' => sub {
- $t->get_ok('/plain/reverse')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('application/octet-stream')->content_is('oof!olleH');
+ $t->get_ok('/plain/reverse')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('application/octet-stream')
+ ->content_is('oof!olleH');
};
subtest 'Layout in render call' => sub {
- $t->get_ok('/outerlayout')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/outerlayout')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted \n[\n 1,\n 2\n]\nthere
!\n\n\n");
};
subtest 'Extends in render call' => sub {
- $t->get_ok('/outerextends')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/outerextends')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted \n[\n 1,\n 2\n]\nthere
!\n\n\n");
};
subtest 'Layout in route' => sub {
- $t->get_ok('/outerlayouttwo')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/outerlayouttwo')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted \n[\n 1,\n 2\n]\nthere
!\n\n\n");
};
subtest 'Included template with layout' => sub {
- $t->get_ok('/outerinnerlayout')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/outerinnerlayout')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted Hello\nlayouted [\n 1,\n 2\n]\nthere
!\n\n\n\n");
};
subtest 'Layout with block' => sub {
- $t->get_ok('/withblocklayout')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/withblocklayout')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("\nwith_block \n\nOne: one\nTwo: two\n\n");
};
subtest 'Content blocks' => sub {
- $t->get_ok('/content_for')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/content_for')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Content!This\n\nseems\nto\nHello World!\n\nwork!\n\nShared content!\n\n");
- $t->get_ok('/content_with')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/content_with')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Default\n\nSomething else!\n\n\n
Hello World!\n\n");
};
@@ -263,22 +306,30 @@ subtest '"0" data' => sub {
};
subtest 'Variants (desktop)' => sub {
- $t->get_ok('/variants.txt')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/variants.txt')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Variant: Desktop!');
};
subtest 'Variants (tablet)' => sub {
- $t->get_ok('/variants.txt?device=tablet')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/variants.txt?device=tablet')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Variant: Tablet!');
};
subtest 'Variants (desktop fallback)' => sub {
- $t->get_ok('/variants.txt?device=phone')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/variants.txt?device=phone')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Variant: Desktop!');
};
subtest 'Variants ("0")' => sub {
- $t->get_ok('/variants.txt?device=0')->status_is(200)->content_type_is('text/plain;charset=UTF-8')
+ $t->get_ok('/variants.txt?device=0')
+ ->status_is(200)
+ ->content_type_is('text/plain;charset=UTF-8')
->content_is('Another variant: Desktop!');
};
diff --git a/t/mojolicious/lib/MojoliciousTest.pm b/t/mojolicious/lib/MojoliciousTest.pm
index 0dcf88346f..31844597d8 100644
--- a/t/mojolicious/lib/MojoliciousTest.pm
+++ b/t/mojolicious/lib/MojoliciousTest.pm
@@ -67,7 +67,10 @@ sub startup {
$r->any('/exceptional/this_one_dies')->to('exceptional#this_one_dies');
# /exceptional_too/*
- $r->any('/exceptional_too')->inline(1)->to('exceptional#this_one_might_die')->any('/this_one_dies')
+ $r->any('/exceptional_too')
+ ->inline(1)
+ ->to('exceptional#this_one_might_die')
+ ->any('/this_one_dies')
->to('#this_one_dies');
# /fun/time
diff --git a/t/mojolicious/lite_app.t b/t/mojolicious/lite_app.t
index 088f88b7fa..2653e35160 100644
--- a/t/mojolicious/lite_app.t
+++ b/t/mojolicious/lite_app.t
@@ -493,20 +493,29 @@ $t->get_ok('/unicode/a b')->status_is(200)->content_is('a b/unicode/a%20b');
$t->get_ok('/unicode/a\\b')->status_is(200)->content_is('a\\b/unicode/a%5Cb');
# Root
-$t->get_ok('/')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
# HEAD request
-$t->head_ok('/')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is('Content-Length' => 55)
+$t->head_ok('/')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 55)
->content_is('');
# HEAD request (lowercase)
my $tx = $t->ua->build_tx(head => '/');
-$t->request_ok($tx)->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is('Content-Length' => 55)
+$t->request_ok($tx)
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 55)
->content_is('');
# Root with body
-$t->get_ok('/', '1234' x 1024)->status_is(200)
+$t->get_ok('/', '1234' x 1024)
+ ->status_is(200)
->content_is("/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
# DELETE request
@@ -517,18 +526,26 @@ $t->post_ok('/?_method=DELETE')->status_is(200)->header_is(Server => 'Mojoliciou
$t->post_ok('/')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Bye!');
# Unicode alternatives
-$t->get_ok('/alternatives/☃')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/alternatives/☃')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/alternatives/%E2%98%83');
-$t->get_ok('/alternatives/♥')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/alternatives/♥')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/alternatives/%E2%99%A5');
$t->get_ok('/alternatives/☃23')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')->content_is("Oops!\n");
$t->get_ok('/alternatives')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')->content_is("Oops!\n");
$t->get_ok('/alternatives/test')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')->content_is("Oops!\n");
# Optional placeholder in the middle
-$t->get_ok('/optional/test/placeholder')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/optional/test/placeholder')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('test-/optional/test/placeholder');
-$t->get_ok('/optional/placeholder')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/optional/placeholder')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('none-/optional/none/placeholder');
# Optional placeholder
@@ -549,32 +566,45 @@ $t->get_ok('/noformat.xml')->status_is(404)->header_is(Server => 'Mojolicious (P
$t->post_ok('/multipart/form' => form => {test => [1 .. 5]})->status_is(200)->content_is(join "\n", 1 .. 5);
# "multipart/form-data"
-$t->post_ok('/multipart/form' => form => {test => [1 .. 5], file => {content => '123'}})->status_is(200)
+$t->post_ok('/multipart/form' => form => {test => [1 .. 5], file => {content => '123'}})
+ ->status_is(200)
->content_is(join "\n", 1 .. 5);
# Generated name
$t->get_ok('/auto_name')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('/custom_name');
# Query string roundtrip
-$t->get_ok('/query_string?http://mojolicious.org/perldoc?foo=%62ar')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('http://mojolicious.org/perldoc?foo=%62ar');
+$t->get_ok('/query_string?http://mojolicious.org/perldoc?foo=%62ar')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('http://mojolicious.org/perldoc?foo=%62ar');
# Reserved stash values
-$t->get_ok('/reserved?data=just-works')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/reserved?data=just-works')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('just-works');
-$t->get_ok('/reserved?data=just-works&json=test')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/reserved?data=just-works&json=test')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('just-works');
# Exception in inline template
-$t->get_ok('/inline/exception')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/inline/exception')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Died at inline template 6635c7011166fa11bb23c21912900ea9 line 1.\n\n");
# Exception in template from data section
-$t->get_ok('/data/exception')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/data/exception')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Died at template dies.html.ep from DATA section line 2.\n\n");
# Exception in template
-$t->get_ok('/template/exception')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/template/exception')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Died at template dies_too.html.ep line 2.\n\n");
# Generate URL without format
@@ -586,33 +616,48 @@ $t->get_ok('/without-format.html')->content_is("/without-format\n");
$t->get_ok('/json_too')->status_is(200)->json_is({hello => 'world'});
# Static inline file
-$t->get_ok('/static.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is("Just some\ntext!\n\n");
+$t->get_ok('/static.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("Just some\ntext!\n\n");
# Partial inline file
-$t->get_ok('/static.txt' => {Range => 'bytes=2-5'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 4)->content_is('st s');
+$t->get_ok('/static.txt' => {Range => 'bytes=2-5'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 4)
+ ->content_is('st s');
# Protected DATA template
-$t->get_ok('/template.txt.epl')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/template.txt.epl')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Route without action and nothing to render/);
# Captured "0"
$t->get_ok('/null/0')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('0');
# Render action
-$t->get_ok('/action_template')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/action_template')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("controller and action!\n");
# Dead action
$t->get_ok('/dead')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/works!/);
# Dead renderer
-$t->get_ok('/dead_renderer')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/dead_renderer')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/renderer works!/);
# Dead renderer with auto rendering
-$t->get_ok('/dead_auto_renderer')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/dead_auto_renderer')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/renderer works!/);
# Dead template
@@ -625,17 +670,23 @@ $t->get_ok('/handler_change_status')->status_is(500)->content_is("Bad\n");
$t->get_ok('/template_change_status')->status_is(500)->content_is("Bad\n");
# Regex in name
-$t->get_ok('/regex/in/template')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/regex/in/template')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("test(test)(\\Qtest\\E)(\n");
# Chunked response with basic auth
-$t->get_ok('//sri:foo@/stream' => form => {foo => 'bar'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('//sri:foo@/stream' => form => {foo => 'bar'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr!^foobarsri:foohttp://127\.0\.0\.1:\d+/stream$!);
# Ajax
$t->get_ok('/maybe/ajax')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('not ajax');
-$t->get_ok('/maybe/ajax' => {'X-Requested-With' => 'XMLHttpRequest'})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('is ajax');
+$t->get_ok('/maybe/ajax' => {'X-Requested-With' => 'XMLHttpRequest'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('is ajax');
# With finish event
my $stash;
@@ -655,22 +706,29 @@ $t->get_ok('/root')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->
$t->get_ok('/root.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('root fallback!');
# Root with format
-$t->get_ok('/.html')->status_is(200)->header_exists_not('Servers')
- ->header_exists_not('Servers', 'the header is missing')->header_exists('Server')
- ->header_exists('Server', 'the header exists')->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/.html')
+ ->status_is(200)
+ ->header_exists_not('Servers')
+ ->header_exists_not('Servers', 'the header is missing')
+ ->header_exists('Server')
+ ->header_exists('Server', 'the header exists')
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
subtest 'Reverse proxy with "X-Forwarded-For"' => sub {
local $ENV{MOJO_REVERSE_PROXY} = 1;
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
- ->header_unlike('X-Original' => qr/192\.0\.2\.1/)->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.1-0$!);
+ $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
+ ->header_unlike('X-Original' => qr/192\.0\.2\.1/)
+ ->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.1-0$!);
};
subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies' => sub {
local $ENV{MOJO_TRUSTED_PROXIES} = '127.0.0.1, 192.0.2.1';
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
+ $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
->header_unlike('X-Original' => qr/192\.0\.2\.(?:2|1)/)
->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.2-0$!);
};
@@ -678,7 +736,8 @@ subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies' => sub {
subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (untrusted original)' => sub {
local $ENV{MOJO_TRUSTED_PROXIES} = '192.0.2.1';
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
+ $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
->header_unlike('X-Original' => qr/192\.0\.2\.(?:2|1)/)
->content_like(qr!http://127\.0\.0\.1:\d+/0-127\.0\.0\.1-0$!);
};
@@ -686,7 +745,8 @@ subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (untrusted ori
subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxy networks' => sub {
local $ENV{MOJO_TRUSTED_PROXIES} = '127.0.0.0/8, 192.0.2.1/32';
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
+ $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
->header_unlike('X-Original' => qr/192\.0\.2\.(?:2|1)/)
->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.2-0$!);
};
@@ -694,7 +754,8 @@ subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxy networks' => sub
subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (all addresses trusted)' => sub {
local $ENV{MOJO_TRUSTED_PROXIES} = '0.0.0.0/0';
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
+ $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
->header_unlike('X-Original' => qr/192\.0\.2\.(?:2|1)/)
->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.2-0$!);
};
@@ -702,7 +763,8 @@ subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (all addresses
subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (unexpected leading address)' => sub {
local $ENV{MOJO_TRUSTED_PROXIES} = '127.0.0.0/8, 192.0.2.1';
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-For' => '7.7.7.7, 192.0.2.2, 192.0.2.1'})->status_is(200)
+ $t->get_ok('/0' => {'X-Forwarded-For' => '7.7.7.7, 192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
->header_unlike('X-Original' => qr/192\.0\.2\.(?:2|1)/)
->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.2-0$!);
};
@@ -710,18 +772,27 @@ subtest 'Reverse proxy with "X-Forwarded-For" and trusted proxies (unexpected le
subtest 'Reverse proxy with "X-Forwarded-Proto"' => sub {
local $ENV{MOJO_REVERSE_PROXY} = 1;
my $t = Test::Mojo->new;
- $t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})->status_is(200)->content_like(qr!^https://127\.0\.0\.1:\d+/0-!)
- ->content_like(qr/-0$/)->content_unlike(qr!-192\.0\.2\.1-0$!);
+ $t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})
+ ->status_is(200)
+ ->content_like(qr!^https://127\.0\.0\.1:\d+/0-!)
+ ->content_like(qr/-0$/)
+ ->content_unlike(qr!-192\.0\.2\.1-0$!);
};
# "X-Forwarded-For"
$t->ua->server->restart;
-$t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})->status_is(200)
- ->content_like(qr!^http://127\.0\.0\.1:\d+/0-!)->content_like(qr/-0$/)->content_unlike(qr!-192\.0\.2\.1-0$!);
+$t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
+ ->status_is(200)
+ ->content_like(qr!^http://127\.0\.0\.1:\d+/0-!)
+ ->content_like(qr/-0$/)
+ ->content_unlike(qr!-192\.0\.2\.1-0$!);
# "X-Forwarded-Proto"
-$t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})->status_is(200)->content_like(qr!^http://127\.0\.0\.1:\d+/0-!)
- ->content_like(qr/-0$/)->content_unlike(qr!-192\.0\.2\.1-0$!);
+$t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})
+ ->status_is(200)
+ ->content_like(qr!^http://127\.0\.0\.1:\d+/0-!)
+ ->content_like(qr/-0$/)
+ ->content_unlike(qr!-192\.0\.2\.1-0$!);
# "continue" keyword in template
$t->get_ok('/continue')->status_is(200)->content_like(qr/1.+2.+3/s);
@@ -754,7 +825,9 @@ undef $logs;
{
local $ENV{MOJO_MAX_MESSAGE_SIZE} = 1024;
my $logs = app->log->capture('trace');
- $t->get_ok('/', '1234' x 1024)->status_is(200)->header_is(Connection => 'close')
+ $t->get_ok('/', '1234' x 1024)
+ ->status_is(200)
+ ->header_is(Connection => 'close')
->content_is("Maximum message size exceeded\n" . "/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
like $logs, qr/Maximum message size exceeded/, 'right message';
undef $logs;
@@ -774,7 +847,8 @@ $t->get_ok('/foo_wildcard_too/123')->status_is(200)->content_is('123');
$t->get_ok('/foo_wildcard_too/')->status_is(404);
# Header conditions
-$t->get_ok('/with/header/condition', {'X-Secret-Header' => 'bar', 'X-Another-Header' => 'baz'})->status_is(200)
+$t->get_ok('/with/header/condition', {'X-Secret-Header' => 'bar', 'X-Another-Header' => 'baz'})
+ ->status_is(200)
->content_is("Test ok!\n");
$t->get_ok('/with/header/condition')->status_is(404)->content_like(qr/Oops!/);
$t->get_ok('/with/header/condition' => {'X-Secret-Header' => 'bar'})->status_is(404)->content_like(qr/Oops!/);
@@ -785,15 +859,21 @@ $t->post_ok('/with/header/condition' => {} => 'bar')->
# Session cookie
$t->get_ok('/session_cookie')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Cookie set!');
-$t->get_ok('/session_cookie/2')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/session_cookie/2')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Session is 23!');
-$t->get_ok('/session_cookie/2')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/session_cookie/2')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Session is 23!');
# Session reset
$t->reset_session;
ok !$t->tx, 'session reset';
-$t->get_ok('/session_cookie/2')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/session_cookie/2')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Session is missing!');
# Text
@@ -810,8 +890,10 @@ $t->delete_ok('/something')->status_is(200)->header_is(Server => 'Mojolicious (P
# Only GET, POST and a custom request method
$t->get_ok('/something/else')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Yay!');
$t->post_ok('/something/else')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Yay!');
-$t->request_ok($t->ua->build_tx(WHATEVER => '/something/else'))->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('Yay!');
+$t->request_ok($t->ua->build_tx(WHATEVER => '/something/else'))
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('Yay!');
$t->delete_ok('/something/else')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Oops!/);
# Regex constraint
@@ -823,55 +905,91 @@ $t->post_ok('/bar')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->
$t->post_ok('/bar/baz')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('baz');
# Layout
-$t->get_ok('/layout')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/layout')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("LayoutYea baby! with layout\n");
# User agent condition
-$t->patch_ok('/firefox/bar' => {'User-Agent' => 'Firefox'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->patch_ok('/firefox/bar' => {'User-Agent' => 'Firefox'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/firefox/foo');
-$t->patch_ok('/firefox/bar' => {'User-Agent' => 'Explorer'})->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->patch_ok('/firefox/bar' => {'User-Agent' => 'Explorer'})
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Oops!/);
# URL for route with condition
$t->get_ok('/url_for_foxy')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('/firefox/%23test');
# UTF-8 form
-$t->post_ok('/utf8' => form => {name => 'табак'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 22)->content_type_is('text/html;charset=UTF-8')->content_is("табак ангел\n");
+$t->post_ok('/utf8' => form => {name => 'табак'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 22)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_is("табак ангел\n");
# UTF-8 "multipart/form-data" form
-$t->post_ok('/utf8' => {'Content-Type' => 'multipart/form-data'} => form => {name => 'табак'})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->header_is('Content-Length' => 22)
- ->content_type_is('text/html;charset=UTF-8')->content_is("табак ангел\n");
+$t->post_ok('/utf8' => {'Content-Type' => 'multipart/form-data'} => form => {name => 'табак'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 22)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_is("табак ангел\n");
# Malformed UTF-8
-$t->post_ok('/malformed_utf8' => {'Content-Type' => 'application/x-www-form-urlencoded'} => 'foo=%E1')->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('%E1');
+$t->post_ok('/malformed_utf8' => {'Content-Type' => 'application/x-www-form-urlencoded'} => 'foo=%E1')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('%E1');
# JSON (with a lot of different tests)
-$t->get_ok('/json')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('application/json;charset=UTF-8')->json_is({foo => [1, -2, 3, 'b☃r']})
- ->json_is('/foo' => [1, -2, 3, 'b☃r'])->json_is('/foo/3', 'b☃r', 'with description')->json_has('/foo')
- ->json_has('/foo', 'with description')->json_hasnt('/bar')->json_hasnt('/bar', 'with description')
- ->json_like('/foo/3' => qr/r$/)->json_like('/foo/3' => qr/r$/, 'with description')->json_unlike('/foo/3' => qr/b$/)
+$t->get_ok('/json')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({foo => [1, -2, 3, 'b☃r']})
+ ->json_is('/foo' => [1, -2, 3, 'b☃r'])
+ ->json_is('/foo/3', 'b☃r', 'with description')
+ ->json_has('/foo')
+ ->json_has('/foo', 'with description')
+ ->json_hasnt('/bar')
+ ->json_hasnt('/bar', 'with description')
+ ->json_like('/foo/3' => qr/r$/)
+ ->json_like('/foo/3' => qr/r$/, 'with description')
+ ->json_unlike('/foo/3' => qr/b$/)
->json_unlike('/foo/3' => qr/^r/, 'with description');
# JSON ("null")
-$t->get_ok('/json' => json => undef)->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('application/json;charset=UTF-8')->json_is(undef)->content_is('null');
+$t->get_ok('/json' => json => undef)
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is(undef)
+ ->content_is('null');
# Stash values in template
-$t->get_ok('/autostash?bar=23')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/autostash?bar=23')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("layouted bar\n23\n42\nautostash\n\n");
# Route without slash
-$t->get_ok('/app')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/app')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("app layout app23\ndevelopment\n");
# Helper
-$t->get_ok('/helper')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/helper')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("23\n
\n<...\n/template\n(Mojolicious (Perl))");
-$t->get_ok('/helper' => {'User-Agent' => 'Explorer'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/helper' => {'User-Agent' => 'Explorer'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("23\n
\n<...\n/template\n(Explorer)");
# Exception in EP template
@@ -882,25 +1000,38 @@ $t->get_ok('/subrequest')->status_is(200)->header_is(Server => 'Mojolicious (Per
$t->get_ok('/subrequest')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_is('Just works!');
# Non-blocking subrequest
-$t->get_ok('/subrequest_non_blocking')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/subrequest_non_blocking')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Just works!success!');
is $nb, 'broken!', 'right text';
# Redirect to URL
-$t->get_ok('/redirect_url')->status_is(302)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is(Location => 'http://127.0.0.1/foo')->content_is('');
+$t->get_ok('/redirect_url')
+ ->status_is(302)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(Location => 'http://127.0.0.1/foo')
+ ->content_is('');
# Redirect to path
-$t->get_ok('/redirect_path')->status_is(302)->header_is(Server => 'Mojolicious (Perl)')
- ->header_like(Location => qr!/foo/bar\?foo=bar$!)->content_is('');
+$t->get_ok('/redirect_path')
+ ->status_is(302)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_like(Location => qr!/foo/bar\?foo=bar$!)
+ ->content_is('');
# Redirect to named route
-$t->get_ok('/redirect_named')->status_is(302)->header_is(Server => 'Mojolicious (Perl)')
- ->header_like(Location => qr!/template.txt$!)->content_is('');
+$t->get_ok('/redirect_named')
+ ->status_is(302)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_like(Location => qr!/template.txt$!)
+ ->content_is('');
# Redirect twice
$t->ua->max_redirects(3);
-$t->get_ok('/redirect_twice')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/redirect_twice')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->text_is('div#☃' => 'Redirect works!');
my $redirects = $t->tx->redirects;
is scalar @$redirects, 2, 'two redirects';
@@ -909,18 +1040,33 @@ is $redirects->[1]->req->url->path, '/redirect_named', 'right path';
$t->ua->max_redirects(0);
# Non-blocking redirect
-$t->get_ok('/redirect_callback')->status_is(301)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 9)->header_is(Location => 'http://127.0.0.1/foo')->content_is('Whatever!');
+$t->get_ok('/redirect_callback')
+ ->status_is(301)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 9)
+ ->header_is(Location => 'http://127.0.0.1/foo')
+ ->content_is('Whatever!');
# Static file
-$t->get_ok('/static')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is('Content-Length' => 31)
+$t->get_ok('/static')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 31)
->content_is("Hello Mojo from a static file!\n");
# Redirect to named route with redirecting enabled in user agent
$t->ua->max_redirects(3);
-$t->get_ok('/redirect_named')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is(Location => undef)
- ->element_exists('#☃')->element_exists_not('#foo')->text_isnt('#foo' => 'whatever')->text_isnt('div#☃' => 'Redirect')
- ->text_is('div#☃' => 'Redirect works!')->text_unlike('div#☃' => qr/Foo/)->text_like('div#☃' => qr/^Redirect/);
+$t->get_ok('/redirect_named')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(Location => undef)
+ ->element_exists('#☃')
+ ->element_exists_not('#foo')
+ ->text_isnt('#foo' => 'whatever')
+ ->text_isnt('div#☃' => 'Redirect')
+ ->text_is('div#☃' => 'Redirect works!')
+ ->text_unlike('div#☃' => qr/Foo/)
+ ->text_like('div#☃' => qr/^Redirect/);
$t->ua->max_redirects(0);
is $t->tx->previous->res->code, 302, 'right status';
like $t->tx->previous->res->headers->location, qr!/template.txt$!, 'right "Location" value';
@@ -931,11 +1077,16 @@ my $koi8
= 'Этот человек наполняет меня надеждой.'
. ' Ну, и некоторыми другими глубокими и приводящими в'
. ' замешательство эмоциями.';
-$t->get_ok('/koi8-r')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('text/html; charset=koi8-r')->content_like(qr/^$koi8/);
+$t->get_ok('/koi8-r')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/html; charset=koi8-r')
+ ->content_like(qr/^$koi8/);
# Custom condition
-$t->get_ok('/default/condition')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/default/condition')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('works 23 condition23 works!');
# Placeholder type
@@ -947,19 +1098,32 @@ $t->get_ok('/type/56')->status_is(200)->header_is(Server => 'Mojolicious (Perl)'
$t->get_ok('/type/12')->status_is(404)->header_is(Server => 'Mojolicious (Perl)');
# Redirect from condition
-$t->get_ok('/redirect/condition/0')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/redirect/condition/0')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('condition works!');
-$t->get_ok('/redirect/condition/1')->status_is(302)->header_is(Server => 'Mojolicious (Perl)')
- ->header_like('Location' => qr!/template$!)->content_is('');
-$t->get_ok('/redirect/condition/1' => {'X-Condition-Test' => 1})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('condition works too!');
+$t->get_ok('/redirect/condition/1')
+ ->status_is(302)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_like('Location' => qr!/template$!)
+ ->content_is('');
+$t->get_ok('/redirect/condition/1' => {'X-Condition-Test' => 1})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('condition works too!');
# Multiple placeholders
-$t->get_ok('/captures/foo/bar')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/captures/foo/bar')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/captures/foo/bar');
-$t->get_ok('/captures/bar/baz')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/captures/bar/baz')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/captures/bar/baz');
-$t->get_ok('/captures/♥/☃')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/captures/♥/☃')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('/captures/%E2%99%A5/%E2%98%83');
is b($t->tx->res->body)->url_unescape->decode('UTF-8'), '/captures/♥/☃', 'right result';
@@ -980,7 +1144,8 @@ $t->get_ok('/dynamic/inline')->status_is(200)->content_is("dynamic inline 1\n");
$t->get_ok('/dynamic/inline')->status_is(200)->content_is("dynamic inline 2\n");
# Timing
-$t->get_ok('/timing')->status_is(200)
+$t->get_ok('/timing')
+ ->status_is(200)
->header_like('Server-Timing' => qr/miss, dc;desc="atl", test;desc="Some Test";dur=0.002, app;dur=0.001/)
->content_like(qr/Foo: [0-9.]+, Bar: [0-9.]+ \([0-9.?]+\)/);
is $t->app->timing->elapsed('does_not_exist'), undef, 'no timing data';
diff --git a/t/mojolicious/longpolling_lite_app.t b/t/mojolicious/longpolling_lite_app.t
index 998acab088..a05573b0d7 100644
--- a/t/mojolicious/longpolling_lite_app.t
+++ b/t/mojolicious/longpolling_lite_app.t
@@ -163,7 +163,10 @@ subtest 'Stream without delay and finish' => sub {
my $logs = $t->app->log->capture('trace');
my $stash;
$t->app->plugins->once(before_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/write')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_type_is('text/plain')
+ $t->get_ok('/write')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/plain')
->content_is('this was short.');
Mojo::IOLoop->one_tick until $stash->{finished};
ok !$t->tx->kept_alive, 'connection was not kept alive';
@@ -175,15 +178,21 @@ subtest 'Stream without delay and finish' => sub {
};
subtest 'Stream without delay and content length' => sub {
- $t->get_ok('/write/length')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_type_is('text/plain')
+ $t->get_ok('/write/length')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/plain')
->content_is('this was short and plain.');
ok !$t->tx->kept_alive, 'connection was not kept alive';
ok $t->tx->keep_alive, 'connection will be kept alive';
};
subtest 'Stream without delay and empty write' => sub {
- $t->get_ok('/write/nolength')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => undef)->content_type_is('text/plain')
+ $t->get_ok('/write/nolength')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => undef)
+ ->content_type_is('text/plain')
->content_is('this was short and had no length.');
ok $t->tx->kept_alive, 'connection was kept alive';
ok !$t->tx->keep_alive, 'connection will not be kept alive';
@@ -192,8 +201,11 @@ subtest 'Stream without delay and empty write' => sub {
subtest 'Chunked response with delay' => sub {
my $stash = undef;
$t->app->plugins->once(before_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/longpoll/chunked')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('text/plain')->content_is('hi there, whats up?');
+ $t->get_ok('/longpoll/chunked')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/plain')
+ ->content_is('hi there, whats up?');
Mojo::IOLoop->one_tick until $stash->{finished};
ok !$t->tx->kept_alive, 'connection was not kept alive';
ok $t->tx->keep_alive, 'connection will be kept alive';
@@ -236,37 +248,53 @@ subtest 'Interrupted by raising an error' => sub {
subtest 'Stream with delay and content length' => sub {
my $stash = undef;
$t->app->plugins->once(before_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/longpoll/length')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->content_type_is('text/plain')->content_is('hi there plain, whats up?');
+ $t->get_ok('/longpoll/length')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/plain')
+ ->content_is('hi there plain, whats up?');
is $stash->{drain}, 1, 'drain event has been emitted once';
};
subtest 'Stream with delay and finish' => sub {
- $t->get_ok('/longpoll/nolength')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => undef)->content_type_is('text/plain')->content_is('hi there, what length?');
+ $t->get_ok('/longpoll/nolength')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => undef)
+ ->content_type_is('text/plain')
+ ->content_is('hi there, what length?');
ok !$t->tx->keep_alive, 'connection will not be kept alive';
};
subtest 'The drain event should be emitted on the next reactor tick' => sub {
my $stash = undef;
$t->app->plugins->once(before_dispatch => sub { $stash = shift->stash });
- $t->get_ok('/longpoll/order')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/longpoll/order')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('First, second, third!');
is $stash->{order}, 1, 'the drain event was emitted on the next reactor tick';
};
subtest 'Static file with cookies and session' => sub {
my $logs = $t->app->log->capture('trace');
- $t->get_ok('/longpoll/static')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_like('Set-Cookie' => qr/bar=baz/)->header_like('Set-Cookie' => qr/mojolicious=/)
- ->content_type_is('text/plain;charset=UTF-8')->content_is("Hello Mojo from a static file!\n");
+ $t->get_ok('/longpoll/static')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_like('Set-Cookie' => qr/bar=baz/)
+ ->header_like('Set-Cookie' => qr/mojolicious=/)
+ ->content_type_is('text/plain;charset=UTF-8')
+ ->content_is("Hello Mojo from a static file!\n");
like $logs, qr/Nothing has been rendered, expecting delayed response/, 'right message';
undef $logs;
};
subtest 'Custom response' => sub {
- $t->get_ok('/longpoll/dynamic')->status_is(201)->header_is(Server => 'Mojolicious (Perl)')
- ->header_like('Set-Cookie' => qr/baz=yada/)->content_is('Dynamic!');
+ $t->get_ok('/longpoll/dynamic')
+ ->status_is(201)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_like('Set-Cookie' => qr/baz=yada/)
+ ->content_is('Dynamic!');
};
subtest 'Chunked response streaming with drain event' => sub {
diff --git a/t/mojolicious/multipath_lite_app.t b/t/mojolicious/multipath_lite_app.t
index 948a685bdf..4bd930fda6 100644
--- a/t/mojolicious/multipath_lite_app.t
+++ b/t/mojolicious/multipath_lite_app.t
@@ -25,17 +25,23 @@ subtest '"templates" directory' => sub {
};
subtest '"templates2" directory' => sub {
- $t->get_ok('/fourty_two')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/fourty_two')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("The answer is 42.\n");
};
subtest '"templates2" directory (variant)' => sub {
- $t->get_ok('/fourty_two_again')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/fourty_two_again')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("The answer is 43!\n");
};
subtest '"public2" directory' => sub {
- $t->get_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Also higher precedence!\n");
};
@@ -44,7 +50,9 @@ subtest '"public" directory' => sub {
};
subtest '"public2" directory' => sub {
- $t->get_ok('/hello3.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/hello3.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Hello Mojo from... ALL GLORY TO THE HYPNOTOAD!\n");
};
diff --git a/t/mojolicious/production_app.t b/t/mojolicious/production_app.t
index e003bd3dc7..1e88f108d9 100644
--- a/t/mojolicious/production_app.t
+++ b/t/mojolicious/production_app.t
@@ -35,67 +35,99 @@ is $t->app->static->file('mojo/jquery/jquery.js'), undef, 'no jQuery';
is_deeply $t->app->routes->namespaces, ['MojoliciousTest::Controller', 'MojoliciousTest'], 'right namespaces';
# Plugin::Test::SomePlugin2::register (security violation)
-$t->get_ok('/plugin-test-some_plugin2/register')->status_isnt(404)->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Not development mode error!/);
+$t->get_ok('/plugin-test-some_plugin2/register')
+ ->status_isnt(404)
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Not development mode error!/);
# Plugin::Test::SomePlugin2::register (security violation again)
-$t->get_ok('/plugin-test-some_plugin2/register')->status_isnt(404)->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Not development mode error!/);
+$t->get_ok('/plugin-test-some_plugin2/register')
+ ->status_isnt(404)
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Not development mode error!/);
# SyntaxError::foo in production mode (syntax error in controller)
-$t->get_ok('/syntax_error/foo')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/syntax_error/foo')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# Foo::syntaxerror in production mode (syntax error in template)
-$t->get_ok('/foo/syntaxerror')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/syntaxerror')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# Exceptional::this_one_dies (action dies)
-$t->get_ok('/exceptional/this_one_dies')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional/this_one_dies')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# Exceptional::this_one_might_die (bridge dies)
-$t->get_ok('/exceptional_too/this_one_dies')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional_too/this_one_dies')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# Exceptional::this_one_might_die (action dies)
-$t->get_ok('/exceptional_too/this_one_dies' => {'X-DoNotDie' => 1})->status_is(500)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Not development mode error!/);
+$t->get_ok('/exceptional_too/this_one_dies' => {'X-DoNotDie' => 1})
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Not development mode error!/);
# Exceptional::this_one_does_not_exist (action does not exist)
-$t->get_ok('/exceptional/this_one_does_not_exist')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/exceptional/this_one_does_not_exist')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Exceptional::this_one_does_not_exist (action behind bridge does not exist)
-$t->get_ok('/exceptional_too/this_one_does_not_exist' => {'X-DoNotDie' => 1})->status_is(404)
- ->header_is(Server => 'Mojolicious (Perl)')->content_like(qr/Page Not Found/);
+$t->get_ok('/exceptional_too/this_one_does_not_exist' => {'X-DoNotDie' => 1})
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_like(qr/Page Not Found/);
# Static file /hello.txt in production mode
-$t->get_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Hello Mojo from a static file!/);
# Foo::bar in production mode (missing action)
-$t->get_ok('/foo/baz')->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/foo/baz')
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# Try to access a file which is not under the web root via path traversal in
# production mode
-$t->get_ok('/../../mojolicious/secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/../../mojolicious/secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal in
# production mode (triple dot)
-$t->get_ok('/.../mojolicious/secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/.../mojolicious/secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal in
# production mode (backslashes)
-$t->get_ok('/..\\..\\mojolicious\\secret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/..\\..\\mojolicious\\secret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Try to access a file which is not under the web root via path traversal in
# production mode (escaped backslashes)
-$t->get_ok('/..%5C..%5Cmojolicious%5Csecret.txt')->status_is(404)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/..%5C..%5Cmojolicious%5Csecret.txt')
+ ->status_is(404)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Page Not Found/);
# Check that backslashes in query or fragment parts don't block access in
@@ -103,19 +135,27 @@ $t->get_ok('/..%5C..%5Cmojolicious%5Csecret.txt')->status_is(404)->header_is(Ser
$t->get_ok('/hello.txt?one=\\1#two=\\2')->status_is(200)->content_like(qr/Hello Mojo from a static file!/);
# Embedded production static file
-$t->get_ok('/some/static/file.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/some/static/file.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Production static file with low precedence.\n\n");
# Embedded production template
-$t->get_ok('/just/some/template')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/just/some/template')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("Production template with low precedence.\n");
# MojoliciousTest3::Bar::index (controller class in development namespace)
-$t->get_ok('/test9' => {'X-Test' => 'Hi there!'})->status_is(500)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test9' => {'X-Test' => 'Hi there!'})
+ ->status_is(500)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/Not development mode error!/);
# MojoliciousTest::Baz::index (controller class precedence)
-$t->get_ok('/test10')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+$t->get_ok('/test10')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('Production namespace has low precedence!');
done_testing();
diff --git a/t/mojolicious/proxy_app.t b/t/mojolicious/proxy_app.t
index f9c1c21e0a..7e1f4d25d9 100644
--- a/t/mojolicious/proxy_app.t
+++ b/t/mojolicious/proxy_app.t
@@ -122,52 +122,108 @@ get '/proxy3/:method/*target' => sub {
my $t = Test::Mojo->new;
subtest 'Various response variants' => sub {
- $t->get_ok('/proxy1/size/200/2')->status_is(200)->header_is('X-Mojo-App' => 'Size')->header_is('Content-Length' => 2)
+ $t->get_ok('/proxy1/size/200/2')
+ ->status_is(200)
+ ->header_is('X-Mojo-App' => 'Size')
+ ->header_is('Content-Length' => 2)
->content_is('xx');
- $t->get_ok('/proxy1/size/200/1')->status_is(200)->header_is('X-Mojo-App' => 'Size')->header_is('Content-Length' => 1)
+ $t->get_ok('/proxy1/size/200/1')
+ ->status_is(200)
+ ->header_is('X-Mojo-App' => 'Size')
+ ->header_is('Content-Length' => 1)
->content_is('x');
- $t->get_ok('/proxy1/size/200/0')->status_is(200)->header_is('X-Mojo-App' => 'Size')->header_is('Content-Length' => 0)
+ $t->get_ok('/proxy1/size/200/0')
+ ->status_is(200)
+ ->header_is('X-Mojo-App' => 'Size')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/size/204/0')
+ ->status_is(204)
+ ->header_is('X-Mojo-App' => 'Size')
+ ->header_is('Content-Length' => undef)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/304/200/1')
+ ->status_is(304)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => undef)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/302/200/1')
+ ->status_is(302)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/301/200/1')
+ ->status_is(301)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/304/200/0')
+ ->status_is(304)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => undef)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/302/200/0')
+ ->status_is(302)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/301/200/0')
+ ->status_is(301)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/304/204/0')
+ ->status_is(304)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => undef)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/302/204/0')
+ ->status_is(302)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
+ ->content_is('');
+ $t->get_ok('/proxy1/redirect/301/204/0')
+ ->status_is(301)
+ ->header_is('X-Mojo-App' => 'Redirect')
+ ->header_is('Content-Length' => 0)
->content_is('');
- $t->get_ok('/proxy1/size/204/0')->status_is(204)->header_is('X-Mojo-App' => 'Size')
- ->header_is('Content-Length' => undef)->content_is('');
- $t->get_ok('/proxy1/redirect/304/200/1')->status_is(304)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => undef)->content_is('');
- $t->get_ok('/proxy1/redirect/302/200/1')->status_is(302)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
- $t->get_ok('/proxy1/redirect/301/200/1')->status_is(301)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
- $t->get_ok('/proxy1/redirect/304/200/0')->status_is(304)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => undef)->content_is('');
- $t->get_ok('/proxy1/redirect/302/200/0')->status_is(302)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
- $t->get_ok('/proxy1/redirect/301/200/0')->status_is(301)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
- $t->get_ok('/proxy1/redirect/304/204/0')->status_is(304)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => undef)->content_is('');
- $t->get_ok('/proxy1/redirect/302/204/0')->status_is(302)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
- $t->get_ok('/proxy1/redirect/301/204/0')->status_is(301)->header_is('X-Mojo-App' => 'Redirect')
- ->header_is('Content-Length' => 0)->content_is('');
$t->get_ok('/proxy1/res1')->status_is(200)->header_is('X-Mojo-App' => 'One')->content_is('One!');
$t->get_ok('/proxy1/res2')->status_is(200)->header_is('X-Mojo-App' => 'Two')->content_is('Two!');
- $t->get_ok('/proxy1/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')->header_is('X-Mojo-Method' => 'GET')
- ->header_is('X-Mojo-More' => '')->header_is('X-Mojo-Body' => 0)->content_is('Three!');
+ $t->get_ok('/proxy1/res3')
+ ->status_is(200)
+ ->header_is('X-Mojo-App' => 'Three')
+ ->header_is('X-Mojo-Method' => 'GET')
+ ->header_is('X-Mojo-More' => '')
+ ->header_is('X-Mojo-Body' => 0)
+ ->content_is('Three!');
$t->get_ok('/proxy1/res4')->status_is(204)->header_is('X-Mojo-App' => 'Four')->content_is('');
$t->get_ok('/proxy1/res5')->status_is(400)->content_like(qr/Error: /);
$t->get_ok('/proxy1/res6')->status_is(200)->content_is('Six!');
};
subtest 'Custom request' => sub {
- $t->patch_ok('/proxy2/res3')->status_is(200)->header_is('X-Mojo-App' => 'Three')
- ->header_is('X-Mojo-Method' => 'POST')->header_is('X-Mojo-More' => 'Less')->header_is('X-Mojo-Body' => 6)
+ $t->patch_ok('/proxy2/res3')
+ ->status_is(200)
+ ->header_is('X-Mojo-App' => 'Three')
+ ->header_is('X-Mojo-Method' => 'POST')
+ ->header_is('X-Mojo-More' => 'Less')
+ ->header_is('X-Mojo-Body' => 6)
->content_is('Three!');
};
subtest 'Response modification' => sub {
- $t->get_ok('/proxy3/GET/res1')->status_is(200)->header_exists_not('X-Mojo-App')->header_is('X-Mojo-Proxy1' => 'just')
- ->header_is('X-Mojo-Proxy2' => 'works!')->content_is('One!');
- $t->get_ok('/proxy3/POST/res3')->status_is(200)->header_is('X-Mojo-Method' => 'POST')
- ->header_exists_not('X-Mojo-App')->header_is('X-Mojo-Proxy1' => 'just')->header_is('X-Mojo-Proxy2' => 'works!')
+ $t->get_ok('/proxy3/GET/res1')
+ ->status_is(200)
+ ->header_exists_not('X-Mojo-App')
+ ->header_is('X-Mojo-Proxy1' => 'just')
+ ->header_is('X-Mojo-Proxy2' => 'works!')
+ ->content_is('One!');
+ $t->get_ok('/proxy3/POST/res3')
+ ->status_is(200)
+ ->header_is('X-Mojo-Method' => 'POST')
+ ->header_exists_not('X-Mojo-App')
+ ->header_is('X-Mojo-Proxy1' => 'just')
+ ->header_is('X-Mojo-Proxy2' => 'works!')
->content_is('Three!');
};
diff --git a/t/mojolicious/restful_lite_app.t b/t/mojolicious/restful_lite_app.t
index 99d7f889c5..9d7e5d30d6 100644
--- a/t/mojolicious/restful_lite_app.t
+++ b/t/mojolicious/restful_lite_app.t
@@ -50,8 +50,10 @@ subtest 'Hash without format' => sub {
};
subtest 'Hash with "json" format' => sub {
- $t->post_ok('/json/echo' => {Accept => 'application/json'} => json => {hello => 'world'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({hello => 'world'});
+ $t->post_ok('/json/echo' => {Accept => 'application/json'} => json => {hello => 'world'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({hello => 'world'});
my $tx = $t->ua->build_tx(PUT => '/json/echo' => {Accept => 'application/json'} => json => {hello => 'world'});
$t->request_ok($tx)->status_is(200)->content_type_is('application/json;charset=UTF-8')->json_is({hello => 'world'});
};
@@ -99,7 +101,8 @@ subtest 'Accept "json"' => sub {
subtest 'Ajax' => sub {
my $ajax = 'text/html;q=0.1,application/json';
- $t->get_ok('/accepts' => {Accept => $ajax, 'X-Requested-With' => 'XMLHttpRequest'})->status_is(200)
+ $t->get_ok('/accepts' => {Accept => $ajax, 'X-Requested-With' => 'XMLHttpRequest'})
+ ->status_is(200)
->json_is({best => 'json'});
};
@@ -112,88 +115,122 @@ subtest '"html" format' => sub {
};
subtest 'Accept "html"' => sub {
- $t->get_ok('/rest' => {Accept => 'text/html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'Accept "html" again' => sub {
- $t->get_ok('/rest' => {Accept => 'Text/Html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest' => {Accept => 'Text/Html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'Accept "html" with format' => sub {
- $t->get_ok('/rest.html' => {Accept => 'text/html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest.html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'Accept "html" with quality' => sub {
- $t->get_ok('/rest' => {Accept => 'text/html;q=9'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest' => {Accept => 'text/html;q=9'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest '"html" query' => sub {
- $t->get_ok('/rest?_format=html')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest?_format=html')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest '"html" format with query' => sub {
- $t->get_ok('/rest.html?_format=html')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest.html?_format=html')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'Accept "html" with query' => sub {
- $t->get_ok('/rest?_format=html' => {Accept => 'text/html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works');
+ $t->get_ok('/rest?_format=html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works');
};
subtest 'Accept "html" with everything' => sub {
- $t->get_ok('/rest.html?_format=html' => {Accept => 'text/html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works');
+ $t->get_ok('/rest.html?_format=html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works');
};
subtest '"json" format' => sub {
- $t->get_ok('/rest.json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/rest.json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works'});
};
subtest 'Accept "json"' => sub {
- $t->get_ok('/rest' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest 'Accept "json" again' => sub {
- $t->get_ok('/rest' => {Accept => 'APPLICATION/JSON'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest' => {Accept => 'APPLICATION/JSON'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest 'Accept "json" with format' => sub {
- $t->get_ok('/rest.json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest.json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest 'Accept "json" with quality' => sub {
- $t->get_ok('/rest' => {Accept => 'application/json;q=9'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest' => {Accept => 'application/json;q=9'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest '"json" query' => sub {
- $t->get_ok('/rest?_format=json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/rest?_format=json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works'});
};
subtest '"json" format with query' => sub {
- $t->get_ok('/rest.json?_format=json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->get_ok('/rest.json?_format=json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works'});
};
subtest 'Accept "json" with query' => sub {
- $t->get_ok('/rest?_format=json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest?_format=json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest 'Accept "json" with everything' => sub {
- $t->get_ok('/rest.json?_format=json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest.json?_format=json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
subtest '"xml" format' => sub {
@@ -201,22 +238,30 @@ subtest '"xml" format' => sub {
};
subtest 'Accept "xml"' => sub {
- $t->get_ok('/rest' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->get_ok('/rest' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works');
};
subtest 'Accept "xml" again' => sub {
- $t->get_ok('/rest' => {Accept => 'APPLICATION/XML'})->status_is(200)->content_type_is('application/xml')
+ $t->get_ok('/rest' => {Accept => 'APPLICATION/XML'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works');
};
subtest 'Accept "xml" with format' => sub {
- $t->get_ok('/rest.xml' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->get_ok('/rest.xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works');
};
subtest 'Accept "xml" with quality' => sub {
- $t->get_ok('/rest' => {Accept => 'application/xml;q=9'})->status_is(200)->content_type_is('application/xml')
+ $t->get_ok('/rest' => {Accept => 'application/xml;q=9'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works');
};
@@ -229,13 +274,17 @@ subtest '"xml" format with query' => sub {
};
subtest 'Accept "json" with query' => sub {
- $t->get_ok('/rest?_format=xml' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->get_ok('/rest?_format=xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works');
};
subtest 'Accept "json" with everything' => sub {
- $t->get_ok('/rest.xml?_format=xml' => {Accept => 'application/xml'})->status_is(200)
- ->content_type_is('application/xml')->text_is(just => 'works');
+ $t->get_ok('/rest.xml?_format=xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
+ ->text_is(just => 'works');
};
subtest 'Unsupported accept' => sub {
@@ -247,133 +296,185 @@ subtest 'Nothing' => sub {
};
subtest '"html" format' => sub {
- $t->post_ok('/rest.html')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest.html')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept "html"' => sub {
- $t->post_ok('/rest' => {Accept => 'text/html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept "html" again' => sub {
- $t->post_ok('/rest' => {Accept => 'Text/Html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest' => {Accept => 'Text/Html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept "html" with format' => sub {
- $t->post_ok('/rest.html' => {Accept => 'text/html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest.html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept "html" with quality' => sub {
- $t->post_ok('/rest' => {Accept => 'text/html;q=9'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest' => {Accept => 'text/html;q=9'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest '"html" query' => sub {
- $t->post_ok('/rest?_format=html')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest?_format=html')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest '"html" format with query' => sub {
- $t->post_ok('/rest.html?_format=html')->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest.html?_format=html')
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept html with query' => sub {
- $t->post_ok('/rest?_format=html' => {Accept => 'text/html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works too');
+ $t->post_ok('/rest?_format=html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works too');
};
subtest 'Accept "html" with everything' => sub {
- $t->post_ok('/rest.html?_format=html' => {Accept => 'text/html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works too');
+ $t->post_ok('/rest.html?_format=html' => {Accept => 'text/html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works too');
};
subtest '"html" form' => sub {
- $t->post_ok('/rest' => form => {_format => 'html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest' => form => {_format => 'html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest '"html" format with form' => sub {
- $t->post_ok('/rest.html' => form => {_format => 'html'})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest.html' => form => {_format => 'html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works too');
};
subtest 'Accept "html" with form' => sub {
- $t->post_ok('/rest' => {Accept => 'text/html'} => form => {_format => 'html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works too');
+ $t->post_ok('/rest' => {Accept => 'text/html'} => form => {_format => 'html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works too');
};
subtest 'Accept "html" with everything, form alternative' => sub {
- $t->post_ok('/rest.html' => {Accept => 'text/html'} => form => {_format => 'html'})->status_is(200)
- ->content_type_is('text/html;charset=UTF-8')->text_is('html > body', 'works too');
+ $t->post_ok('/rest.html' => {Accept => 'text/html'} => form => {_format => 'html'})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->text_is('html > body', 'works too');
};
subtest '"json" format' => sub {
- $t->post_ok('/rest.json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->post_ok('/rest.json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works too'});
};
subtest 'Accept "json"' => sub {
- $t->post_ok('/rest' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" again' => sub {
- $t->post_ok('/rest' => {Accept => 'APPLICATION/JSON'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest' => {Accept => 'APPLICATION/JSON'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" with format' => sub {
- $t->post_ok('/rest.json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest.json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" with quality' => sub {
- $t->post_ok('/rest' => {Accept => 'application/json;q=9'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest' => {Accept => 'application/json;q=9'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest '"json" query' => sub {
- $t->post_ok('/rest?_format=json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->post_ok('/rest?_format=json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works too'});
};
subtest '"json" format with query' => sub {
- $t->post_ok('/rest.json?_format=json')->status_is(200)->content_type_is('application/json;charset=UTF-8')
+ $t->post_ok('/rest.json?_format=json')
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
->json_is({just => 'works too'});
};
subtest 'Accept "json" with query' => sub {
- $t->post_ok('/rest?_format=json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest?_format=json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" with everything' => sub {
- $t->post_ok('/rest.json?_format=json' => {Accept => 'application/json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest.json?_format=json' => {Accept => 'application/json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest '"json" form' => sub {
- $t->post_ok('/rest' => form => {_format => 'json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest' => form => {_format => 'json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest '"json" format with form' => sub {
- $t->post_ok('/rest.json' => form => {_format => 'json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest.json' => form => {_format => 'json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" with form' => sub {
- $t->post_ok('/rest' => {Accept => 'application/json'} => form => {_format => 'json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest' => {Accept => 'application/json'} => form => {_format => 'json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest 'Accept "json" with everything, form alternative' => sub {
- $t->post_ok('/rest.json' => {Accept => 'application/json'} => form => {_format => 'json'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works too'});
+ $t->post_ok('/rest.json' => {Accept => 'application/json'} => form => {_format => 'json'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works too'});
};
subtest '"xml" format' => sub {
@@ -381,22 +482,30 @@ subtest '"xml" format' => sub {
};
subtest 'Accept "xml"' => sub {
- $t->post_ok('/rest' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "xml" again' => sub {
- $t->post_ok('/rest' => {Accept => 'APPLICATION/XML'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest' => {Accept => 'APPLICATION/XML'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "xml" with format' => sub {
- $t->post_ok('/rest.xml' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest.xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "xml" with quality' => sub {
- $t->post_ok('/rest' => {Accept => 'application/xml;q=9'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest' => {Accept => 'application/xml;q=9'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
@@ -405,48 +514,66 @@ subtest '"xml" query' => sub {
};
subtest '"xml" format with query' => sub {
- $t->post_ok('/rest.xml?_format=xml')->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest.xml?_format=xml')
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "json" with query' => sub {
- $t->post_ok('/rest?_format=xml' => {Accept => 'application/xml'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest?_format=xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "json" with everything' => sub {
- $t->post_ok('/rest.xml?_format=xml' => {Accept => 'application/xml'})->status_is(200)
- ->content_type_is('application/xml')->text_is(just => 'works too');
+ $t->post_ok('/rest.xml?_format=xml' => {Accept => 'application/xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
+ ->text_is(just => 'works too');
};
subtest '"xml" form' => sub {
- $t->post_ok('/rest' => form => {_format => 'xml'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest' => form => {_format => 'xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest '"xml" format with form' => sub {
- $t->post_ok('/rest.xml' => form => {_format => 'xml'})->status_is(200)->content_type_is('application/xml')
+ $t->post_ok('/rest.xml' => form => {_format => 'xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
->text_is(just => 'works too');
};
subtest 'Accept "json" with form' => sub {
- $t->post_ok('/rest' => {Accept => 'application/xml'} => form => {_format => 'xml'})->status_is(200)
- ->content_type_is('application/xml')->text_is(just => 'works too');
+ $t->post_ok('/rest' => {Accept => 'application/xml'} => form => {_format => 'xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
+ ->text_is(just => 'works too');
};
subtest 'Accept "json" with everything, form alternative' => sub {
- $t->post_ok('/rest.xml' => {Accept => 'application/xml'} => form => {_format => 'xml'})->status_is(200)
- ->content_type_is('application/xml')->text_is(just => 'works too');
+ $t->post_ok('/rest.xml' => {Accept => 'application/xml'} => form => {_format => 'xml'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
+ ->text_is(just => 'works too');
};
subtest 'Unsupported accept' => sub {
- $t->post_ok('/rest' => {Accept => 'image/png'})->status_is(201)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest' => {Accept => 'image/png'})
+ ->status_is(201)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is('works too');
};
subtest 'Unsupported everything' => sub {
- $t->post_ok('/rest.png?_format=jpg' => {Accept => 'image/whatever'})->status_is(201)
- ->content_type_is('text/html;charset=UTF-8')->content_is('works too');
+ $t->post_ok('/rest.png?_format=jpg' => {Accept => 'image/whatever'})
+ ->status_is(201)
+ ->content_type_is('text/html;charset=UTF-8')
+ ->content_is('works too');
};
subtest 'Unsupported format' => sub {
@@ -454,7 +581,9 @@ subtest 'Unsupported format' => sub {
};
subtest 'Unsupported format and query' => sub {
- $t->post_ok('/rest.png?_format=png')->status_is(201)->content_type_is('text/html;charset=UTF-8')
+ $t->post_ok('/rest.png?_format=png')
+ ->status_is(201)
+ ->content_type_is('text/html;charset=UTF-8')
->content_is('works too');
};
@@ -464,26 +593,34 @@ subtest 'Does not exist' => sub {
subtest 'Ajax' => sub {
my $ajax = 'text/html;q=0.1,application/xml';
- $t->get_ok('/rest' => {Accept => $ajax, 'X-Requested-With' => 'XMLHttpRequest'})->status_is(200)
- ->content_type_is('application/xml')->text_is(just => 'works');
+ $t->get_ok('/rest' => {Accept => $ajax, 'X-Requested-With' => 'XMLHttpRequest'})
+ ->status_is(200)
+ ->content_type_is('application/xml')
+ ->text_is(just => 'works');
};
subtest 'Chrome 64' => sub {
my $chrome = 'text/html,application/xhtml+xml,application/xml;q=0.9' . ',image/webp,image/apng,*/*;q=0.8';
- $t->get_ok('/rest.html' => {Accept => $chrome})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest.html' => {Accept => $chrome})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'Chrome 11 with query' => sub {
my $chrome = 'text/html,application/xhtml+xml,application/xml;q=0.9' . ',image/webp,image/apng,*/*;q=0.8';
- $t->get_ok('/rest?_format=html' => {Accept => $chrome})->status_is(200)->content_type_is('text/html;charset=UTF-8')
+ $t->get_ok('/rest?_format=html' => {Accept => $chrome})
+ ->status_is(200)
+ ->content_type_is('text/html;charset=UTF-8')
->text_is('html > body', 'works');
};
subtest 'jQuery 1.8' => sub {
my $jquery = 'application/json, text/javascript, */*; q=0.01';
- $t->get_ok('/rest' => {Accept => $jquery, 'X-Requested-With' => 'XMLHttpRequest'})->status_is(200)
- ->content_type_is('application/json;charset=UTF-8')->json_is({just => 'works'});
+ $t->get_ok('/rest' => {Accept => $jquery, 'X-Requested-With' => 'XMLHttpRequest'})
+ ->status_is(200)
+ ->content_type_is('application/json;charset=UTF-8')
+ ->json_is({just => 'works'});
};
done_testing();
diff --git a/t/mojolicious/routes.t b/t/mojolicious/routes.t
index 1ff43ef2bf..ebf845a939 100644
--- a/t/mojolicious/routes.t
+++ b/t/mojolicious/routes.t
@@ -120,11 +120,13 @@ $r->any('/type/')->to('foo#bar');
# /articles/1/delete.json
my $inline = $r->any('/articles/:id')->inline(1)->to(testcase => 'articles', action => 'load', format => 'html');
$inline->any('/edit')->to(testcase => 'articles', action => 'edit');
-$inline->any('/delete', [format => ['json']])->to(testcase => 'articles', action => 'delete', format => undef)
+$inline->any('/delete', [format => ['json']])
+ ->to(testcase => 'articles', action => 'delete', format => undef)
->name('articles_delete');
# GET /method/get
-$r->any('/method/get', [format => ['html']])->methods('GET')
+$r->any('/method/get', [format => ['html']])
+ ->methods('GET')
->to(testcase => 'method', action => 'get', format => undef);
# POST /method/post
diff --git a/t/mojolicious/static_lite_app.t b/t/mojolicious/static_lite_app.t
index 00f5ac14e2..7e6914168f 100644
--- a/t/mojolicious/static_lite_app.t
+++ b/t/mojolicious/static_lite_app.t
@@ -104,8 +104,12 @@ subtest 'Freshness (multiple Etag values)' => sub {
subtest 'Static file' => sub {
my $logs = $t->app->log->capture('trace');
- $t->get_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_exists_not('Cache-Control')->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 31)
+ $t->get_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_exists_not('Cache-Control')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 31)
->content_is("Hello Mojo from a static file!\n");
like $logs, qr/Static file served/, 'right message';
unlike $logs, qr/200 OK/, 'no status message';
@@ -113,13 +117,20 @@ subtest 'Static file' => sub {
};
subtest 'Static file (HEAD)' => sub {
- $t->head_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 31)->content_is('');
+ $t->head_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 31)
+ ->content_is('');
};
subtest 'Route for method other than GET and HEAD' => sub {
- $t->options_ok('/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 8)->content_is('Options!');
+ $t->options_ok('/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 8)
+ ->content_is('Options!');
};
subtest 'Unknown method' => sub {
@@ -127,89 +138,154 @@ subtest 'Unknown method' => sub {
};
subtest 'Partial static file' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=2-8'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_exists_not('Cache-Control')->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 7)
- ->header_is('Content-Range' => 'bytes 2-8/31')->content_is('llo Moj');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=2-8'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_exists_not('Cache-Control')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 7)
+ ->header_is('Content-Range' => 'bytes 2-8/31')
+ ->content_is('llo Moj');
};
subtest 'Partial static file, no end' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=8-'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 23)
- ->header_is('Content-Range' => 'bytes 8-30/31')->content_is("jo from a static file!\n");
+ $t->get_ok('/hello.txt' => {Range => 'bytes=8-'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 23)
+ ->header_is('Content-Range' => 'bytes 8-30/31')
+ ->content_is("jo from a static file!\n");
};
subtest 'Partial static file, no start' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=-8'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 9)
- ->header_is('Content-Range' => 'bytes 0-8/31')->content_is('Hello Moj');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=-8'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 9)
+ ->header_is('Content-Range' => 'bytes 0-8/31')
+ ->content_is('Hello Moj');
};
subtest 'Partial static file, starting at first byte' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=0-8'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 9)
- ->header_is('Content-Range' => 'bytes 0-8/31')->content_is('Hello Moj');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=0-8'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 9)
+ ->header_is('Content-Range' => 'bytes 0-8/31')
+ ->content_is('Hello Moj');
};
subtest 'Partial static file, invalid range' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=8-1'})->status_is(416)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is('');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=8-1'})
+ ->status_is(416)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is('');
};
subtest 'Partial static file, first byte' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=0-0'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 1)
- ->header_is('Content-Range' => 'bytes 0-0/31')->content_is('H');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=0-0'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 1)
+ ->header_is('Content-Range' => 'bytes 0-0/31')
+ ->content_is('H');
};
subtest 'Partial static file, end outside of range' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=25-31'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 6)->header_is('Content-Range' => 'bytes 25-30/31')
- ->header_is('Accept-Ranges' => 'bytes')->content_is("file!\n");
+ $t->get_ok('/hello.txt' => {Range => 'bytes=25-31'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 6)
+ ->header_is('Content-Range' => 'bytes 25-30/31')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("file!\n");
};
subtest 'Partial static file, end way outside of range' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=25-300'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Content-Length' => 6)->header_is('Content-Range' => 'bytes 25-30/31')
- ->header_is('Accept-Ranges' => 'bytes')->content_is("file!\n");
+ $t->get_ok('/hello.txt' => {Range => 'bytes=25-300'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Content-Length' => 6)
+ ->header_is('Content-Range' => 'bytes 25-30/31')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("file!\n");
};
subtest 'Partial static file, invalid range' => sub {
- $t->get_ok('/hello.txt' => {Range => 'bytes=32-33'})->status_is(416)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is('');
+ $t->get_ok('/hello.txt' => {Range => 'bytes=32-33'})
+ ->status_is(416)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is('');
};
subtest 'Render single byte static file' => sub {
- $t->get_ok('/hello3.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 1)->content_is('X');
+ $t->get_ok('/hello3.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 1)
+ ->content_is('X');
};
subtest 'Render partial single byte static file' => sub {
- $t->get_ok('/hello3.txt' => {Range => 'bytes=0-0'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 1)
- ->header_is('Content-Range' => 'bytes 0-0/1')->content_is('X');
+ $t->get_ok('/hello3.txt' => {Range => 'bytes=0-0'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 1)
+ ->header_is('Content-Range' => 'bytes 0-0/1')
+ ->content_is('X');
};
subtest 'Render static file with custom content type' => sub {
- $t->post_ok('/hello4.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->content_type_is('text/html')
- ->header_is('Content-Length' => 1)->content_is('X');
+ $t->post_ok('/hello4.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_type_is('text/html')
+ ->header_is('Content-Length' => 1)
+ ->content_is('X');
};
subtest 'Fresh content' => sub {
- $t->get_ok('/etag')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is(ETag => '"abc"')
+ $t->get_ok('/etag')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => '"abc"')
->content_is('I ♥ Mojolicious!');
- $t->get_ok('/etag_weak')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')->header_is(ETag => 'W/"abc"')
+ $t->get_ok('/etag_weak')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => 'W/"abc"')
+ ->content_is('I ♥ Mojolicious!');
+ $t->get_ok('/etag' => {'If-None-Match' => 'W/"abc"'})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => '"abc"')
->content_is('I ♥ Mojolicious!');
- $t->get_ok('/etag' => {'If-None-Match' => 'W/"abc"'})->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is(ETag => '"abc"')->content_is('I ♥ Mojolicious!');
};
subtest 'Stale content' => sub {
- $t->get_ok('/etag' => {'If-None-Match' => '"abc"'})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is(ETag => '"abc"')->content_is('');
- $t->get_ok('/etag_weak' => {'If-None-Match' => '"abc"'})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is(ETag => 'W/"abc"')->content_is('');
- $t->get_ok('/etag_weak' => {'If-None-Match' => 'W/"abc"'})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is(ETag => 'W/"abc"')->content_is('');
+ $t->get_ok('/etag' => {'If-None-Match' => '"abc"'})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => '"abc"')
+ ->content_is('');
+ $t->get_ok('/etag_weak' => {'If-None-Match' => '"abc"'})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => 'W/"abc"')
+ ->content_is('');
+ $t->get_ok('/etag_weak' => {'If-None-Match' => 'W/"abc"'})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is(ETag => 'W/"abc"')
+ ->content_is('');
};
subtest 'Fresh asset' => sub {
@@ -218,18 +294,26 @@ subtest 'Fresh asset' => sub {
subtest 'Stale asset' => sub {
my $etag = $t->tx->res->headers->etag;
- $t->get_ok('/asset' => {'If-None-Match' => $etag})->status_is(304)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/asset' => {'If-None-Match' => $etag})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is('');
};
subtest 'Partial asset' => sub {
- $t->get_ok('/asset' => {'Range' => 'bytes=3-5'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_exists_not('Cache-Control')->content_is('3 A');
+ $t->get_ok('/asset' => {'Range' => 'bytes=3-5'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_exists_not('Cache-Control')
+ ->content_is('3 A');
};
subtest 'File' => sub {
- $t->get_ok('/file' => {'Range' => 'bytes=4-9'})->status_is(206)->content_type_is('application/octet-stream')
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('answer');
+ $t->get_ok('/file' => {'Range' => 'bytes=4-9'})
+ ->status_is(206)
+ ->content_type_is('application/octet-stream')
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('answer');
};
subtest 'Empty file' => sub {
@@ -237,8 +321,11 @@ subtest 'Empty file' => sub {
};
subtest 'Partial empty file' => sub {
- $t->get_ok('/hello4.txt' => {Range => 'bytes=0-0'})->status_is(416)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is('');
+ $t->get_ok('/hello4.txt' => {Range => 'bytes=0-0'})
+ ->status_is(416)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is('');
};
subtest 'Hidden inline file' => sub {
@@ -247,40 +334,62 @@ subtest 'Hidden inline file' => sub {
subtest 'Base64 static inline file, If-Modified-Since' => sub {
my $modified = Mojo::Date->new->epoch($^T - 1);
- $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->header_is('Accept-Ranges' => 'bytes')->content_is("test 123\nlalala");
+ $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("test 123\nlalala");
$modified = $t->tx->res->headers->last_modified;
- $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})->status_is(304)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('');
+ $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('');
};
subtest 'Base64 static inline file' => sub {
- $t->get_ok('/static.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is("test 123\nlalala");
+ $t->get_ok('/static.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("test 123\nlalala");
};
subtest 'Base64 static inline file, If-Modified-Since' => sub {
my $modified = Mojo::Date->new->epoch($^T - 1);
- $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})->status_is(200)
- ->header_is(Server => 'Mojolicious (Perl)')->header_is('Accept-Ranges' => 'bytes')->content_is("test 123\nlalala");
+ $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is("test 123\nlalala");
$modified = $t->tx->res->headers->last_modified;
- $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})->status_is(304)
- ->header_is(Server => 'Mojolicious (Perl)')->content_is('');
+ $t->get_ok('/static.txt' => {'If-Modified-Since' => $modified})
+ ->status_is(304)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->content_is('');
};
subtest 'Base64 partial inline file' => sub {
- $t->get_ok('/static.txt' => {Range => 'bytes=2-5'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Range' => 'bytes 2-5/15')
- ->header_is('Content-Length' => 4)->content_is('st 1');
+ $t->get_ok('/static.txt' => {Range => 'bytes=2-5'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Range' => 'bytes 2-5/15')
+ ->header_is('Content-Length' => 4)
+ ->content_is('st 1');
};
subtest 'Base64 partial inline file, invalid range' => sub {
- $t->get_ok('/static.txt' => {Range => 'bytes=45-50'})->status_is(416)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->content_is('');
+ $t->get_ok('/static.txt' => {Range => 'bytes=45-50'})
+ ->status_is(416)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->content_is('');
};
subtest 'UTF-8 encoded inline file' => sub {
- $t->get_ok('/static_utf8.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/static_utf8.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("I ♥ Unicode\n");
};
@@ -295,24 +404,48 @@ subtest 'Assets' => sub {
is $c->url_for_asset('/foo/bar/test.min.js')->path, '/assets/foo/bar/test.ab1234cd5678ef.min.js', 'right asset path';
is $c->url_for_asset('/foo/bar/yada.css')->path, '/assets/foo/bar/yada.css', 'right asset path';
- $t->get_ok('/assets/foo.ab1234cd5678ef.css')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\.css asset/);
- $t->get_ok('/assets/foo.ab1234cd5678ef.js')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\.js asset/);
- $t->get_ok('/assets/foo/bar.321.js')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\/bar\.js asset/);
- $t->get_ok('/assets/foo/bar/baz.development.js')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\/bar\/baz\.js development asset/);
- $t->get_ok('/assets/foo/bar/baz.123.js')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\/bar\/baz\.js asset/);
- $t->get_ok('/assets/foo/bar/test.ab1234cd5678ef.min.js')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\/bar\/test\.min\.js asset/);
- $t->get_ok('/assets/foo/bar/yada.css')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Cache-Control', 'no-cache')->content_like(qr/\* foo\/bar\/yada\.css asset/);
+ $t->get_ok('/assets/foo.ab1234cd5678ef.css')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\.css asset/);
+ $t->get_ok('/assets/foo.ab1234cd5678ef.js')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\.js asset/);
+ $t->get_ok('/assets/foo/bar.321.js')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\/bar\.js asset/);
+ $t->get_ok('/assets/foo/bar/baz.development.js')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\/bar\/baz\.js development asset/);
+ $t->get_ok('/assets/foo/bar/baz.123.js')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\/bar\/baz\.js asset/);
+ $t->get_ok('/assets/foo/bar/test.ab1234cd5678ef.min.js')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\/bar\/test\.min\.js asset/);
+ $t->get_ok('/assets/foo/bar/yada.css')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Cache-Control', 'no-cache')
+ ->content_like(qr/\* foo\/bar\/yada\.css asset/);
$t->app->mode('production');
- $t->get_ok('/assets/foo.ab1234cd5678ef.css')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_exists_not('Cache-Control')->content_like(qr/\* foo\.css asset/);
+ $t->get_ok('/assets/foo.ab1234cd5678ef.css')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_exists_not('Cache-Control')
+ ->content_like(qr/\* foo\.css asset/);
};
subtest 'File' => sub {
diff --git a/t/mojolicious/static_prefix_lite_app.t b/t/mojolicious/static_prefix_lite_app.t
index cf49f8a645..a729636e00 100644
--- a/t/mojolicious/static_prefix_lite_app.t
+++ b/t/mojolicious/static_prefix_lite_app.t
@@ -19,13 +19,19 @@ subtest 'Action for static file path without prefix' => sub {
};
subtest 'Static file' => sub {
- $t->get_ok('/static/hello.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
- ->header_exists_not('Cache-Control')->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 31)
+ $t->get_ok('/static/hello.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_exists_not('Cache-Control')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Length' => 31)
->content_is("Hello Mojo from a static file!\n");
};
subtest 'Static asset' => sub {
- $t->get_ok('/static/assets/foo.ab1234cd5678ef.css')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/static/assets/foo.ab1234cd5678ef.css')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_like(qr/\* foo\.css asset/);
};
@@ -34,7 +40,9 @@ subtest 'Bundled static file' => sub {
};
subtest 'Bundled template' => sub {
- $t->get_ok('/doesnotexist')->status_is(404)->element_exists('link[href=/static/favicon.ico]')
+ $t->get_ok('/doesnotexist')
+ ->status_is(404)
+ ->element_exists('link[href=/static/favicon.ico]')
->element_exists('link[href=/static/mojo/mojo.css]');
};
@@ -63,14 +71,20 @@ subtest 'Hidden inline file' => sub {
subtest 'Base64 partial inline file' => sub {
$t->get_ok('/static.txt')->status_is(404);
- $t->get_ok('/static/static.txt' => {Range => 'bytes=2-5'})->status_is(206)->header_is(Server => 'Mojolicious (Perl)')
- ->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Range' => 'bytes 2-5/15')
- ->header_is('Content-Length' => 4)->content_is('st 1');
+ $t->get_ok('/static/static.txt' => {Range => 'bytes=2-5'})
+ ->status_is(206)
+ ->header_is(Server => 'Mojolicious (Perl)')
+ ->header_is('Accept-Ranges' => 'bytes')
+ ->header_is('Content-Range' => 'bytes 2-5/15')
+ ->header_is('Content-Length' => 4)
+ ->content_is('st 1');
};
subtest 'UTF-8 encoded inline file' => sub {
$t->get_ok('/static_utf8.txt')->status_is(404);
- $t->get_ok('/static/static_utf8.txt')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
+ $t->get_ok('/static/static_utf8.txt')
+ ->status_is(200)
+ ->header_is(Server => 'Mojolicious (Perl)')
->content_is("I ♥ Unicode\n");
};
diff --git a/t/mojolicious/tag_helper_lite_app.t b/t/mojolicious/tag_helper_lite_app.t
index 952f8add53..463b20151a 100644
--- a/t/mojolicious/tag_helper_lite_app.t
+++ b/t/mojolicious/tag_helper_lite_app.t
@@ -128,7 +128,8 @@ $t->post_ok('/links')->status_is(200)->content_is(<<'EOF');
EOF
# Buttons
-$t->get_ok('/buttons')->status_is(200)
+$t->get_ok('/buttons')
+ ->status_is(200)
->content_is('\n"
@@ -371,7 +372,8 @@ $t->get_ok('/form/lala?c=b&d=3&e=4&f=<5&b=on')->status_is(200)->content_is(<put_ok('/selection')->status_is(200)
+$t->put_ok('/selection')
+ ->status_is(200)
->content_is("\n");
# Selection with values
-$t->put_ok('/selection?a=e&foo=bar&bar=baz&yada=b&h=j')->status_is(200)
+$t->put_ok('/selection?a=e&foo=bar&bar=baz&yada=b&h=j')
+ ->status_is(200)
->content_is("\n");
# Selection with multiple values
-$t->put_ok('/selection?foo=bar&a=e&foo=baz&bar=d&yada=a&yada=b&h=i&h=j')->status_is(200)
+$t->put_ok('/selection?foo=bar&a=e&foo=baz&bar=d&yada=a&yada=b&h=i&h=j')
+ ->status_is(200)
->content_is("\n");
# Selection with multiple values preselected
-$t->put_ok('/selection?preselect=1&undef=1')->status_is(200)
+$t->put_ok('/selection?preselect=1&undef=1')
+ ->status_is(200)
->content_is("