Authentication back compat fail due to ::ClassData not behaving like C::D::I, not...
[catagits/Catalyst-Runtime.git] / t / optional_threads.t
CommitLineData
c7ded7aa 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/lib";
8
9use Test::More;
10use Catalyst::Test 'TestApp';
11use Catalyst::Request;
12use Config;
13use HTTP::Response;
14
15plan skip_all => 'set TEST_THREADS to enable this test'
16 unless $ENV{TEST_THREADS};
17
18if ( $Config{useithreads} && !$ENV{CATALYST_SERVER} ) {
19 require threads;
20 plan tests => 3;
21}
22else {
23 if ( $ENV{CATALYST_SERVER} ) {
24 plan skip_all => 'Using remote server';
25 }
26 else {
27 plan skip_all => 'Needs a Perl with ithreads enabled';
28 }
29}
30
31no warnings 'redefine';
32sub request {
33 my $thr = threads->new(
34 sub { Catalyst::Test::local_request('TestApp',@_) },
35 @_
36 );
37 $thr->join;
38}
39
40# test that running inside a thread works ok
41{
42 my @expected = qw[
43 TestApp::Controller::Action::Default->begin
44 TestApp::Controller::Action::Default->default
45 TestApp::View::Dump::Request->process
46 TestApp->end
47 ];
48
49 my $expected = join( ", ", @expected );
50
51 ok( my $response = request('http://localhost/action/default'), 'Request' );
52 ok( $response->is_success, 'Response Successful 2xx' );
53 is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
54}