1Catalyst::Test(3) User Contributed Perl Documentation Catalyst::Test(3)
2
3
4
6 Catalyst::Test - Test Catalyst Applications
7
9 # Helper
10 script/test.pl
11
12 # Tests
13 use Catalyst::Test 'TestApp';
14 request('index.html');
15 get('index.html');
16
17 # Run tests against a remote server
18 CATALYST_SERVER='http://localhost:3000/' prove -r -l lib/ t/
19
20 # Tests with inline apps need to use Catalyst::Engine::Test
21 package TestApp;
22
23 use Catalyst;
24
25 sub foo : Global {
26 my ( $self, $c ) = @_;
27 $c->res->output('bar');
28 }
29
30 __PACKAGE__->setup();
31
32 package main;
33
34 use Test::More tests => 1;
35 use Catalyst::Test 'TestApp';
36
37 ok( get('/foo') =~ /bar/ );
38
40 Test Catalyst Applications.
41
42 METHODS
43
44 get
45
46 Returns the content.
47
48 my $content = get('foo/bar?test=1');
49
50 Note that this method doesn't follow redirects, so to test for a cor‐
51 rectly redirecting page you'll need to use a combination of this method
52 and the request method below:
53
54 my $res = request('/'); # redirects to /y
55 warn $res->header('location');
56 use URI;
57 my $uri = URI->new($res->header('location'));
58 is ( $uri->path , '/y');
59 my $content = get($uri->path);
60
61 request
62
63 Returns a "HTTP::Response" object.
64
65 my $res = request('foo/bar?test=1');
66
67 local_request
68
69 remote_request
70
71 Do an actual remote request using LWP.
72
74 Catalyst.
75
77 Sebastian Riedel, "sri@cpan.org"
78
80 This program is free software, you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82
83
84
85perl v5.8.8 2007-09-20 Catalyst::Test(3)