| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CatalystX::Test::Most; |
|
2
|
1
|
|
|
1
|
|
3585
|
use strictures; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
1
|
|
|
1
|
|
86
|
no warnings "uninitialized"; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
1016
|
use HTTP::Request::Common ( qw{ GET POST DELETE PUT } ); |
|
|
1
|
|
|
|
|
30075
|
|
|
|
1
|
|
|
|
|
97
|
|
|
5
|
1
|
|
|
1
|
|
9
|
use Test::More; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
6
|
1
|
|
|
1
|
|
1192
|
use Test::Fatal; |
|
|
1
|
|
|
|
|
5130
|
|
|
|
1
|
|
|
|
|
204
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = "cpan:ASHLEY"; |
|
8
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
|
9
|
|
|
|
|
|
|
our @EXPORT = ( qw{ GET POST DELETE PUT }, |
|
10
|
|
|
|
|
|
|
qw{ request ctx_request action_redirect }, |
|
11
|
|
|
|
|
|
|
qw{ exception }, |
|
12
|
|
|
|
|
|
|
qw{ ctx mech }, |
|
13
|
|
|
|
|
|
|
grep { defined &{$_} } @Test::More::EXPORT ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my ( $App, $Args ); # Save for mech. |
|
16
|
|
|
|
|
|
|
sub import { |
|
17
|
1
|
|
|
1
|
|
9
|
my $package = shift; |
|
18
|
1
|
|
|
|
|
3
|
( $App, $Args ) = @_; |
|
19
|
1
|
|
|
|
|
5
|
my $calling_package = [ caller() ]->[0]; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
8
|
strictures->import; |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
681
|
require Catalyst::Test; |
|
24
|
0
|
|
|
|
|
|
Catalyst::Test->import($App, $Args); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
|
27
|
1
|
|
|
1
|
|
8
|
no strict "refs"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
219
|
|
|
|
0
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
*{"${calling_package}::$_"} = \&{$_} for @EXPORT; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# delete is obviously a problem and the rest should maybe be the uc |
|
33
|
|
|
|
|
|
|
# anyway and not export the HTTP::Request::Common ones or something new? |
|
34
|
|
|
|
|
|
|
#sub get { request( GET( @_ ) ); } |
|
35
|
|
|
|
|
|
|
#sub put { request( PUT( @_ ) ); } |
|
36
|
|
|
|
|
|
|
#sub post { request( POST( @_ ) ); } |
|
37
|
|
|
|
|
|
|
#sub delete { request( DELETE( @_ ) ); } |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
sub ctx { [ ctx_request(@_) ]->[1] } |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# No args means function call. |
|
42
|
|
|
|
|
|
|
sub mech { |
|
43
|
0
|
0
|
|
0
|
1
|
|
my $self = shift if $_[0] eq __PACKAGE__; # Toss it. |
|
44
|
0
|
|
0
|
|
|
|
my @args = ( catalyst_app => +shift || $App ); |
|
45
|
0
|
0
|
|
|
|
|
push @args, shift if @_; |
|
46
|
0
|
|
|
|
|
|
require Test::WWW::Mechanize::Catalyst; |
|
47
|
0
|
|
|
|
|
|
Test::WWW::Mechanize::Catalyst |
|
48
|
|
|
|
|
|
|
->new( @args ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 Name |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
CatalystX::Test::Most - Test base pulling in L<Catalyst::Test>, L<Test::More>, L<Test::Fatal>, and L<HTTP::Request::Common> for unit tests on Catalyst applications. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 Synopsis |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use CatalystX::Test::Most "MyApp"; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
subtest "Tests with plain Catalyst::Test" => sub { |
|
66
|
|
|
|
|
|
|
ok request("/")->is_success, "/ is okay"; |
|
67
|
|
|
|
|
|
|
is exception { request("/no-such-uri") }, undef, |
|
68
|
|
|
|
|
|
|
"404s do not throw exceptions"; |
|
69
|
|
|
|
|
|
|
is request("/no-such-uri")->code, 404, "And do return 404"; |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
subtest "Tests with Test::WWW::Mechanize::Catalyst" => sub { |
|
73
|
|
|
|
|
|
|
my $mech = mech(); |
|
74
|
|
|
|
|
|
|
$mech->get_ok("/", "GET /"); |
|
75
|
|
|
|
|
|
|
$mech->content_contains("OHAI", "That's my app all right"); |
|
76
|
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
done_testing(); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# ok 1 - / is okay |
|
81
|
|
|
|
|
|
|
# ok 2 - 404s do not throw exceptions |
|
82
|
|
|
|
|
|
|
# ok 3 - And do return 404 |
|
83
|
|
|
|
|
|
|
# 1..3 |
|
84
|
|
|
|
|
|
|
# ok 2 - Tests with plain Catalyst::Test |
|
85
|
|
|
|
|
|
|
# ok 1 - GET / |
|
86
|
|
|
|
|
|
|
# ok 2 - My app all right |
|
87
|
|
|
|
|
|
|
# 1..2 |
|
88
|
|
|
|
|
|
|
# ok 3 - Tests with Test::WWW::Mechanize::Catalyst |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 Exported Functions from Other Packages |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 Catalyst::Test |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Everything, so see its documentation: L<Catalyst::Test>. L<CatalystX::Test::Most> is basically an overloaded version of it. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 Test::More |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
All of its exported functions; see its documentation: L<Test::More>. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Test::Fatal |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
See C<exception> in L<Test::Fatal>. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 Test::WWW::Mechanize::Catalyst |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You have easy access to a L<Test::WWW::Mechanize::Catalyst> object. There are no related functions, just the object methods. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 New Functions |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over 4 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * C<ctx> |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is a wrapper to get the context object. It will only work on local tests (not remote servers). |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C<mech> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Get a L<Test::WWW::Mechanize::Catalyst> object. Unless specified, the app name and the arguments are recycled from the C<import> of L<CatalystX::Test::Most>. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 Notes |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<strictures> are exported. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 Copyright and License |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Ashley Pond V. Artistic License 2.0. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |