File: author-live_engine_response_redirect.t

package info (click to toggle)
libcatalyst-engine-apache-perl 1.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 1,040 kB
  • ctags: 667
  • sloc: perl: 6,344; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 2,378 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!perl

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all => 'these tests are for testing by the author');
  }
}


use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/lib";

use Test::More tests => 26;
use Catalyst::Test 'TestApp';

{
    ok( my $response = request('http://localhost/engine/response/redirect/one'), 'Request' );
    ok( $response->is_redirect, 'Response Redirection 3xx' );
    is( $response->code, 302, 'Response Code' );
    is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/one', 'Test Action' );
    is( $response->header('Location'), '/test/writing/is/boring', 'Response Header Location' );
    ok( $response->header('Content-Length'), '302 Redirect contains Content-Length' );
    ok( $response->content, '302 Redirect contains a response body' );
}

{
    ok( my $response = request('http://localhost/engine/response/redirect/two'), 'Request' );
    ok( $response->is_redirect, 'Response Redirection 3xx' );
    is( $response->code, 302, 'Response Code' );
    is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/two', 'Test Action' );
    is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
}

{
    ok( my $response = request('http://localhost/engine/response/redirect/three'), 'Request' );
    ok( $response->is_redirect, 'Response Redirection 3xx' );
    is( $response->code, 301, 'Response Code' );
    is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/three', 'Test Action' );
    is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
    ok( $response->header('Content-Length'), '301 Redirect contains Content-Length' );
    ok( $response->content, '301 Redirect contains a response body' );
}

{
    ok( my $response = request('http://localhost/engine/response/redirect/four'), 'Request' );
    ok( $response->is_redirect, 'Response Redirection 3xx' );
    is( $response->code, 307, 'Response Code' );
    is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/four', 'Test Action' );
    is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
    ok( $response->header('Content-Length'), '307 Redirect contains Content-Length' );
    ok( $response->content, '307 Redirect contains a response body' );
}