| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
399717
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
87
|
|
|
2
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
155
|
|
|
3
|
|
|
|
|
|
|
package CatalystX::Test::MockContext; |
|
4
|
2
|
|
|
2
|
|
1209
|
use Plack::Test; |
|
|
2
|
|
|
|
|
1658
|
|
|
|
2
|
|
|
|
|
131
|
|
|
5
|
2
|
|
|
2
|
|
1220
|
use Class::Load (); |
|
|
2
|
|
|
|
|
47442
|
|
|
|
2
|
|
|
|
|
191
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000004'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#ABSTRACT: Conveniently create $c objects for testing |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
19
|
use Sub::Exporter -setup => { |
|
13
|
|
|
|
|
|
|
exports => [qw(mock_context)], |
|
14
|
|
|
|
|
|
|
groups => { default => [qw(mock_context)] } |
|
15
|
2
|
|
|
2
|
|
1564
|
}; |
|
|
2
|
|
|
|
|
10508
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub mock_context { |
|
19
|
2
|
|
|
2
|
1
|
2955652
|
my ($class) = @_; |
|
20
|
2
|
|
|
|
|
10
|
Class::Load::load_class($class); |
|
21
|
|
|
|
|
|
|
sub { |
|
22
|
3
|
|
|
3
|
|
7031
|
my ($req) = @_; |
|
23
|
3
|
|
|
|
|
7
|
my $c; |
|
24
|
|
|
|
|
|
|
my $app = sub { |
|
25
|
3
|
|
|
|
|
3049
|
my $env = shift; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# legacy implementation handles stash creation via MyApp->prepare |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
37
|
$c = $class->prepare( env => $env, response_cb => sub { } ); |
|
30
|
3
|
|
|
|
|
24238
|
return [ 200, [ 'Content-type' => 'text/plain' ], ['Created mock OK'] ]; |
|
31
|
3
|
|
|
|
|
14
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# handle stash-as-middleware implementation from v5.90070 |
|
34
|
3
|
50
|
|
|
|
6
|
if (eval { $Catalyst::VERSION } >= 5.90070) { |
|
|
3
|
|
|
|
|
25
|
|
|
35
|
3
|
|
|
|
|
10
|
Class::Load::load_class('Catalyst::Middleware::Stash'); |
|
36
|
3
|
|
|
|
|
154
|
$app = Catalyst::Middleware::Stash->wrap($app); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
test_psgi app => $app, |
|
40
|
|
|
|
|
|
|
client => sub { |
|
41
|
3
|
|
|
|
|
5322
|
my $cb = shift; |
|
42
|
3
|
|
|
|
|
13
|
$cb->($req); |
|
43
|
3
|
|
|
|
|
111
|
}; |
|
44
|
3
|
|
|
|
|
561
|
return $c; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
2
|
|
|
|
|
42586
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
CatalystX::Test::MockContext - Conveniently create $c objects for testing |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.000004 |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use HTTP::Request::Common; |
|
68
|
|
|
|
|
|
|
use CatalystX::Test::MockContext; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $m = mock_context('MyApp'); |
|
71
|
|
|
|
|
|
|
my $c = $m->(GET '/'); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 EXPORTS |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 mock_context |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $sub = mock_context('MyApp'); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This function returns a closure that takes an L<HTTP::Request> object and returns a |
|
80
|
|
|
|
|
|
|
L<Catalyst> context object for that request. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SOURCE |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The development version is on github at L<https://github.com/robrwo/CatalystX-Test-MockContext> |
|
85
|
|
|
|
|
|
|
and may be cloned from L<git://github.com/robrwo/CatalystX-Test-MockContext.git> |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 BUGS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
90
|
|
|
|
|
|
|
L<https://github.com/robrwo/CatalystX-Test-MockContext/issues> |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
93
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
94
|
|
|
|
|
|
|
feature. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 Reporting Security Vulnerabilities |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Security issues should not be reported on the bugtracker website. Please see F<SECURITY.md> for instructions how to |
|
99
|
|
|
|
|
|
|
report security vulnerabilities. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Eden Cardim <edencardim@gmail.com> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Currently maintained by Robert Rothenberg <rrwo@cpan.org> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is copyright (c) 2017, 2025 by Eden Cardim. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
112
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |