File: state.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (90 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (5)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use warnings;
use strict;
use Test::More;
use HTTP::Request::Common;

{
  package MyApp::Controller::Root;
  $INC{'MyApp/Controller/Root.pm'} = __FILE__;

  use base 'Catalyst::Controller';

  MyApp::Controller::Root->config(namespace=>'');

  sub begin :Action {
    my ($self, $c) = @_;
    Test::More::is($c->state, 0);
    return 'begin';
  }

  sub auto :Action {
    my ($self, $c) = @_;
    # Even if a begin returns something, we kill it.  Need to
    # do this since there's actually people doing detach in
    # auto and expect that to work the same as 0.
    Test::More::is($c->state, '0');
    return 'auto';

  }

  sub base :Chained('/') PathPrefix CaptureArgs(0) {
    my ($self, $c) = @_;
    Test::More::is($c->state, 'auto');
    return 10;
  }

    sub one :Chained('base') PathPart('') CaptureArgs(0) {
      my ($self, $c) = @_;
      Test::More::is($c->state, 10);
      return 20;
    }

      sub two :Chained('one') PathPart('') Args(1) {
        my ($self, $c, $arg) = @_;
        Test::More::is($c->state, 20);
        my $ret = $c->forward('forward2');
        Test::More::is($ret, 25);
        Test::More::is($c->state, 25);
        return 30;
      }

  sub end :Action {
    my ($self, $c) = @_;
    Test::More::is($c->state, 30);
    my $ret = $c->forward('forward1');
    Test::More::is($ret, 100);
    Test::More::is($c->state, 100);
    $c->detach('detach1');
  }

  sub forward1 :Action {
    my ($self, $c) = @_;
    Test::More::is($c->state, 30);
    return 100;
  }

  sub forward2 :Action {
    my ($self, $c) = @_;
    Test::More::is($c->state, 20);
    return 25;
  }

  sub detach1 :Action {
    my ($self, $c) = @_;
    Test::More::is($c->state, 100);
  }

  package MyApp;
  use Catalyst;

  MyApp->config(show_internal_actions=>1);
  MyApp->setup;
}

use Catalyst::Test 'MyApp';

{
  ok my $res = request "/100";
}

done_testing;