| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
63190
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
43
|
|
|
3
|
|
|
|
|
|
|
package CatalystX::Test::MockContext; |
|
4
|
1
|
|
|
1
|
|
914
|
use Plack::Test; |
|
|
1
|
|
|
|
|
2006
|
|
|
|
1
|
|
|
|
|
62
|
|
|
5
|
1
|
|
|
1
|
|
17859
|
use Class::Load (); |
|
|
1
|
|
|
|
|
57385
|
|
|
|
1
|
|
|
|
|
45
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#ABSTRACT: Conveniently create $c objects for testing |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
12
|
use Sub::Exporter -setup => { |
|
11
|
|
|
|
|
|
|
exports => [qw(mock_context)], |
|
12
|
|
|
|
|
|
|
groups => { default => [qw(mock_context)] } |
|
13
|
1
|
|
|
1
|
|
981
|
}; |
|
|
1
|
|
|
|
|
4023
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub mock_context { |
|
17
|
0
|
|
|
0
|
1
|
|
my ($class) = @_; |
|
18
|
0
|
|
|
|
|
|
Class::Load::load_class($class); |
|
19
|
|
|
|
|
|
|
sub { |
|
20
|
0
|
|
|
0
|
|
|
my ($req) = @_; |
|
21
|
0
|
|
|
|
|
|
my $c; |
|
22
|
|
|
|
|
|
|
test_psgi app => sub { |
|
23
|
0
|
|
|
|
|
|
my $env = shift; |
|
24
|
0
|
|
|
|
|
|
$c = $class->prepare( env => $env, response_cb => sub { } ); |
|
|
0
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return [ 200, [ 'Content-type' => 'text/plain' ], ['Created mock OK'] ]; |
|
26
|
|
|
|
|
|
|
}, |
|
27
|
|
|
|
|
|
|
client => sub { |
|
28
|
0
|
|
|
|
|
|
my $cb = shift; |
|
29
|
0
|
|
|
|
|
|
$cb->($req); |
|
30
|
0
|
|
|
|
|
|
}; |
|
31
|
0
|
|
|
|
|
|
return $c; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
0
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
|
38
|
|
|
|
|
|
|
=pod |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
CatalystX::Test::MockContext - Conveniently create $c objects for testing |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 VERSION |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
version 0.000001 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use HTTP::Request::Common; |
|
51
|
|
|
|
|
|
|
use CatalystX::Test::MockContext; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $m = mock_context('MyApp'); |
|
54
|
|
|
|
|
|
|
my $c = $m->(GET '/'); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 my $sub = mock_context('MyApp'); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This method returns a closure that takes an HTTP::Request object and returns a |
|
61
|
|
|
|
|
|
|
L<Catalyst> context object for that request. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Eden Cardim <edencardim@gmail.com> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Eden Cardim. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
72
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|