├── t ├── something │ ├── Makefile.PL │ └── script │ │ └── foo │ │ └── bar │ │ └── for_dist ├── utf8.txt ├── lib │ ├── TestMiddleware │ │ ├── share │ │ │ ├── static │ │ │ │ ├── forced.txt │ │ │ │ └── message.txt │ │ │ ├── static2 │ │ │ │ └── message2.txt │ │ │ └── static3 │ │ │ │ └── message3.txt │ │ ├── Custom.pm │ │ └── Controller │ │ │ └── Root.pm │ ├── TestMiddlewareFromPlugin │ │ ├── share │ │ │ ├── static │ │ │ │ ├── forced.txt │ │ │ │ └── message.txt │ │ │ ├── static2 │ │ │ │ └── message2.txt │ │ │ └── static3 │ │ │ │ └── message3.txt │ │ ├── Custom.pm │ │ ├── Controller │ │ │ └── Root.pm │ │ ├── SetMiddleware.pm │ │ └── testmiddlewarefromplugin.pl │ ├── TestPath.pm │ ├── ScriptTestApp.pm │ ├── TestAppMetaCompat │ │ └── Controller │ │ │ ├── Base.pm │ │ │ └── Books.pm │ ├── TestAppNonMooseController │ │ ├── ControllerBase.pm │ │ └── Controller │ │ │ └── Foo.pm │ ├── TestApp │ │ ├── Model │ │ │ ├── Foo │ │ │ │ └── Bar.pm │ │ │ ├── ClosuresInConfig.pm │ │ │ ├── Foo.pm │ │ │ └── Generating.pm │ │ ├── Controller │ │ │ ├── Immutable.pm │ │ │ ├── Priorities │ │ │ │ ├── loc_vs_index.pm │ │ │ │ ├── path_vs_index.pm │ │ │ │ ├── locre_vs_index.pm │ │ │ │ └── MultiMethod.pm │ │ │ ├── Index.pm │ │ │ ├── Action │ │ │ │ ├── Index.pm │ │ │ │ ├── Default.pm │ │ │ │ ├── ForwardTo.pm │ │ │ │ ├── Chained │ │ │ │ │ ├── ParentChain │ │ │ │ │ │ └── Relative.pm │ │ │ │ │ ├── PathPrefix.pm │ │ │ │ │ ├── Bar.pm │ │ │ │ │ ├── Root.pm │ │ │ │ │ ├── Auto │ │ │ │ │ │ ├── Bar.pm │ │ │ │ │ │ ├── Foo.pm │ │ │ │ │ │ ├── Detach.pm │ │ │ │ │ │ └── Forward.pm │ │ │ │ │ ├── ParentChain.pm │ │ │ │ │ ├── Auto.pm │ │ │ │ │ ├── Foo.pm │ │ │ │ │ ├── PassedArgs.pm │ │ │ │ │ └── ArgsOrder.pm │ │ │ │ ├── End.pm │ │ │ │ ├── Begin.pm │ │ │ │ ├── DieInEnd.pm │ │ │ │ ├── Auto.pm │ │ │ │ ├── Auto │ │ │ │ │ ├── Deep.pm │ │ │ │ │ ├── Default.pm │ │ │ │ │ ├── Abort.pm │ │ │ │ │ └── Detach.pm │ │ │ │ ├── TestMultipath.pm │ │ │ │ ├── ConfigSmashArrayRefs.pm │ │ │ │ ├── Global.pm │ │ │ │ ├── Local.pm │ │ │ │ ├── Private.pm │ │ │ │ ├── TestRelative.pm │ │ │ │ ├── Path.pm │ │ │ │ ├── Detach.pm │ │ │ │ └── Streaming.pm │ │ │ ├── Moose │ │ │ │ ├── NoAttributes.pm │ │ │ │ └── MethodModifiers.pm │ │ │ ├── Args.pm │ │ │ ├── Engine │ │ │ │ ├── Response │ │ │ │ │ ├── Large.pm │ │ │ │ │ ├── Headers.pm │ │ │ │ │ ├── Errors.pm │ │ │ │ │ ├── Print.pm │ │ │ │ │ ├── Redirect.pm │ │ │ │ │ ├── Status.pm │ │ │ │ │ └── Cookies.pm │ │ │ │ └── Request │ │ │ │ │ └── Uploads.pm │ │ │ ├── Log.pm │ │ │ ├── Action.pm │ │ │ ├── BodyParams.pm │ │ │ ├── Keyword.pm │ │ │ ├── ActionRoles.pm │ │ │ ├── Priorities.pm │ │ │ ├── ContextClosure.pm │ │ │ ├── Immutable │ │ │ │ └── HardToReload.pm │ │ │ ├── Moose.pm │ │ │ ├── Attributes.pm │ │ │ ├── Anon.pm │ │ │ ├── Fork.pm │ │ │ └── Dump.pm │ │ ├── ActionRole │ │ │ ├── Guff.pm │ │ │ ├── Kooh.pm │ │ │ └── Boo.pm │ │ ├── DispatchType │ │ │ ├── CustomPostLoad.pm │ │ │ └── CustomPreLoad.pm │ │ ├── Plugin │ │ │ ├── FullyQualified.pm │ │ │ ├── ParameterizedRole.pm │ │ │ └── AddDispatchTypes.pm │ │ ├── View │ │ │ └── Dump │ │ │ │ ├── Action.pm │ │ │ │ ├── Body.pm │ │ │ │ ├── Request.pm │ │ │ │ ├── Response.pm │ │ │ │ └── Env.pm │ │ ├── RequestBaseBug.pm │ │ ├── Action │ │ │ ├── TestBefore.pm │ │ │ ├── TestMatchCaptures.pm │ │ │ ├── TestExtraArgsAction.pm │ │ │ ├── TestActionArgsFromConstructor.pm │ │ │ └── TestMyAction.pm │ │ ├── Role.pm │ │ └── Model.pm │ ├── TestAppNonMooseController.pm │ ├── TestAppMetaCompat.pm │ ├── ScriptTestApp │ │ ├── Script │ │ │ ├── CompileTest.pm │ │ │ ├── Bar.pm │ │ │ └── Foo.pm │ │ ├── Controller │ │ │ └── Root.pm │ │ └── TraitFor │ │ │ ├── Script.pm │ │ │ └── Script │ │ │ ├── Bar.pm │ │ │ └── Foo.pm │ ├── TestDataHandlers.pm │ ├── Catalyst │ │ ├── Script │ │ │ ├── Bar.pm │ │ │ ├── Baz.pm │ │ │ └── CompileTest.pm │ │ ├── ActionRole │ │ │ ├── Guff.pm │ │ │ └── Zoo.pm │ │ ├── Action │ │ │ ├── TestBefore.pm │ │ │ └── TestAfter.pm │ │ └── Plugin │ │ │ └── Test │ │ │ ├── MangleDollarUnderScore.pm │ │ │ ├── Deprecated.pm │ │ │ ├── Errors.pm │ │ │ ├── Headers.pm │ │ │ └── Plugin.pm │ ├── TestAppOneView.pm │ ├── Test │ │ └── Apple.pm │ ├── TestAppIndexDefault.pm │ ├── TestAppEncoding.pm │ ├── TestAppMatchSingleArg.pm │ ├── TestAppEncodingSetInPlugin.pm │ ├── TestAppWithMeta.pm │ ├── TestAppToTestScripts.pm │ ├── Guff.pm │ ├── TestAppEncodingSetInApp.pm │ ├── TestAppOneView │ │ ├── View │ │ │ └── Dummy.pm │ │ └── Controller │ │ │ └── Root.pm │ ├── TestFromPSGI.pm │ ├── TestContentNegotiation.pm │ ├── TestAppChainedAbsolutePathPart │ │ └── Controller │ │ │ └── Foo.pm │ ├── TestAppEncodingSetInPlugin │ │ ├── SetEncoding.pm │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppIndexDefault │ │ └── Controller │ │ │ ├── IndexPrivate.pm │ │ │ ├── IndexChained.pm │ │ │ ├── Default.pm │ │ │ └── Root.pm │ ├── DeprecatedTestApp.pm │ ├── TestAppChainedRecursive │ │ └── Controller │ │ │ └── Foo.pm │ ├── TestAppPluginWithConstructor │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppWithoutUnicode.pm │ ├── TestPath │ │ └── Controller │ │ │ ├── One.pm │ │ │ ├── Two.pm │ │ │ ├── Three.pm │ │ │ └── Four.pm │ ├── NullPackage.pm │ ├── TestMiddlewareFromPlugin.pm │ ├── TestAppUnknownError.pm │ ├── TestAppBadlyImmutable.pm │ ├── TestPluginWithConstructor.pm │ ├── TestAppEncodingSetInApp │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppChainedRecursive.pm │ ├── TestAppOnDemand.pm │ ├── ACLTestApp │ │ └── Controller │ │ │ └── Root.pm │ ├── TestDataHandlers │ │ └── Controller │ │ │ └── Root.pm │ ├── DeprecatedTestApp │ │ └── C │ │ │ └── Root.pm │ ├── TestAppChainedAbsolutePathPart.pm │ ├── TestAppStats │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppViewWarnings │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppShowInternalActions │ │ └── Controller │ │ │ └── Root.pm │ ├── TestLogger.pm │ ├── TestAppWithMeta │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppWithoutUnicode │ │ └── Controller │ │ │ └── Root.pm │ ├── ChainedActionsApp.pm │ ├── TestAppUnicode.pm │ ├── TestAppViewWarnings.pm │ ├── TestAppClassExceptionSimpleTest.pm │ ├── TestAppDoubleAutoBug │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppStats.pm │ ├── TestAppShowInternalActions.pm │ ├── TestAppMatchSingleArg │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppPluginWithConstructor.pm │ ├── TestAppPathBug.pm │ ├── ACLTestApp.pm │ ├── DeprecatedActionsInAppClassTestApp.pm │ ├── TestAppArgsEmptyParens.pm │ ├── TestAppOnDemand │ │ └── Controller │ │ │ └── Body.pm │ ├── PluginTestApp.pm │ ├── TestMiddleware.pm │ ├── TestAppEncoding │ │ └── Controller │ │ │ └── Root.pm │ ├── TestAppDoubleAutoBug.pm │ ├── MakeTestApp.pm │ ├── TestFromPSGI │ │ └── Controller │ │ │ └── Root.pm │ └── CDICompatTestPlugin.pm ├── 01use.t ├── catalyst_130pix.gif ├── aggregate │ ├── unit_metaclass_compat_non_moose.t │ ├── to_app.t │ ├── live_engine_response_body.t │ ├── deprecated_test_import.t │ ├── unit_core_controller_actions_config.t │ ├── unit_core_component_generating.t │ ├── unit_core_appclass_roles_in_plugin_list.t │ ├── live_engine_setup_basics.t │ ├── live_engine_setup_plugins.t │ ├── error_page_dump.t │ ├── unit_response.t │ ├── unit_metaclass_compat_extend_non_moose_controller.t │ ├── deprecated_test_unimported.t │ ├── live_view_warnings.t │ ├── unit_controller_namespace.t │ ├── c3_appclass_bug.t │ ├── meta_method_unneeded.t │ ├── unit_core_action_for.t │ ├── unit_metaclass_compat_non_moose_controller.t │ ├── unit_core_component_mro.t │ ├── live_engine_response_emptybody.t │ ├── live_engine_response_print.t │ ├── live_loop.t │ ├── live_component_controller_action_die_in_end.t │ ├── live_engine_request_escaped_path.t │ ├── unit_utils_request.t │ ├── unit_core_script_help.t │ ├── live_recursion.t │ ├── live_engine_response_large.t │ ├── unit_core_script_cgi.t │ ├── caf_backcompat.t │ ├── utf8_content_length.t │ ├── unit_core_scriptrunner.t │ ├── live_component_controller_action_path_matchsingle.t │ ├── unit_controller_actions.t │ ├── custom_live_path_bug.t │ ├── unit_core_ctx_attr.t │ ├── unit_core_script_server-without_modules.t │ ├── unit_dispatcher_requestargs_restore.t │ ├── live_plugin_loaded.t │ ├── live_component_view_single.t │ ├── unit_core_component_layers.t │ ├── unit_engineloader.t │ ├── catalyst_test_utf8.t │ ├── live_component_controller_action_chained2.t │ ├── live_component_controller_anon.t │ ├── live_component_controller_actionroles.t │ ├── unit_core_path_to.t │ ├── unit_core_script_run_options.t │ ├── c3_mro.t │ ├── unit_utils_prefix.t │ ├── unit_utils_home.t │ ├── live_engine_request_prepare_parameters.t │ ├── unit_core_merge_config_hashes.t │ ├── live_engine_request_auth.t │ ├── live_component_controller_action_index_or_default.t │ ├── live_engine_request_env.t │ ├── custom_live_component_controller_action_auto_doublebug.t │ └── live_engine_request_remote_user.t ├── dead_no_unknown_error.t ├── bad_middleware_error.t ├── encoding_set_in_plugin.t ├── encoding_set_in_app.t ├── unicode_plugin_config.t ├── custom_exception_class_simple.t ├── deprecated_appclass_action_warnings.t ├── no_test_stash_bug.t ├── dead_load_multiple_chained_attributes.t ├── live_stats.t ├── psgi_file_testapp.t ├── live_show_internal_actions_warnings.t ├── unit_core_methodattributes_method_metaclass_on_subclasses.t ├── set_allowed_method.t ├── args-empty-parens-bug.t ├── accept_context_regression.t ├── evil_stash.t ├── unicode_plugin_charset_utf8.t ├── remove_redundant_body.t ├── undef_encoding_regression.t ├── optional_stress.t ├── path_action_empty_brackets.t ├── not_utf8_query_bug.t ├── dead_recursive_chained_attributes.t ├── live_component_controller_context_closure.t ├── deprecated.t ├── head_middleware.t ├── abort-chain-1.t ├── optional_apache-cgi.pl ├── optional_apache-fastcgi.pl ├── optional_apache-cgi-rewrite.pl ├── plugin_new_method_backcompat.t └── undef-params.t ├── xt └── author │ ├── pod.t │ ├── notabs.t │ └── podcoverage.t ├── .gitignore ├── .yath.rc ├── lib └── Catalyst │ ├── Plugin │ └── Unicode │ │ └── Encoding.pm │ ├── Runtime.pm │ ├── Model.pm │ ├── Script │ ├── CGI.pm │ └── Test.pm │ ├── Engine │ └── HTTP.pm │ ├── Exception │ ├── Go.pm │ └── Detach.pm │ ├── Base.pm │ └── Exception.pm └── maint └── Makefile.PL.include /t/something/Makefile.PL: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /t/something/script/foo/bar/for_dist: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /t/utf8.txt: -------------------------------------------------------------------------------- 1 |

This is stream_body_fh action ♥

2 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/share/static/forced.txt: -------------------------------------------------------------------------------- 1 | forced message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/share/static/message.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/share/static2/message2.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/share/static3/message3.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/01use.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | 3 | use_ok('Catalyst'); 4 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/share/static/forced.txt: -------------------------------------------------------------------------------- 1 | forced message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/share/static/message.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/share/static2/message2.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/share/static3/message3.txt: -------------------------------------------------------------------------------- 1 | static message 2 | -------------------------------------------------------------------------------- /t/catalyst_130pix.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/perl-catalyst/catalyst-runtime/HEAD/t/catalyst_130pix.gif -------------------------------------------------------------------------------- /xt/author/pod.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use Test::Pod 1.14; 6 | 7 | all_pod_files_ok(); 8 | -------------------------------------------------------------------------------- /t/lib/TestPath.pm: -------------------------------------------------------------------------------- 1 | package TestPath; 2 | use strict; 3 | use warnings; 4 | use Catalyst; 5 | 6 | __PACKAGE__->setup; 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp; 2 | use Moose; 3 | 4 | extends 'Catalyst'; 5 | 6 | __PACKAGE__->setup; 7 | 1; 8 | 9 | -------------------------------------------------------------------------------- /xt/author/notabs.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use File::Spec; 5 | use Test::More; 6 | use Test::NoTabs; 7 | 8 | all_perl_files_ok(qw/lib/); 9 | -------------------------------------------------------------------------------- /t/lib/TestAppMetaCompat/Controller/Base.pm: -------------------------------------------------------------------------------- 1 | package TestAppMetaCompat::Controller::Base; 2 | 3 | use strict; 4 | use base qw/Catalyst::Controller/; 5 | 6 | 1; 7 | -------------------------------------------------------------------------------- /t/lib/TestAppNonMooseController/ControllerBase.pm: -------------------------------------------------------------------------------- 1 | package TestAppNonMooseController::ControllerBase; 2 | use base qw/Catalyst::Controller/; 3 | 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /t/lib/TestApp/Model/Foo/Bar.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Model::Foo::Bar; 2 | 3 | sub model_foo_bar_method_from_foo_bar { "model_foo_bar_method_from_foo_bar" } 4 | 5 | 1; 6 | -------------------------------------------------------------------------------- /t/lib/TestAppNonMooseController.pm: -------------------------------------------------------------------------------- 1 | package TestAppNonMooseController; 2 | use base qw/Catalyst/; 3 | use Catalyst; 4 | 5 | __PACKAGE__->setup; 6 | 7 | 1; 8 | 9 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/Custom.pm: -------------------------------------------------------------------------------- 1 | package TestMiddleware::Custom; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use parent qw/Plack::Middleware::Static/; 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/aggregate/unit_metaclass_compat_non_moose.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use lib 't/lib'; 4 | use Test::More tests => 1; 5 | use_ok('TestAppMetaCompat'); 6 | 7 | -------------------------------------------------------------------------------- /t/lib/TestAppMetaCompat.pm: -------------------------------------------------------------------------------- 1 | package TestAppMetaCompat; 2 | use base qw/Catalyst/; 3 | 4 | __PACKAGE__->config(name => __PACKAGE__); 5 | __PACKAGE__->setup; 6 | 7 | 1; 8 | 9 | -------------------------------------------------------------------------------- /t/lib/TestAppNonMooseController/Controller/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestAppNonMooseController::Controller::Foo; 2 | use base qw/TestAppNonMooseController::ControllerBase/; 3 | 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/Custom.pm: -------------------------------------------------------------------------------- 1 | package TestMiddlewareFromPlugin::Custom; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use parent qw/Plack::Middleware::Static/; 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/Script/CompileTest.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::Script::CompileTest; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | die("Does not compile"); 6 | 7 | 1; 8 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Immutable.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Immutable; 2 | use Moose; 3 | BEGIN { extends 'Catalyst::Controller' } 4 | no Moose; 5 | __PACKAGE__->meta->make_immutable; 6 | -------------------------------------------------------------------------------- /t/lib/TestDataHandlers.pm: -------------------------------------------------------------------------------- 1 | package TestDataHandlers; 2 | 3 | use Catalyst; 4 | 5 | __PACKAGE__->config( 6 | 'Controller::Root', { namespace => '' } 7 | ); 8 | 9 | __PACKAGE__->setup; 10 | -------------------------------------------------------------------------------- /t/lib/TestAppMetaCompat/Controller/Books.pm: -------------------------------------------------------------------------------- 1 | package TestAppMetaCompat::Controller::Books; 2 | 3 | use strict; 4 | use base qw/TestAppMetaCompat::Controller::Base/; 5 | 6 | sub edit : Local {} 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Script/Bar.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Script::Bar; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | with 'Catalyst::ScriptRole'; 6 | 7 | sub run { __PACKAGE__ } 8 | 9 | 1; 10 | -------------------------------------------------------------------------------- /t/lib/TestAppOneView.pm: -------------------------------------------------------------------------------- 1 | package TestAppOneView; 2 | use strict; 3 | use warnings; 4 | use TestLogger; 5 | use Catalyst; 6 | 7 | __PACKAGE__->log(TestLogger->new); 8 | 9 | __PACKAGE__->setup; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/Test/Apple.pm: -------------------------------------------------------------------------------- 1 | package Test::Apple; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use parent qw/Catalyst::Controller/; 7 | 8 | sub default :Path { 9 | } 10 | 11 | sub apple :Local { 12 | } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/Script/Bar.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::Script::Bar; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | with 'Catalyst::ScriptRole'; 6 | 7 | sub run { __PACKAGE__ } 8 | 9 | 1; 10 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/Script/Foo.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::Script::Foo; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | with 'Catalyst::ScriptRole'; 6 | 7 | sub run { __PACKAGE__ } 8 | 9 | 1; 10 | -------------------------------------------------------------------------------- /t/lib/TestAppIndexDefault.pm: -------------------------------------------------------------------------------- 1 | package TestAppIndexDefault; 2 | use strict; 3 | use warnings; 4 | use TestLogger; 5 | use Catalyst; 6 | 7 | __PACKAGE__->log(TestLogger->new); 8 | 9 | __PACKAGE__->setup; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestAppEncoding.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncoding; 2 | use strict; 3 | use warnings; 4 | use base qw/Catalyst/; 5 | use Catalyst; 6 | 7 | __PACKAGE__->config(name => __PACKAGE__); 8 | __PACKAGE__->setup; 9 | 10 | 1; 11 | 12 | -------------------------------------------------------------------------------- /t/lib/TestAppMatchSingleArg.pm: -------------------------------------------------------------------------------- 1 | package TestAppMatchSingleArg; 2 | use strict; 3 | use warnings; 4 | use TestLogger; 5 | use Catalyst; 6 | 7 | __PACKAGE__->log(TestLogger->new); 8 | 9 | __PACKAGE__->setup; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/ActionRole/Guff.pm: -------------------------------------------------------------------------------- 1 | package TestApp::ActionRole::Guff; 2 | 3 | use Moose::Role; 4 | 5 | after execute => sub { 6 | my ($self, $controller, $c) = @_; 7 | $c->response->body(__PACKAGE__); 8 | }; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Priorities/loc_vs_index.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Priorities::loc_vs_index; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub index :Private { $_[1]->res->body( 'index' ) } 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Priorities/path_vs_index.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Priorities::path_vs_index; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub index :Private { $_[1]->res->body( 'index' ) } 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/TestAppEncodingSetInPlugin.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncodingSetInPlugin; 2 | use Moose; 3 | 4 | use Catalyst qw/+TestAppEncodingSetInPlugin::SetEncoding/; 5 | 6 | extends 'Catalyst'; 7 | 8 | __PACKAGE__->setup; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/TestAppWithMeta.pm: -------------------------------------------------------------------------------- 1 | package TestAppWithMeta; 2 | use strict; 3 | use warnings; 4 | use Catalyst; 5 | 6 | no warnings 'redefine'; 7 | sub meta {} 8 | use warnings 'redefine'; 9 | 10 | __PACKAGE__->setup; 11 | 12 | 1; 13 | 14 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Priorities/locre_vs_index.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Priorities::locre_vs_index; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub index :Private { $_[1]->res->body( 'index' ) } 7 | 8 | 1; 9 | -------------------------------------------------------------------------------- /t/lib/TestAppToTestScripts.pm: -------------------------------------------------------------------------------- 1 | package TestAppToTestScripts; 2 | use strict; 3 | use warnings; 4 | use Carp; 5 | 6 | our @RUN_ARGS; 7 | 8 | sub run { 9 | @RUN_ARGS = @_; 10 | 1; # Does this work? 11 | } 12 | 13 | 1; 14 | 15 | -------------------------------------------------------------------------------- /t/lib/Guff.pm: -------------------------------------------------------------------------------- 1 | package Guff; 2 | 3 | use Moose::Role; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | after execute => sub { 7 | my ($self, $controller, $c) = @_; 8 | $c->response->body(__PACKAGE__); 9 | }; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/aggregate/to_app.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin; 4 | use lib "$FindBin::Bin/../lib"; 5 | use TestApp; 6 | use Test::More; 7 | 8 | ok(TestApp->can('to_app')); 9 | is(ref(TestApp->to_app), 'CODE'); 10 | 11 | done_testing; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/DispatchType/CustomPostLoad.pm: -------------------------------------------------------------------------------- 1 | package TestApp::DispatchType::CustomPostLoad; 2 | use strict; 3 | use warnings; 4 | use base qw/Catalyst::DispatchType::Path/; 5 | 6 | # Never match anything.. 7 | sub match { } 8 | 9 | 1; 10 | 11 | -------------------------------------------------------------------------------- /t/lib/TestApp/DispatchType/CustomPreLoad.pm: -------------------------------------------------------------------------------- 1 | package TestApp::DispatchType::CustomPreLoad; 2 | use strict; 3 | use warnings; 4 | use base qw/Catalyst::DispatchType::Path/; 5 | 6 | # Never match anything.. 7 | sub match { } 8 | 9 | 1; 10 | 11 | -------------------------------------------------------------------------------- /t/lib/TestAppEncodingSetInApp.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncodingSetInApp; 2 | use Moose; 3 | 4 | use Catalyst; 5 | 6 | extends 'Catalyst'; 7 | 8 | __PACKAGE__->config( 9 | encoding => 'UTF-8', 10 | ); 11 | 12 | __PACKAGE__->setup; 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/TestAppOneView/View/Dummy.pm: -------------------------------------------------------------------------------- 1 | package TestAppOneView::View::Dummy; 2 | 3 | use base 'Catalyst::View'; 4 | 5 | sub COMPONENT { 6 | bless {}, 'AClass' 7 | } 8 | 9 | package AClass; 10 | 11 | use base 'Catalyst::View'; 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Index.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Index; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub index : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->body( 'Index index' ); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/Plugin/FullyQualified.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Plugin::FullyQualified; 2 | 3 | use strict; 4 | 5 | sub fully_qualified { 6 | my $c = shift; 7 | 8 | $c->stash->{fully_qualified} = 1; 9 | 10 | return $c; 11 | } 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /t/lib/TestFromPSGI.pm: -------------------------------------------------------------------------------- 1 | package TestFromPSGI; 2 | 3 | use Moose; 4 | use Catalyst; 5 | 6 | __PACKAGE__->config( 7 | 'Controller::Root', { namespace => '' }, 8 | use_hash_multivalue_in_request => 1, 9 | ); 10 | 11 | __PACKAGE__->setup; 12 | 13 | -------------------------------------------------------------------------------- /t/lib/TestContentNegotiation.pm: -------------------------------------------------------------------------------- 1 | package TestContentNegotiation; 2 | 3 | use Moose; 4 | use Catalyst; 5 | 6 | extends 'Catalyst'; 7 | 8 | __PACKAGE__->config( 9 | 'Controller::Root', { namespace => '' }, 10 | ); 11 | 12 | __PACKAGE__->setup; 13 | 14 | -------------------------------------------------------------------------------- /t/lib/TestApp/View/Dump/Action.pm: -------------------------------------------------------------------------------- 1 | package TestApp::View::Dump::Action; 2 | 3 | use strict; 4 | use base qw[TestApp::View::Dump]; 5 | 6 | sub process { 7 | my ( $self, $c ) = @_; 8 | return $self->SUPER::process( $c, $c->action, 0 ); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::Controller::Root; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | sub default : Chained('/') PathPart('') Args() {} 8 | 9 | 1; 10 | 11 | -------------------------------------------------------------------------------- /t/lib/TestAppChainedAbsolutePathPart/Controller/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestAppChainedAbsolutePathPart::Controller::Foo; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Controller/; 7 | 8 | sub foo : Chained PathPart('/foo/bar') Args(1) { } 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/TestAppEncodingSetInPlugin/SetEncoding.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncodingSetInPlugin::SetEncoding; 2 | use strict; 3 | use warnings; 4 | 5 | sub setup { 6 | my $c = shift; 7 | $c->config(encoding => 'UTF-8'); 8 | $c->next::method(@_); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestAppIndexDefault/Controller/IndexPrivate.pm: -------------------------------------------------------------------------------- 1 | package TestAppIndexDefault::Controller::IndexPrivate; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | sub index : Private { 6 | my ($self, $c) = @_; 7 | $c->res->body('index_private'); 8 | } 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_response_body.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | ok( request('/body_semipredicate')->is_success ); 11 | 12 | done_testing; 13 | -------------------------------------------------------------------------------- /t/lib/Catalyst/ActionRole/Guff.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::ActionRole::Guff; 2 | 3 | use Moose::Role; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | after execute => sub { 7 | my ($self, $controller, $c) = @_; 8 | $c->response->body(__PACKAGE__); 9 | }; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/Catalyst/ActionRole/Zoo.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::ActionRole::Zoo; 2 | 3 | use Moose::Role; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | after execute => sub { 7 | my ($self, $controller, $c) = @_; 8 | $c->response->body(__PACKAGE__); 9 | }; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Index.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Index; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub index : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->body( 'Action-Index index' ); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/RequestBaseBug.pm: -------------------------------------------------------------------------------- 1 | package TestApp::RequestBaseBug; 2 | 3 | use base 'Catalyst::Request'; 4 | 5 | sub uri { 6 | my $self = shift; 7 | 8 | # this goes into infinite mutual recursion 9 | $self->base; 10 | 11 | $self->SUPER::uri(@_) 12 | } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/TraitFor/Script.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::TraitFor::Script; 2 | use Moose::Role; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | around run => sub { 6 | my ($orig, $self, @args) = @_; 7 | return 'moo' . $self->$orig(@args); 8 | }; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/DeprecatedTestApp.pm: -------------------------------------------------------------------------------- 1 | package DeprecatedTestApp; 2 | 3 | use strict; 4 | use Catalyst qw/ 5 | Test::Deprecated 6 | /; 7 | 8 | our $VERSION = '0.01'; 9 | 10 | __PACKAGE__->config( name => 'DeprecatedTestApp', root => '/some/dir' ); 11 | 12 | __PACKAGE__->setup; 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/TraitFor/Script/Bar.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::TraitFor::Script::Bar; 2 | use Moose::Role; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | around run => sub { 6 | my ($orig, $self, @args) = @_; 7 | return $self->$orig(@args) . '23'; 8 | }; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/ScriptTestApp/TraitFor/Script/Foo.pm: -------------------------------------------------------------------------------- 1 | package ScriptTestApp::TraitFor::Script::Foo; 2 | use Moose::Role; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | around run => sub { 6 | my ($orig, $self, @args) = @_; 7 | return $self->$orig(@args) . '42'; 8 | }; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/TestApp/ActionRole/Kooh.pm: -------------------------------------------------------------------------------- 1 | package TestApp::ActionRole::Kooh; 2 | 3 | use Moose::Role; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | after execute => sub { 7 | my ($self, $controller, $c) = @_; 8 | $c->response->header('X-Affe' => 'Tiger'); 9 | }; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/dead_no_unknown_error.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/lib"; 5 | use Test::More tests => 1; 6 | 7 | use Catalyst (); 8 | eval { 9 | require TestAppUnknownError; 10 | }; 11 | unlike($@, qr/Unknown error/, 'No unknown error'); 12 | 13 | 1; 14 | 15 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Default.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Default; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub default : Private { 7 | my ( $self, $c ) = @_; 8 | $c->forward('TestApp::View::Dump::Request'); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/View/Dump/Body.pm: -------------------------------------------------------------------------------- 1 | package TestApp::View::Dump::Body; 2 | 3 | use strict; 4 | use base qw[TestApp::View::Dump]; 5 | 6 | sub process { 7 | my ( $self, $c ) = @_; 8 | return $self->SUPER::process( $c, $c->request->{_body} ); # FIXME, accessor doesn't work? 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestAppChainedRecursive/Controller/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestAppChainedRecursive::Controller::Foo; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Controller/; 7 | 8 | sub foo : Chained('bar') CaptureArgs(1) { } 9 | sub bar : Chained('foo') CaptureArgs(1) { } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestAppPluginWithConstructor/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppPluginWithConstructor::Controller::Root; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | __PACKAGE__->config->{namespace} = ''; 6 | 7 | sub foo : Local { 8 | my ($self, $c) = @_; 9 | $c->res->body('foo'); 10 | } 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /t/lib/TestApp/View/Dump/Request.pm: -------------------------------------------------------------------------------- 1 | package TestApp::View::Dump::Request; 2 | 3 | use strict; 4 | use base qw[TestApp::View::Dump]; 5 | 6 | sub process { 7 | my ( $self, $c ) = @_; 8 | my $r = $c->request; 9 | #local $r->{env}; 10 | return $self->SUPER::process( $c, $r ); 11 | } 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /t/aggregate/deprecated_test_import.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | use Catalyst::Test (); 6 | 7 | my $warn; 8 | { 9 | local $SIG{__WARN__} = sub { $warn = shift; }; 10 | Catalyst::Test->import(); 11 | } 12 | ok $warn; 13 | like $warn, qr/deprecated/; 14 | 15 | done_testing; 16 | 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/ForwardTo.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::ForwardTo; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub uri_check : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->body( $c->uri_for('foo/bar')->rel($c->req->base)->path ); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Moose/NoAttributes.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Moose::NoAttributes; 2 | use Moose; 3 | extends qw/Catalyst::Controller/; 4 | 5 | __PACKAGE__->config( 6 | actions => { 7 | test => { Local => undef } 8 | } 9 | ); 10 | 11 | sub test { 12 | } 13 | 14 | no Moose; 15 | 1; 16 | 17 | -------------------------------------------------------------------------------- /t/bad_middleware_error.t: -------------------------------------------------------------------------------- 1 | { 2 | package MyApp; 3 | 4 | use Catalyst; 5 | use Test::More; 6 | 7 | eval { 8 | __PACKAGE__->setup_middleware('DoesNotExist'); 1; 9 | } || do { 10 | like($@, qr/MyApp::Middleware::DoesNotExist or Plack::Middleware::DoesNotExist/); 11 | }; 12 | 13 | done_testing; 14 | } 15 | -------------------------------------------------------------------------------- /t/lib/TestAppWithoutUnicode.pm: -------------------------------------------------------------------------------- 1 | package TestAppWithoutUnicode; 2 | use strict; 3 | use warnings; 4 | use TestLogger; 5 | use base qw/Catalyst/; 6 | use Catalyst qw//; 7 | 8 | __PACKAGE__->config('name' => 'TestAppWithoutUnicode'); 9 | 10 | __PACKAGE__->log(TestLogger->new); 11 | 12 | __PACKAGE__->setup; 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/TestPath/Controller/One.pm: -------------------------------------------------------------------------------- 1 | package TestPath::Controller::One; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | sub one :Path { 8 | my ( $self, $c ) = @_; 9 | $c->response->body( 'OK' ); 10 | } 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | -------------------------------------------------------------------------------- /t/lib/TestPath/Controller/Two.pm: -------------------------------------------------------------------------------- 1 | package TestPath::Controller::Two; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | sub two :Path() { 8 | my ( $self, $c ) = @_; 9 | $c->response->body( 'OK' ); 10 | } 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Action/TestBefore.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Action::TestBefore; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Action/; 7 | 8 | sub execute { 9 | my $self = shift; 10 | my ( $controller, $c ) = @_; 11 | $c->stash->{test} = 'works'; 12 | $self->next::method( @_ ); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/ParentChain/Relative.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::ParentChain::Relative; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw/ Catalyst::Controller /; 6 | 7 | # using ../ to go up more than one level 8 | sub chained_rel_two : Chained('../../one') Args(2) { } 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Moose/MethodModifiers.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Moose::MethodModifiers; 2 | use Moose; 3 | BEGIN { extends qw/TestApp::Controller::Moose/; } 4 | 5 | after get_attribute => sub { 6 | my ($self, $c) = @_; 7 | $c->response->header( 'X-Catalyst-Test-After' => 'after called' ); 8 | }; 9 | 10 | 1; 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /MANIFEST 2 | /MANIFEST.bak 3 | /MANIFEST.SKIP 4 | /META.* 5 | /MYMETA.* 6 | /Makefile 7 | /Makefile.old 8 | /README 9 | /blib/ 10 | /pm_to_blib 11 | /Distar 12 | /Debian* 13 | *~ 14 | *# 15 | .#* 16 | *.bs 17 | /Catalyst-Runtime-*/ 18 | /Catalyst-Runtime-*.tar.gz 19 | /cover_db/ 20 | /_eumm/ 21 | /t/tmp/ 22 | /.aggregating 23 | -------------------------------------------------------------------------------- /t/lib/TestPath/Controller/Three.pm: -------------------------------------------------------------------------------- 1 | package TestPath::Controller::Three; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | sub three :Path('') { 8 | my ( $self, $c ) = @_; 9 | $c->response->body( 'OK' ); 10 | } 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | -------------------------------------------------------------------------------- /t/lib/NullPackage.pm: -------------------------------------------------------------------------------- 1 | package NullPackage; 2 | # Do nothing class, there should be no code or symbols defined here.. 3 | # Loading this works fine in 5.70, but a die was introduced in 5.80 which caused 4 | # it to fail. This has been changed to a warning to maintain back-compat. 5 | # See Catalyst::Utils::ensure_class_loaded() for more info. 6 | 1; 7 | 8 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestMiddleware::Controller::Root; 2 | 3 | use Moose; 4 | use MooseX::MethodAttributes; 5 | 6 | extends 'Catalyst::Controller'; 7 | 8 | sub default : Path { } 9 | sub welcome : Path(welcome) { 10 | pop->res->body('Welcome to Catalyst'); 11 | } 12 | 13 | __PACKAGE__->meta->make_immutable; 14 | -------------------------------------------------------------------------------- /t/lib/TestPath/Controller/Four.pm: -------------------------------------------------------------------------------- 1 | package TestPath::Controller::Four; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | sub four :Path('') :Args() { 8 | my ( $self, $c ) = @_; 9 | $c->response->body( 'OK' ); 10 | } 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_controller_actions_config.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use FindBin qw/ $Bin /; 5 | use lib "$Bin/../lib"; 6 | 7 | use TestApp; 8 | 9 | is(TestApp->controller("Action::ConfigSmashArrayRefs")->config->{action}{foo}{CustomAttr}[0], 'Bar', 'Config un-mangled. RT#65463'); 10 | 11 | done_testing; 12 | 13 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/End.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::End; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub end : Private { 7 | my ( $self, $c ) = @_; 8 | } 9 | 10 | sub default : Private { 11 | my ( $self, $c ) = @_; 12 | $c->forward('TestApp::View::Dump::Request'); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/lib/TestApp/View/Dump/Response.pm: -------------------------------------------------------------------------------- 1 | package TestApp::View::Dump::Response; 2 | 3 | use strict; 4 | use base qw[TestApp::View::Dump]; 5 | 6 | sub process { 7 | my ( $self, $c ) = @_; 8 | my $r = $c->response; 9 | local $r->{_writer}; 10 | local $r->{_reponse_cb}; 11 | return $self->SUPER::process( $c, $r ); 12 | } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin.pm: -------------------------------------------------------------------------------- 1 | package TestMiddlewareFromPlugin; 2 | 3 | use Catalyst qw/+TestMiddlewareFromPlugin::SetMiddleware/; 4 | 5 | ## Proof this is good config 6 | ##__PACKAGE__->config( do TestMiddlewareFromConfig->path_to('testmiddlewarefromplugin.pl') ); 7 | 8 | __PACKAGE__->setup_middleware('Head'); 9 | __PACKAGE__->setup; 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /t/lib/TestAppEncodingSetInPlugin/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncodingSetInPlugin::Controller::Root; 2 | use Moose; 3 | use namespace::autoclean; 4 | 5 | BEGIN { extends 'Catalyst::Controller'; } 6 | 7 | __PACKAGE__->config(namespace => ''); 8 | 9 | sub default: Local{ 10 | my ( $self, $c ) = @_; 11 | 12 | $c->res->body(''); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/lib/TestAppUnknownError.pm: -------------------------------------------------------------------------------- 1 | package TestApp; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Catalyst::Runtime 5.70; 7 | 8 | use base qw/Catalyst/; 9 | 10 | use Catalyst; 11 | 12 | __PACKAGE__->setup(); 13 | 14 | sub _test { 15 | my $self = shift; 16 | $self->_method_which_does_not_exist; 17 | } 18 | 19 | __PACKAGE__->_test; 20 | 21 | 1; 22 | 23 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestMiddlewareFromPlugin::Controller::Root; 2 | 3 | use Moose; 4 | use MooseX::MethodAttributes; 5 | 6 | extends 'Catalyst::Controller'; 7 | 8 | sub default : Path { } 9 | sub welcome : Path(welcome) { 10 | pop->res->body('Welcome to Catalyst'); 11 | } 12 | 13 | __PACKAGE__->meta->make_immutable; 14 | -------------------------------------------------------------------------------- /t/lib/TestApp/Action/TestBefore.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Action::TestBefore; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Action/; 7 | 8 | sub execute { 9 | my $self = shift; 10 | my ( $controller, $c, $test ) = @_; 11 | $c->res->header( 'X-TestAppActionTestBefore', $test ); 12 | $self->next::method( @_ ); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/lib/TestAppBadlyImmutable.pm: -------------------------------------------------------------------------------- 1 | package TestAppBadlyImmutable; 2 | use Catalyst qw/+TestPluginWithConstructor/; 3 | 4 | use base qw/Class::Accessor Catalyst/; 5 | 6 | use Test::More; 7 | 8 | __PACKAGE__->setup; 9 | 10 | __PACKAGE__->meta->make_immutable( inline_constructor => 0 ); 11 | ok __PACKAGE__->meta->is_immutable, 'Am now immutable'; 12 | 13 | 1; 14 | 15 | -------------------------------------------------------------------------------- /t/lib/TestPluginWithConstructor.pm: -------------------------------------------------------------------------------- 1 | # See t/plugin_new_method_backcompat.t 2 | package Class::Accessor::Fast; 3 | use strict; 4 | use warnings; 5 | 6 | sub new { 7 | my $class = shift; 8 | return bless $_[0], $class; 9 | } 10 | 11 | package TestPluginWithConstructor; 12 | use strict; 13 | use warnings; 14 | use base qw/Class::Accessor::Fast/; 15 | 16 | 1; 17 | 18 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_component_generating.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 3; 2 | use strict; 3 | use warnings; 4 | 5 | use lib 't/lib'; 6 | use TestApp; 7 | 8 | ok(TestApp->model('Generating'), 'knows about generating model'); 9 | ok(TestApp->model('Generated'), 'knows about the generated model'); 10 | is(TestApp->model('Generated')->foo, 'foo', 'can operate on generated model'); 11 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Args.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Args; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub args :Local { 7 | my ( $self, $c ) = @_; 8 | $c->res->body( join('',@{$c->req->args}) ); 9 | } 10 | 11 | sub params :Local { 12 | my ( $self, $c ) = splice @_, 0, 2; 13 | $c->res->body( join('',@_) ); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestAppEncodingSetInApp/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncodingSetInApp::Controller::Root; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller'; } 6 | 7 | __PACKAGE__->config(namespace => ''); 8 | 9 | sub default: Local{ 10 | my ( $self, $c ) = @_; 11 | 12 | $c->res->body(''); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/encoding_set_in_plugin.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin '$Bin'; 5 | use lib "$Bin/lib"; 6 | 7 | use Test::More; 8 | 9 | #for this test encoding => 'UTF-8' is set in a plugin 10 | use Catalyst::Test 'TestAppEncodingSetInPlugin'; 11 | 12 | my ( undef, $c ) = ctx_request('/'); 13 | isa_ok( $c->encoding, 'Encode::utf8', '$c->encoding' ); 14 | 15 | done_testing; 16 | -------------------------------------------------------------------------------- /t/lib/TestApp/ActionRole/Boo.pm: -------------------------------------------------------------------------------- 1 | package TestApp::ActionRole::Boo; 2 | 3 | use Moose::Role; 4 | 5 | has boo => ( 6 | is => 'ro', 7 | required => 1, 8 | ); 9 | 10 | around execute => sub { 11 | my ($orig, $self, $controller, $ctx, @rest) = @_; 12 | $ctx->stash(action_boo => $self->boo); 13 | return $self->$orig($controller, $ctx, @rest); 14 | }; 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/PathPrefix.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::PathPrefix; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Controller/; 7 | 8 | # this is kinda the same thing as: sub instance : Path {} 9 | # it should respond to: /action/chained/pathprefix/* 10 | sub instance : Chained('/') PathPrefix Args(1) { } 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /t/lib/TestAppIndexDefault/Controller/IndexChained.pm: -------------------------------------------------------------------------------- 1 | package TestAppIndexDefault::Controller::IndexChained; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | sub index : Chained('/') PathPart('indexchained') CaptureArgs(0) {} 6 | 7 | sub index_endpoint : Chained('index') PathPart('') Args(0) { 8 | my ($self, $c) = @_; 9 | $c->res->body('index_chained'); 10 | } 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Begin.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Begin; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub begin : Private { 7 | my ( $self, $c ) = @_; 8 | $self->SUPER::begin($c); 9 | } 10 | 11 | sub default : Private { 12 | my ( $self, $c ) = @_; 13 | $c->forward('TestApp::View::Dump::Request'); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/encoding_set_in_app.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin '$Bin'; 5 | use lib "$Bin/lib"; 6 | 7 | use Test::More; 8 | 9 | #for this test encoding => 'UTF-8' is set in TestAppEncodingSetInApp.pm 10 | use Catalyst::Test 'TestAppEncodingSetInApp'; 11 | 12 | my ( undef, $c ) = ctx_request('/'); 13 | isa_ok( $c->encoding, 'Encode::utf8', '$c->encoding' ); 14 | 15 | done_testing; 16 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Bar.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Bar; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Controller/; 7 | 8 | # 9 | # Redispatching between controllers that are not in a parent/child 10 | # relation. This is the root. 11 | # 12 | sub cross1 :PathPart('chained/cross') :CaptureArgs(1) :Chained('/') { } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Root.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Root; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw( Catalyst::Controller ); 7 | 8 | __PACKAGE__->config->{namespace} = ''; 9 | 10 | sub rootsub : PathPart Chained( '/' ) CaptureArgs( 1 ) { } 11 | sub endpointsub : PathPart Chained( 'rootsub' ) Args( 1 ) { } 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /t/lib/TestAppChainedRecursive.pm: -------------------------------------------------------------------------------- 1 | package TestAppChainedRecursive; 2 | 3 | use strict; 4 | use Catalyst qw/ 5 | Test::Errors 6 | Test::Headers 7 | /; 8 | use Catalyst::Utils; 9 | 10 | our $VERSION = '0.01'; 11 | 12 | TestAppChainedRecursive->config( 13 | name => 'TestAppChainedRecursive', 14 | root => '/some/dir' 15 | ); 16 | 17 | TestAppChainedRecursive->setup; 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /t/lib/TestAppOnDemand.pm: -------------------------------------------------------------------------------- 1 | package TestAppOnDemand; 2 | 3 | use strict; 4 | use Catalyst qw/ 5 | Test::Errors 6 | Test::Headers 7 | /; 8 | use Catalyst::Utils; 9 | 10 | our $VERSION = '0.01'; 11 | 12 | __PACKAGE__->config( 13 | name => __PACKAGE__, 14 | root => '/some/dir', 15 | parse_on_demand => 1, 16 | ); 17 | 18 | __PACKAGE__->setup; 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Script/Baz.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Script::Baz; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | use Test::More; 6 | 7 | with 'Catalyst::ScriptRole'; 8 | 9 | sub run { __PACKAGE__ } 10 | 11 | after new_with_options => sub { 12 | my ($self, %args) = @_; 13 | is_deeply \%args, { application_name => 'ScriptTestApp' }, 'App name correct'; 14 | }; 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/DieInEnd.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::DieInEnd; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub end : Private { 7 | my ( $self, $c ) = @_; 8 | die "I'm ending with death"; 9 | } 10 | 11 | sub default : Private { 12 | my ( $self, $c ) = @_; 13 | $c->forward('TestApp::View::Dump::Request'); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Large.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Large; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one : Relative { 7 | my ( $self, $c ) = @_; 8 | $c->res->output( 'x' x (100 * 1024) ); 9 | } 10 | 11 | sub two : Relative { 12 | my ( $self, $c ) = @_; 13 | $c->res->output( 'y' x (1024 * 1024) ); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Role.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Role; 2 | use Moose::Role; 3 | use namespace::clean -except => 'meta'; 4 | 5 | requires 'fully_qualified'; # Comes from TestApp::Plugin::FullyQualified 6 | 7 | our $SETUP_FINALIZE = 0; 8 | our $SETUP_DISPATCHER = 0; 9 | 10 | before 'setup_finalize' => sub { $SETUP_FINALIZE++ }; 11 | 12 | before 'setup_dispatcher' => sub { $SETUP_DISPATCHER++ }; 13 | 14 | 1; 15 | 16 | -------------------------------------------------------------------------------- /t/lib/TestAppIndexDefault/Controller/Default.pm: -------------------------------------------------------------------------------- 1 | package TestAppIndexDefault::Controller::Default; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | sub default : Private { 6 | my ($self, $c) = @_; 7 | $c->res->body('default_default'); 8 | } 9 | 10 | sub path_one_arg : Path('/default/') Args(1) { 11 | my ($self, $c) = @_; 12 | $c->res->body('default_path_one_arg'); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/unicode_plugin_config.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | BEGIN { $ENV{TESTAPP_ENCODING} = 'UTF-8' }; 6 | 7 | # setup library path 8 | use FindBin qw($Bin); 9 | use lib "$Bin/lib"; 10 | 11 | use Catalyst::Test 'TestAppUnicode'; 12 | 13 | { 14 | TestAppUnicode->encoding('UTF-8'); 15 | action_ok('/unicode', 'encoding configured ok'); 16 | } 17 | 18 | done_testing; 19 | 20 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_appclass_roles_in_plugin_list.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin qw/$Bin/; 5 | use lib "$Bin/../lib"; 6 | 7 | use Test::More tests => 2; 8 | 9 | use TestApp; 10 | use TestApp::Role; 11 | 12 | is $TestApp::Role::SETUP_FINALIZE, 1, 'TestApp->setup_finalize modifier run once'; 13 | is $TestApp::Role::SETUP_DISPATCHER, 1, 'TestApp->setup_dispacter modifier run once'; 14 | 15 | -------------------------------------------------------------------------------- /t/lib/ACLTestApp/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package ACLTestApp::Controller::Root; 2 | use Test::More; 3 | 4 | use base 'Catalyst::Controller'; 5 | 6 | __PACKAGE__->config->{namespace} = ''; 7 | 8 | sub foobar : Private { 9 | die $Catalyst::DETACH; 10 | } 11 | 12 | sub gorch : Local { 13 | my ( $self, $c, $frozjob ) = @_; 14 | is $frozjob, 'wozzle'; 15 | $c->res->body("gorch"); 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_setup_basics.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 1; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | SKIP: 11 | { 12 | if ( $ENV{CATALYST_SERVER} ) { 13 | skip "Using remote server", 1; 14 | } 15 | # Allow overriding automatic root. 16 | is( TestApp->config->{root}, '/some/dir' ); 17 | } 18 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Log.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Log; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub debug :Local { 7 | my ( $self, $c ) = @_; 8 | $c->log->debug('debug'); 9 | $c->res->body( 'logged' ); 10 | } 11 | 12 | sub info :Local { 13 | my ( $self, $c ) = @_; 14 | $c->log->info('info'); 15 | $c->res->body( 'logged' ); 16 | } 17 | 18 | 1; 19 | 20 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_setup_plugins.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 2; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | { 11 | # Allow overriding automatic root. 12 | ok( my $response = request('http://localhost/engine/response/headers/one'), 'Request' ); 13 | is( $response->header('X-Catalyst-Plugin-Setup'), '1' ); 14 | } 15 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Script/CompileTest.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Script::CompileTest; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | use Test::More; 6 | 7 | with 'Catalyst::ScriptRole'; 8 | 9 | sub run { __PACKAGE__ } 10 | 11 | after new_with_options => sub { 12 | my ($self, %args) = @_; 13 | is_deeply \%args, { application_name => 'ScriptTestApp' }, 'App name correct'; 14 | }; 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/aggregate/error_page_dump.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Fatal; 5 | 6 | use Catalyst::Engine; 7 | 8 | my $m = sub { Catalyst::Engine->_dump_error_page_element(@_) }; 9 | 10 | is exception { $m->('Scalar' => ['foo' => 'bar']) }, undef; 11 | is exception { $m->('Array' => ['foo' => []]) }, undef; 12 | is exception { $m->('Hash' => ['foo' => {}]) }, undef; 13 | 14 | done_testing; 15 | 16 | -------------------------------------------------------------------------------- /t/lib/TestAppIndexDefault/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppIndexDefault::Controller::Root; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | __PACKAGE__->config->{namespace} = ''; 6 | 7 | sub default : Private { 8 | my ($self, $c) = @_; 9 | $c->res->body('default'); 10 | } 11 | 12 | sub path_one_arg : Path('/') Args(1) { 13 | my ($self, $c) = @_; 14 | $c->res->body('path_one_arg'); 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/SetMiddleware.pm: -------------------------------------------------------------------------------- 1 | package TestMiddlewareFromPlugin::SetMiddleware; 2 | use strict; 3 | use warnings; 4 | use File::Spec; 5 | use File::Basename (); 6 | 7 | my $config_path = File::Spec->catfile(File::Basename::dirname(__FILE__), 'testmiddlewarefromplugin.pl'); 8 | 9 | sub setup { 10 | my $c = shift; 11 | $c->config(do $config_path); 12 | $c->next::method(@_); 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /t/lib/TestApp/Model.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Model; 2 | use Moose; 3 | use namespace::clean -except => 'meta'; 4 | 5 | extends 'Catalyst::Model'; 6 | 7 | # Test a closure here, r10394 made this blow up when we clone the config down 8 | # onto the subclass.. 9 | __PACKAGE__->config( 10 | escape_flags => { 11 | 'js' => sub { ${ $_[0] } =~ s/\'/\\\'/g; }, 12 | } 13 | ); 14 | 15 | __PACKAGE__->meta->make_immutable; 16 | 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Plugin/ParameterizedRole.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Plugin::ParameterizedRole; 2 | 3 | use MooseX::Role::Parameterized; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | parameter method_name => ( 7 | isa => 'Str', 8 | required => 1, 9 | ); 10 | 11 | role { 12 | my $p = shift; 13 | my $method_name = $p->method_name; 14 | 15 | method $method_name => sub { 'birne' }; 16 | }; 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/custom_exception_class_simple.t: -------------------------------------------------------------------------------- 1 | # HARNESS-NO-PRELOAD 2 | use strict; 3 | use warnings; 4 | use FindBin qw/$Bin/; 5 | use lib "$Bin/lib"; 6 | use Test::More tests => 2; 7 | use Test::Fatal; 8 | 9 | is exception { 10 | require TestAppClassExceptionSimpleTest; 11 | }, undef, 'Can load application'; 12 | 13 | 14 | is exception { 15 | Catalyst::Exception->throw 16 | }, undef, 'throw is properly stubbed out'; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /t/lib/TestDataHandlers/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestDataHandlers::Controller::Root; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | sub root :Path('/') {} 6 | 7 | sub test_json :Local { 8 | my ($self, $c) = @_; 9 | $c->res->body($c->req->body_data->{message}); 10 | } 11 | 12 | sub test_nested_for :Local { 13 | my ($self, $c) = @_; 14 | $c->res->body($c->req->body_data->{nested}->{value}); 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/lib/DeprecatedTestApp/C/Root.pm: -------------------------------------------------------------------------------- 1 | package DeprecatedTestApp::C::Root; 2 | use strict; 3 | use warnings; 4 | use base qw/Catalyst::Controller/; 5 | 6 | __PACKAGE__->config->{namespace} = ''; 7 | 8 | sub index : Private { 9 | my ( $self, $c ) = @_; 10 | $c->res->body('root index'); 11 | } 12 | 13 | sub req_user : Local { 14 | my ( $self, $c ) = @_; 15 | $c->res->body('REMOTE_USER = ' . $c->req->user); 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Auto/Bar.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Auto::Bar; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # Test chain reaction if auto action returns 0. 9 | # 10 | sub auto : Private { 0 } 11 | 12 | sub barend : Chained('.') Args(1) { } 13 | 14 | sub crossloose : Chained PathPart('chained/auto_cross') CaptureArgs(1) { } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Auto/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Auto::Foo; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # Test chain reaction if auto action returns 1. 9 | # 10 | sub auto : Private { 1 } 11 | 12 | sub fooend : Chained('.') Args(1) { } 13 | 14 | sub crossend : Chained('/action/chained/auto/bar/crossloose') Args(1) { } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Model/ClosuresInConfig.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Model::ClosuresInConfig; 2 | use Moose; 3 | use namespace::clean -except => 'meta'; 4 | 5 | extends 'TestApp::Model'; 6 | 7 | # Note - don't call ->config in here until the constructor calls it to 8 | # retrieve config, so that we get the 'copy from parent' path, 9 | # and ergo break due to the closure if dclone is used there.. 10 | 11 | __PACKAGE__->meta->make_immutable; 12 | 13 | -------------------------------------------------------------------------------- /t/lib/TestAppChainedAbsolutePathPart.pm: -------------------------------------------------------------------------------- 1 | package TestAppChainedAbsolutePathPart; 2 | 3 | use strict; 4 | use Catalyst qw/ 5 | Test::Errors 6 | Test::Headers 7 | /; 8 | use Catalyst::Utils; 9 | 10 | our $VERSION = '0.01'; 11 | 12 | TestAppChainedAbsolutePathPart 13 | ->config( 14 | name => 'TestAppChainedAbsolutePathPart', 15 | root => '/some/dir' 16 | ); 17 | 18 | TestAppChainedAbsolutePathPart->setup; 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /t/aggregate/unit_response.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use_ok('Catalyst::Response'); 6 | use_ok('Catalyst::Engine'); 7 | 8 | my $res = Catalyst::Response->new; 9 | 10 | # test aliasing of res->code for res->status 11 | $res->code(500); 12 | is($res->code, 500, 'code sets itself'); 13 | is($res->status, 500, 'code sets status'); 14 | $res->status(501); 15 | is($res->code, 501, 'status sets code'); 16 | 17 | done_testing; 18 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Auto.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Auto; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub auto : Private { 7 | my ( $self, $c ) = @_; 8 | return 1; 9 | } 10 | 11 | sub default : Private { 12 | my ( $self, $c ) = @_; 13 | $c->res->body( 'default' ); 14 | } 15 | 16 | sub one : Local { 17 | my ( $self, $c ) = @_; 18 | $c->res->body( 'one' ); 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/lib/TestApp/Model/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Model::Foo; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/ Catalyst::Model /; 7 | 8 | __PACKAGE__->config( 'quux' => 'chunkybacon' ); 9 | 10 | sub model_foo_method { 1 } 11 | 12 | sub model_quux_method { shift->{quux} } 13 | 14 | package TestApp::Model::Foo::Bar; 15 | sub model_foo_bar_method_from_foo { 1 } 16 | 17 | package TestApp::Model::Foo; 18 | sub bar { "TestApp::Model::Foo::Bar" } 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Auto/Deep.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Auto::Deep; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub auto : Private { 7 | my ( $self, $c ) = @_; 8 | return 1; 9 | } 10 | 11 | sub default : Private { 12 | my ( $self, $c ) = @_; 13 | $c->res->body( 'deep default' ); 14 | } 15 | 16 | sub one : Local { 17 | my ( $self, $c ) = @_; 18 | $c->res->body( 'deep one' ); 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/lib/TestAppStats/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppStats::Controller::Root; 2 | use strict; 3 | use warnings; 4 | use base 'Catalyst::Controller'; 5 | 6 | __PACKAGE__->config->{namespace} = ''; 7 | 8 | # Return log messages from previous request 9 | sub default : Private { 10 | my ( $self, $c ) = @_; 11 | $c->stats->profile("test"); 12 | $c->res->body(join("\n", @TestAppStats::log_messages)); 13 | @TestAppStats::log_messages = (); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestAppViewWarnings/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppViewWarnings::Controller::Root; 2 | use strict; 3 | use warnings; 4 | use base 'Catalyst::Controller'; 5 | 6 | __PACKAGE__->config->{namespace} = ''; 7 | 8 | # Return log messages from previous request 9 | sub index :Path Args() {} 10 | 11 | sub end : Action { 12 | my ($self, $c) = @_; 13 | $c->view; # Cause view lookup and ergo warning we are testing. 14 | $c->res->body('foo'); 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/lib/TestAppShowInternalActions/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppShowInternalActions::Controller::Root; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | __PACKAGE__->config(namespace => ''); 8 | 9 | sub index :Path :Args(0) { 10 | my ( $self, $c ) = @_; 11 | 12 | $c->response->body( 'hello world' ); 13 | } 14 | 15 | sub end : Action {} 16 | 17 | __PACKAGE__->meta->make_immutable; 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t: -------------------------------------------------------------------------------- 1 | use Catalyst (); 2 | 3 | { 4 | package TestApp; 5 | use base qw/Catalyst/; 6 | } 7 | { 8 | package TestApp::Controller::Base; 9 | use base qw/Catalyst::Controller/; 10 | } 11 | { 12 | package TestApp::Controller::Other; 13 | use Moose; 14 | use Test::More tests => 1; 15 | use Test::Fatal; 16 | is exception { 17 | extends 'TestApp::Controller::Base'; 18 | }, undef; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /t/lib/TestLogger.pm: -------------------------------------------------------------------------------- 1 | package TestLogger; 2 | use strict; 3 | use warnings; 4 | 5 | our @LOGS; 6 | our @ILOGS; 7 | our @ELOGS; 8 | 9 | sub new { 10 | return bless {}, __PACKAGE__; 11 | } 12 | 13 | sub debug { 14 | shift; 15 | push(@LOGS, shift()); 16 | } 17 | 18 | sub info { 19 | shift; 20 | push(@ILOGS, shift()); 21 | } 22 | 23 | sub warn { 24 | shift; 25 | push(@ELOGS, shift()); 26 | } 27 | 28 | sub error { die "Got unexpected error; $_[1]" } 29 | 1; 30 | 31 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Action/TestAfter.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Action::TestAfter; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Action/; # N.B. Keep as a non-moose class, this also 7 | # tests metaclass initialization works as expected 8 | 9 | sub execute { 10 | my $self = shift; 11 | my ( $controller, $c ) = @_; 12 | $self->next::method( @_ ); 13 | $c->res->header( 'X-Action-After', $c->stash->{after_message} ); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Priorities/MultiMethod.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Priorities::MultiMethod; 2 | 3 | use strict; 4 | use warnings; 5 | use base qw/Catalyst::Controller/; 6 | 7 | sub auto :Private { 8 | my ($self, $c) = @_; 9 | $c->res->body(join(' ', $c->action->name, @{$c->req->args})); 10 | return 1; 11 | } 12 | 13 | sub zero :Path :Args(0) { } 14 | 15 | sub one :Path :Args(1) { } 16 | 17 | sub two :Path :Args(2) { } 18 | 19 | sub not_def : Path { } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/aggregate/deprecated_test_unimported.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | use TestApp; 7 | use Catalyst::Test (); 8 | 9 | { 10 | like do { 11 | my $warning; 12 | local $SIG{__WARN__} = sub { $warning = $_[0] }; 13 | isa_ok Catalyst::Test::local_request('TestApp', '/'), 'HTTP::Response'; 14 | $warning; 15 | }, qr/deprecated/, 'local_request is deprecated'; 16 | } 17 | 18 | done_testing; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Action/TestMatchCaptures.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Action::TestMatchCaptures; 2 | 3 | use Moose; 4 | 5 | extends 'Catalyst::Action'; 6 | 7 | sub match_captures { 8 | my ($self, $c, $cap) = @_; 9 | if ($cap->[0] eq 'force') { 10 | $c->res->header( 'X-TestAppActionTestMatchCaptures', 'forcing' ); 11 | return 1; 12 | } else { 13 | $c->res->header( 'X-TestAppActionTestMatchCaptures', 'fallthrough' ); 14 | return 0; 15 | } 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Model/Generating.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Model::Generating; 2 | use Moose; 3 | extends 'Catalyst::Model'; 4 | 5 | sub BUILD { 6 | Class::MOP::Class->create( 7 | 'TestApp::Model::Generated' => ( 8 | methods => { 9 | foo => sub { 'foo' } 10 | } 11 | ) 12 | ); 13 | } 14 | 15 | sub expand_modules { 16 | return ('TestApp::Model::Generated'); 17 | } 18 | 19 | __PACKAGE__->meta->make_immutable; 20 | no Moose; 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /t/lib/TestAppWithMeta/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppWithMeta::Controller::Root; 2 | use base qw/Catalyst::Controller/; # N.B. Do not convert to Moose, so we do not 3 | # have a metaclass instance! 4 | 5 | __PACKAGE__->config( namespace => '' ); 6 | 7 | no warnings 'redefine'; 8 | sub meta { 'fnar' } 9 | use warnings 'redefine'; 10 | 11 | sub default : Private { 12 | my ($self, $c) = @_; 13 | $c->res->body($self->meta); 14 | } 15 | 16 | 1; 17 | 18 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub begin : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->header( 'X-Test-Class' => ref($self) ); 9 | $c->response->content_type('text/plain; charset=utf-8'); 10 | } 11 | 12 | sub default : Private { 13 | my ( $self, $c ) = @_; 14 | $c->res->output("Error - TestApp::Controller::Action\n"); 15 | $c->res->status(404); 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Auto/Detach.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Auto::Detach; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # For testing behaviour of a detaching auto action in a chain. 9 | # 10 | sub auto : Private { 11 | my ( $self, $c ) = @_; 12 | $c->detach( '/action/chained/auto/fw3' ); 13 | return 1; 14 | } 15 | 16 | sub detachend : Chained('/action/chained/auto/dt1') Args(1) { } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Auto/Forward.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Auto::Forward; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # For testing behaviour of a forwarding auto action in a chain. 9 | # 10 | sub auto : Private { 11 | my ( $self, $c ) = @_; 12 | $c->forward( '/action/chained/auto/fw3' ); 13 | return 1; 14 | } 15 | 16 | sub forwardend : Chained('/action/chained/auto/fw1') Args(1) { } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/TestMultipath.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::TestMultipath; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | __PACKAGE__->config( 7 | namespace => 'action/multipath' 8 | ); 9 | 10 | sub multipath : Local : Global : Path('/multipath1') : Path('multipath2') { 11 | my ( $self, $c ) = @_; 12 | for my $line ( split "\n", <<'EOF' ) { 13 | foo 14 | bar 15 | baz 16 | EOF 17 | $c->res->write("$line\n"); 18 | } 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/lib/TestAppWithoutUnicode/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppWithoutUnicode::Controller::Root; 2 | 3 | use Moose; 4 | BEGIN { extends 'Catalyst::Controller' } 5 | use Encode qw(encode_utf8 decode_utf8); 6 | 7 | __PACKAGE__->config( namespace => q{} ); 8 | 9 | sub default : Private { 10 | my ( $self, $c ) = @_; 11 | my $param = decode_utf8($c->request->parameters->{'myparam'}); 12 | $c->response->body( encode_utf8($param) ); 13 | } 14 | 15 | __PACKAGE__->meta->make_immutable; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/lib/ChainedActionsApp.pm: -------------------------------------------------------------------------------- 1 | package ChainedActionsApp; 2 | use Moose; 3 | use TestLogger; 4 | 5 | use Catalyst::Runtime 5.80; 6 | 7 | use Catalyst qw//; 8 | 9 | use namespace::clean -except => [ 'meta' ]; 10 | 11 | extends 'Catalyst'; 12 | 13 | our $VERSION = "0.01"; 14 | $VERSION = eval $VERSION; 15 | 16 | __PACKAGE__->config( 17 | name => 'ChainedActionsApp', 18 | disable_component_regex_fallback => 1, 19 | ); 20 | 21 | __PACKAGE__->log(TestLogger->new); 22 | 23 | __PACKAGE__->setup; 24 | 25 | 1; 26 | -------------------------------------------------------------------------------- /t/lib/TestApp/Action/TestExtraArgsAction.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Action::TestExtraArgsAction; 2 | 3 | use Moose; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | extends 'Catalyst::Action'; 7 | 8 | has [qw/extra_arg another_extra_arg/] => (is => 'ro'); 9 | 10 | after execute => sub { 11 | my ($self, $controller, $ctx) = @_; 12 | $ctx->response->header('X-TestExtraArgsAction' => join q{,} => $self->extra_arg, $self->another_extra_arg); 13 | }; 14 | 15 | __PACKAGE__->meta->make_immutable; 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Auto/Default.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Auto::Default; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub begin : Private { } 7 | 8 | sub auto : Private { 9 | my ( $self, $c ) = @_; 10 | $c->stash->{auto_ran}++; 11 | return 1; 12 | } 13 | 14 | sub default : Private { 15 | my ( $self, $c ) = @_; 16 | $c->res->body( sprintf 'default (auto: %d)', $c->stash->{auto_ran} ); 17 | } 18 | 19 | sub end : Private { } 20 | 21 | 1; 22 | 23 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Headers.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Headers; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one : Relative { 7 | my ( $self, $c ) = @_; 8 | $c->res->header( 'X-Header-Catalyst' => 'Cool' ); 9 | $c->res->header( 'X-Header-Cool' => 'Catalyst' ); 10 | $c->res->header( 'X-Header-Numbers' => join ', ', 1 .. 10 ); 11 | $c->forward('TestApp::View::Dump', [ { some => [qw(fixed content)] } ]); 12 | } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/lib/TestAppUnicode.pm: -------------------------------------------------------------------------------- 1 | package TestAppUnicode; 2 | use strict; 3 | use warnings; 4 | use TestLogger; 5 | use base qw/Catalyst/; 6 | use Catalyst; 7 | 8 | __PACKAGE__->config( 9 | 'name' => 'TestAppUnicode', 10 | $ENV{TESTAPP_ENCODING} ? ( encoding => $ENV{TESTAPP_ENCODING} ) : (), 11 | ); 12 | 13 | __PACKAGE__->log(TestLogger->new); 14 | 15 | __PACKAGE__->setup; 16 | 17 | sub handle_unicode_encoding_exception { 18 | my ( $self, $param_value, $error_msg ) = @_; 19 | return $param_value; 20 | } 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Plugin/Test/MangleDollarUnderScore.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Test::MangleDollarUnderScore; 2 | use strict; 3 | use warnings; 4 | 5 | # FIXME - should proably use utf8?? 6 | our $VERSION = 0.1; # Make is_class_loaded happy 7 | 8 | # Class::Load::load_class($_) can hurt you real hard. 9 | BEGIN { $_ = q{ 10 | mst sayeth, Class::Load::load_class($_) will ruin your life 11 | rafl spokeh "i ♥ my $_"', 12 | and verrily forsooth, t0m made tests 13 | and yea, there was fail' }; } 14 | 15 | 1; 16 | __END__ 17 | 18 | -------------------------------------------------------------------------------- /t/lib/TestAppViewWarnings.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | package TestAppViewWarnings; 5 | 6 | use Catalyst; 7 | 8 | our @log_messages; 9 | 10 | __PACKAGE__->config( name => 'TestAppWarnings', root => '/some/dir', default_view => "DoesNotExist" ); 11 | 12 | __PACKAGE__->log(TestAppViewWarnings::Log->new); 13 | 14 | __PACKAGE__->setup; 15 | 16 | package TestAppViewWarnings::Log; 17 | 18 | use base qw/Catalyst::Log/; 19 | sub warn { push(@TestAppViewWarnings::log_messages, @_[1..$#_]); } 20 | 21 | 1; 22 | 23 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Errors.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Errors; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one : Relative { 7 | my ( $self, $c ) = @_; 8 | my $a = 0; 9 | my $b = 0; 10 | my $t = $a / $b; 11 | } 12 | 13 | sub two : Relative { 14 | my ( $self, $c ) = @_; 15 | $c->forward('/non/existing/path'); 16 | } 17 | 18 | sub three : Relative { 19 | my ( $self, $c ) = @_; 20 | die("I'm going to die!\n"); 21 | } 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /t/lib/TestAppClassExceptionSimpleTest.pm: -------------------------------------------------------------------------------- 1 | package TestAppClassExceptionSimpleTest::Exception; 2 | use strict; 3 | use warnings; 4 | 5 | sub throw {} 6 | 7 | ######### 8 | 9 | package TestAppClassExceptionSimpleTest; 10 | use strict; 11 | use warnings; 12 | 13 | use Catalyst::Utils; #< some of the scripts use Catalyst::Utils before MyApp.pm 14 | 15 | BEGIN { $Catalyst::Exception::CATALYST_EXCEPTION_CLASS = 'TestAppClassExceptionSimpleTest::Exception'; } 16 | 17 | use Catalyst; 18 | 19 | __PACKAGE__->setup; 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/ConfigSmashArrayRefs.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::ConfigSmashArrayRefs; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub foo : Action {} 7 | 8 | # check configuration for an inherited action 9 | __PACKAGE__->config( 10 | action => { 11 | foo => { CustomAttr => [ 'Bar' ] } 12 | } 13 | ); 14 | 15 | sub _parse_CustomAttr_attr { 16 | my ($self, $app, $name, $value) = @_; 17 | return CustomAttr => "PoopInYourShoes"; 18 | } 19 | 20 | 21 | 1; 22 | 23 | -------------------------------------------------------------------------------- /t/lib/TestAppDoubleAutoBug/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppDoubleAutoBug::Controller::Root; 2 | 3 | use base 'Catalyst::Controller'; 4 | 5 | __PACKAGE__->config->{namespace} = ''; 6 | 7 | sub auto : Private { 8 | my ( $self, $c ) = @_; 9 | ++$c->stash->{auto_count}; 10 | return 1; 11 | } 12 | 13 | sub default : Private { 14 | my ( $self, $c ) = @_; 15 | $c->res->body( sprintf 'default, auto=%d', $c->stash->{auto_count} ); 16 | } 17 | 18 | sub end : Private { 19 | my ($self,$c) = @_; 20 | } 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /t/lib/TestApp/Action/TestActionArgsFromConstructor.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Action::TestActionArgsFromConstructor; 2 | 3 | use Moose; 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | extends 'Catalyst::Action'; 7 | 8 | has [qw/extra_arg another_extra_arg/] => ( is => 'ro' ); 9 | 10 | after execute => sub { 11 | my ($self, $controller, $ctx) = @_; 12 | $ctx->response->header('X-TestExtraArgsAction' => join q{,} => $self->extra_arg, $self->another_extra_arg); 13 | }; 14 | 15 | __PACKAGE__->meta->make_immutable; 16 | 17 | 1; 18 | 19 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Plugin/Test/Deprecated.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Test::Deprecated; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | sub prepare { 7 | my $class = shift; 8 | # Note: This use of NEXT is deliberately left here (without a use NEXT) 9 | # to ensure back compat, as NEXT always used to be loaded, but 10 | # is now replaced by Class::C3::Adopt::NEXT. 11 | my $c = $class->NEXT::prepare(@_); 12 | $c->response->header( 'X-Catalyst-Plugin-Deprecated' => 1 ); 13 | 14 | return $c; 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /t/aggregate/live_view_warnings.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | no warnings 'once'; 4 | 5 | use FindBin; 6 | use lib "$FindBin::Bin/../lib"; 7 | 8 | use Test::More; 9 | use Catalyst::Test 'TestAppViewWarnings'; 10 | 11 | if ( $ENV{CATALYST_SERVER} ) { 12 | plan skip_all => 'Using remote server'; 13 | } 14 | 15 | { 16 | ok( my $response = request('http://localhost/'), 'Request' ); 17 | like($TestAppViewWarnings::log_messages[0], qr/Attempted to use view/s, 'View failure warning received'); 18 | 19 | } 20 | 21 | done_testing; 22 | 23 | -------------------------------------------------------------------------------- /t/aggregate/unit_controller_namespace.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More tests => 2; 5 | 6 | BEGIN { 7 | package MyApp::Controller::Foo; 8 | 9 | use base qw/Catalyst::Controller/; 10 | 11 | package MyApp::Controller::Root; 12 | 13 | use base qw/Catalyst::Controller/; 14 | 15 | __PACKAGE__->config(namespace => ''); 16 | 17 | package Stub; 18 | 19 | sub config { {} }; 20 | } 21 | 22 | is(MyApp::Controller::Foo->action_namespace('Stub'), 'foo'); 23 | 24 | is(MyApp::Controller::Root->action_namespace('Stub'), ''); 25 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/BodyParams.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::BodyParams; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub default : Private { 7 | my ( $self, $c ) = @_; 8 | $c->req->body_params({override => 'that'}); 9 | $c->res->output($c->req->body_params->{override}); 10 | $c->res->status(200); 11 | } 12 | 13 | sub no_params : Local { 14 | my ( $self, $c ) = @_; 15 | my $params = $c->req->body_parameters; 16 | $c->res->output(ref $params); 17 | $c->res->status(200); 18 | } 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /t/lib/TestAppStats.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | package TestAppStats; 5 | 6 | use Catalyst qw/ 7 | -Stats=1 8 | /; 9 | 10 | our $VERSION = '0.01'; 11 | our @log_messages; 12 | 13 | __PACKAGE__->config( name => 'TestAppStats', root => '/some/dir' ); 14 | 15 | __PACKAGE__->log(TestAppStats::Log->new); 16 | 17 | __PACKAGE__->setup; 18 | 19 | package TestAppStats::Log; 20 | use base qw/Catalyst::Log/; 21 | 22 | sub info { push(@TestAppStats::log_messages, @_); } 23 | sub debug { push(@TestAppStats::log_messages, @_); } 24 | 25 | 1; 26 | 27 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Print.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Print; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one :Relative { 7 | my ( $self, $c ) = @_; 8 | 9 | $c->res->print("foo"); 10 | } 11 | 12 | sub two :Relative { 13 | my ( $self, $c ) = @_; 14 | 15 | $c->res->print(qw/foo bar/); 16 | } 17 | 18 | sub three :Relative { 19 | my ( $self, $c ) = @_; 20 | 21 | local $, = ','; 22 | local $\ = ':'; 23 | $c->res->print(qw/foo bar baz/); 24 | } 25 | 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /t/lib/TestAppShowInternalActions.pm: -------------------------------------------------------------------------------- 1 | package TestAppShowInternalActions; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | use Catalyst::Runtime 5.80; 6 | 7 | use Catalyst qw/ -Debug /; # Debug must remain on for 8 | # t/live_show_internal_actions_warnings.t 9 | 10 | extends 'Catalyst'; 11 | 12 | __PACKAGE__->config( 13 | name => 'TestAppShowInternalActions', 14 | disable_component_resolution_regex_fallback => 1, 15 | show_internal_actions => 1, 16 | ); 17 | 18 | __PACKAGE__->setup(); 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /t/aggregate/c3_appclass_bug.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Test::More tests => 1; 3 | 4 | { 5 | package TestPlugin; 6 | use strict; 7 | 8 | sub setup { 9 | shift->maybe::next::method(@_); 10 | } 11 | } 12 | { 13 | package TestAppC3ErrorUseMoose; 14 | use Moose; 15 | 16 | use Catalyst::Runtime 5.80; 17 | 18 | use base qw/Catalyst/; 19 | use Catalyst qw/ 20 | +TestPlugin 21 | /; 22 | } 23 | 24 | use Test::Fatal; 25 | is exception { 26 | TestAppC3ErrorUseMoose->setup(); 27 | }, undef, 'No C3 error'; 28 | 29 | 1; 30 | 31 | -------------------------------------------------------------------------------- /t/lib/TestAppMatchSingleArg/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppMatchSingleArg::Controller::Root; 2 | 3 | use strict; 4 | use warnings; 5 | use base 'Catalyst::Controller'; 6 | 7 | __PACKAGE__->config->{namespace} = ''; 8 | 9 | sub match_single : Path Args(1) { 10 | my ($self, $c) = @_; 11 | $c->res->body('Path Args(1)'); 12 | } 13 | 14 | sub match_other : Path { 15 | my ($self, $c) = @_; 16 | $c->res->body('Path'); 17 | } 18 | 19 | sub match_two : Path Args(2) { 20 | my ($self, $c) = @_; 21 | $c->res->body('Path Args(2)'); 22 | } 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /.yath.rc: -------------------------------------------------------------------------------- 1 | [test] 2 | -j 4 3 | -P Catalyst 4 | -P Catalyst::Action 5 | -P Catalyst::ActionRole::ConsumesContent 6 | -P Catalyst::ActionRole::HTTPMethods 7 | -P Catalyst::ActionRole::QueryMatching 8 | -P Catalyst::ActionRole::Scheme 9 | -P Catalyst::DispatchType::Chained 10 | -P Catalyst::DispatchType::Default 11 | -P Catalyst::DispatchType::Index 12 | -P Catalyst::DispatchType::Path 13 | -P Catalyst::Dispatcher 14 | -P Catalyst::Model 15 | -P Catalyst::Request 16 | -P Catalyst::Response 17 | -P Catalyst::Stats 18 | -P Catalyst::Test 19 | -P Catalyst::View 20 | -P HTML::HeadParser 21 | -------------------------------------------------------------------------------- /t/deprecated_appclass_action_warnings.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/lib"; 6 | 7 | use Test::More; 8 | use Catalyst::Test 'DeprecatedActionsInAppClassTestApp'; 9 | 10 | plan tests => 3; 11 | 12 | my $warnings; 13 | my $logger = DeprecatedActionsInAppClassTestApp::Log->new; 14 | Catalyst->log($logger); 15 | 16 | ok( my $response = request('http://localhost/foo'), 'Request' ); 17 | ok( $response->is_success, 'Response Successful 2xx' ); 18 | is( $DeprecatedActionsInAppClassTestApp::Log::warnings, 1, 'Get the appclass action warning' ); 19 | -------------------------------------------------------------------------------- /t/lib/TestAppPluginWithConstructor.pm: -------------------------------------------------------------------------------- 1 | # See t/plugin_new_method_backcompat.t 2 | package TestAppPluginWithConstructor; 3 | use Test::More; 4 | use Test::Fatal; 5 | use Catalyst qw/+TestPluginWithConstructor/; 6 | use Moose; 7 | extends qw/Catalyst/; 8 | 9 | __PACKAGE__->setup; 10 | our $MODIFIER_FIRED = 0; 11 | 12 | is exception { 13 | before 'dispatch' => sub { $MODIFIER_FIRED = 1 } 14 | }, undef, 'Can apply method modifier'; 15 | no Moose; 16 | 17 | our $IS_IMMUTABLE_YET = __PACKAGE__->meta->is_immutable; 18 | ok !$IS_IMMUTABLE_YET, 'I am not immutable yet'; 19 | 20 | 1; 21 | 22 | -------------------------------------------------------------------------------- /t/aggregate/meta_method_unneeded.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/../lib"; 5 | use Test::More tests => 1; 6 | use Carp (); 7 | 8 | # Doing various silly things, like for example 9 | # use CGI qw/:standard/ in your conrtoller / app 10 | # will overwrite your meta method, therefore Catalyst 11 | # can't depend on it being there correctly. 12 | 13 | # This is/was demonstrated by Catalyst::Controller::WrapCGI 14 | # and Catalyst::Plugin::Cache::Curried 15 | 16 | use Catalyst::Test 'TestAppWithMeta'; 17 | 18 | ok( request('/')->is_success ); 19 | 20 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Request/Uploads.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Request::Uploads; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub slurp : Relative { 7 | my ( $self, $c ) = @_; 8 | $c->response->content_type('text/plain; charset=utf-8'); 9 | my $upload = $c->request->upload('slurp'); 10 | my $contents = $upload->slurp; 11 | my $contents2 = $upload->slurp; 12 | die("Slurp not callable multiple times") unless $contents eq $contents2; 13 | $c->response->output( $c->request->upload('slurp')->slurp ); 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /t/lib/TestAppPathBug.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | package TestAppPathBug; 5 | use strict; 6 | use warnings; 7 | use Catalyst; 8 | 9 | our $VERSION = '0.01'; 10 | 11 | __PACKAGE__->config( name => 'TestAppPathBug', root => '/some/dir' ); 12 | 13 | __PACKAGE__->log(TestAppPathBug::Log->new); 14 | __PACKAGE__->setup; 15 | 16 | sub foo : Path { 17 | my ( $self, $c ) = @_; 18 | $c->res->body( 'This is the foo method.' ); 19 | } 20 | 21 | package TestAppPathBug::Log; 22 | use strict; 23 | use warnings; 24 | use base qw/Catalyst::Log/; 25 | 26 | sub warn {} 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Auto/Abort.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Auto::Abort; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub auto : Private { 7 | my ( $self, $c ) = @_; 8 | return 0; 9 | } 10 | 11 | sub default : Private { 12 | my ( $self, $c ) = @_; 13 | $c->res->body( 'abort default' ); 14 | } 15 | 16 | sub end : Private { 17 | my ( $self, $c ) = @_; 18 | $c->res->body( 'abort end' ) unless $c->res->body; 19 | } 20 | 21 | sub one : Local { 22 | my ( $self, $c ) = @_; 23 | $c->res->body( 'abort one' ); 24 | } 25 | 26 | 1; 27 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Global.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Global; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub action_global_one : Action Absolute { 7 | my ( $self, $c ) = @_; 8 | $c->forward('TestApp::View::Dump::Request'); 9 | } 10 | 11 | sub action_global_two : Action Global { 12 | my ( $self, $c ) = @_; 13 | $c->forward('TestApp::View::Dump::Request'); 14 | } 15 | 16 | sub action_global_three : Action Path('/action_global_three') { 17 | my ( $self, $c ) = @_; 18 | $c->forward('TestApp::View::Dump::Request'); 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/lib/TestApp/Action/TestMyAction.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Action::TestMyAction; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Action/; 7 | 8 | sub execute { 9 | my $self = shift; 10 | my ( $controller, $c, $test ) = @_; 11 | $c->res->header( 'X-TestAppActionTestMyAction', 'MyAction works' ); 12 | $c->res->header( 'X-Component-Name-Action', $controller->catalyst_component_name); 13 | $c->res->header( 'X-Component-Instance-Name-Action', ref($controller)); 14 | $c->res->header( 'X-Class-In-Action', $self->class); 15 | $self->next::method(@_); 16 | } 17 | 18 | 1; 19 | 20 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_action_for.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More; 8 | 9 | plan tests => 4; 10 | 11 | use_ok('TestApp'); 12 | 13 | is(TestApp->action_for('global_action')->code, TestApp::Controller::Root->can('global_action'), 14 | 'action_for on appclass ok'); 15 | 16 | is(TestApp->controller('Args')->action_for('args')->code, 17 | TestApp::Controller::Args->can('args'), 18 | 'action_for on controller ok'); 19 | is(TestApp->controller('Args')->action_for('args').'', 20 | 'args/args', 21 | 'action stringifies'); 22 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Keyword.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Keyword; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | # 7 | # Due to 'actions' being used as an attribute up to cat 5.80003 using this name 8 | # for an action causes a weird error, as this would be called during BUILD time 9 | # of the Catalyst::Controller class 10 | # 11 | 12 | sub actions : Local { 13 | my ( $self, $c ) = @_; 14 | die("Call to controller action method without context! Probably naming clash") unless $c; 15 | $c->res->output("Test case for using 'actions' as a catalyst action name\n"); 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /t/aggregate/unit_metaclass_compat_non_moose_controller.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 1; 8 | use Test::Fatal; 9 | use TestAppNonMooseController; 10 | 11 | # Metaclass init order causes fail. 12 | # There are TODO tests in Moose for this, see 13 | # f2391d17574eff81d911b97be15ea51080500003 14 | # after which the evil kludge in core can die in a fire. 15 | 16 | is exception { 17 | TestAppNonMooseController::ControllerBase->get_action_methods 18 | }, undef, 'Base class->get_action_methods ok when sub class initialized first'; 19 | 20 | -------------------------------------------------------------------------------- /t/lib/ACLTestApp.pm: -------------------------------------------------------------------------------- 1 | package ACLTestApp; 2 | use Test::More; 3 | 4 | use strict; 5 | use warnings; 6 | use MRO::Compat; 7 | use Scalar::Util (); 8 | use TestLogger; 9 | 10 | use base qw/Catalyst Catalyst::Controller/; 11 | use Catalyst qw//; 12 | 13 | __PACKAGE__->log(TestLogger->new); 14 | 15 | sub execute { 16 | my $c = shift; 17 | my ( $class, $action ) = @_; 18 | 19 | if ( Scalar::Util::blessed($action) 20 | and $action->name ne "foobar" ) { 21 | eval { $c->detach( 'foobar', [$action, 'foo'] ) }; 22 | } 23 | 24 | $c->next::method( @_ ); 25 | } 26 | 27 | __PACKAGE__->setup; 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_component_mro.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | use strict; 3 | use warnings; 4 | 5 | { 6 | package MyApp::Component; 7 | use Test::More; 8 | 9 | sub COMPONENT { 10 | fail 'This no longer gets dispatched to'; 11 | } 12 | 13 | package MyApp::MyComponent; 14 | 15 | use base 'Catalyst::Component', 'MyApp::Component'; 16 | 17 | } 18 | 19 | my $warn = ''; 20 | { 21 | local $SIG{__WARN__} = sub { 22 | $warn .= $_[0]; 23 | }; 24 | MyApp::MyComponent->COMPONENT('MyApp'); 25 | } 26 | 27 | like($warn, qr/after Catalyst::Component in MyApp::Component/, 28 | 'correct warning thrown'); 29 | 30 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_response_emptybody.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | # body '0' 11 | { 12 | my $res = request('/zerobody'); 13 | is $res->content, '0'; 14 | is $res->header('Content-Length'), '1'; 15 | } 16 | 17 | # body '' 18 | { 19 | my $res = request('/emptybody'); 20 | is $res->content, ''; 21 | 22 | SKIP: { 23 | skip "content-length for body of '' is now server dependent", 1; 24 | ok !defined $res->header('Content-Length'); 25 | } 26 | } 27 | 28 | done_testing; 29 | 30 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_response_print.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 9; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | my $expected = { 11 | one => "foo", 12 | two => "foobar", 13 | three => "foo,bar,baz:", 14 | }; 15 | 16 | for my $action ( sort keys %{$expected} ) { 17 | ok( my $response = request('http://localhost/engine/response/print/' . $action ), 18 | 'Request' ); 19 | ok( $response->is_success, "Response $action successful 2xx" ); 20 | 21 | is( $response->content, $expected->{$action}, "Content $action OK" ); 22 | } 23 | -------------------------------------------------------------------------------- /t/no_test_stash_bug.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | 4 | # For reported: https://rt.cpan.org/Ticket/Display.html?id=97948 5 | 6 | { 7 | package MyApp::Controller::Root; 8 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 9 | 10 | use base 'Catalyst::Controller'; 11 | 12 | sub example :Local Args(0) { 13 | pop->stash->{testing1} = 'testing2'; 14 | } 15 | 16 | package MyApp; 17 | use Catalyst; 18 | 19 | MyApp->setup; 20 | } 21 | 22 | use Test::More; 23 | use Catalyst::Test 'MyApp'; 24 | 25 | my ($res, $c) = ctx_request('/root/example'); 26 | is $c->stash->{testing1}, 'testing2', 'got expected stash value'; 27 | 28 | done_testing; 29 | -------------------------------------------------------------------------------- /t/aggregate/live_loop.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 3; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | SKIP: 11 | { 12 | # Net::HTTP::Methods crashes when talking to a remote server because this 13 | # test causes a very long header line to be sent 14 | if ( $ENV{CATALYST_SERVER} ) { 15 | skip 'Using remote server', 3; 16 | } 17 | 18 | ok( my $response = request('http://localhost/loop_test'), 'Request' ); 19 | ok( $response->is_success, 'Response Successful 2xx' ); 20 | ok( $response->header('X-Class-Forward-Test-Method'), 'Loop OK' ); 21 | } 22 | -------------------------------------------------------------------------------- /lib/Catalyst/Plugin/Unicode/Encoding.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Unicode::Encoding; 2 | use strict; 3 | use warnings; 4 | 5 | our $VERSION = '5.90132'; 6 | $VERSION =~ tr/_//d; 7 | 8 | 1; 9 | 10 | =head1 NAME 11 | 12 | Catalyst::Plugin::Unicode::Encoding - Unicode aware Catalyst 13 | 14 | =head1 DESCRIPTION 15 | 16 | This plugin has been merged into core. This package only exists to clean out 17 | any existing versions on your installed system. 18 | 19 | =head1 AUTHORS 20 | 21 | Catalyst Contributors, see Catalyst.pm 22 | 23 | =head1 COPYRIGHT 24 | 25 | This library is free software. You can redistribute it and/or modify 26 | it under the same terms as Perl itself. 27 | 28 | =cut 29 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_action_die_in_end.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More tests => 2*$iters; 12 | use Catalyst::Test 'TestApp'; 13 | 14 | if ( $ENV{CAT_BENCHMARK} ) { 15 | require Benchmark; 16 | Benchmark::timethis( $iters, \&run_tests ); 17 | } 18 | else { 19 | for ( 1 .. $iters ) { 20 | run_tests(); 21 | } 22 | } 23 | 24 | sub run_tests { 25 | ok( my $response = request('http://localhost/action/die_in_end'), 'Request' ); 26 | ok( !$response->is_success, 'generates a 500 error' ); 27 | } 28 | -------------------------------------------------------------------------------- /t/dead_load_multiple_chained_attributes.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use lib 't/lib'; 4 | 5 | use Test::More; 6 | 7 | plan tests => 4; 8 | 9 | use Catalyst::Test 'TestApp'; 10 | 11 | eval q{ 12 | package TestApp::Controller::Action::Chained; 13 | sub should_fail : Chained('/') Chained('foo') Args(0) {} 14 | }; 15 | ok(!$@); 16 | 17 | eval { TestApp->setup_actions; }; 18 | ok($@, 'Multiple chained attributes make action setup fail'); 19 | 20 | eval q{ 21 | package TestApp::Controller::Action::Chained; 22 | no warnings 'redefine'; 23 | sub should_fail {} 24 | }; 25 | ok(!$@); 26 | 27 | eval { TestApp->setup_actions }; 28 | ok(!$@, 'And ok again') or warn $@; 29 | 30 | -------------------------------------------------------------------------------- /t/lib/TestApp/View/Dump/Env.pm: -------------------------------------------------------------------------------- 1 | package TestApp::View::Dump::Env; 2 | 3 | use strict; 4 | use base qw[TestApp::View::Dump]; 5 | 6 | sub process { 7 | my ( $self, $c ) = @_; 8 | my $env = $c->stash->{env}; 9 | return $self->SUPER::process($c, { 10 | map { ($_ => $env->{$_}) } 11 | grep { $_ ne 'psgi.input' } 12 | grep { $_ !~/^Catalyst/ } 13 | keys %{ $env }, 14 | }); 15 | } 16 | 17 | ## We override Data::Dumper here since its not reliably outputting 18 | ## something that is roundtrip-able. 19 | 20 | sub dump { 21 | my ( $self, $reference ) = @_; 22 | use Data::Dump (); 23 | return Data::Dump::dump($reference); 24 | } 25 | 26 | 1; 27 | 28 | -------------------------------------------------------------------------------- /lib/Catalyst/Runtime.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Runtime; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | BEGIN { require 5.008003; } 7 | 8 | our $VERSION = '5.90132'; 9 | $VERSION =~ tr/_//d; 10 | 11 | =head1 NAME 12 | 13 | Catalyst::Runtime - The Catalyst Framework Runtime 14 | 15 | =head1 SYNOPSIS 16 | 17 | See L. 18 | 19 | =head1 DESCRIPTION 20 | 21 | This is the primary class for the Catalyst-Runtime distribution, version 5.80. 22 | 23 | =head1 AUTHORS & COPYRIGHT 24 | 25 | Catalyst Contributors, see Catalyst.pm 26 | 27 | =head1 LICENSE 28 | 29 | This library is free software. You can redistribute it and/or modify it under 30 | the same terms as Perl itself. 31 | 32 | =cut 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /t/live_stats.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/lib"; 6 | 7 | use Test::More; 8 | use Catalyst::Test 'TestAppStats'; 9 | 10 | if ( $ENV{CATALYST_SERVER} ) { 11 | plan skip_all => 'Using remote server'; 12 | } 13 | else { 14 | plan tests => 5; 15 | } 16 | 17 | { 18 | ok( my $response = request('http://localhost/'), 'Request' ); 19 | ok( $response->is_success, 'Response Successful 2xx' ); 20 | } 21 | { 22 | ok( my $response = request('http://localhost/'), 'Request' ); 23 | ok( $response->is_success, 'Response Successful 2xx' ); 24 | like( $response->content, qr/\/default.*?[\d.]+s.*- test.*[\d.]+s/s, 'Stats report'); 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_request_escaped_path.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 6; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | # test that un-escaped can be feteched. 11 | { 12 | 13 | ok( my $response = request('http://localhost/args/params/one/two') ); 14 | ok( $response->is_success, 'Response Successful 2xx' ); 15 | is( $response->content, 'onetwo' ); 16 | } 17 | 18 | # test that request with URL-escaped code works. 19 | { 20 | ok( my $response = request('http://localhost/args/param%73/one/two') ); 21 | ok( $response->is_success, 'Response Successful 2xx' ); 22 | is( $response->content, 'onetwo' ); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/ParentChain.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::ParentChain; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw/ Catalyst::Controller /; 6 | 7 | # 8 | # Chains to the action /action/chained/parentchain in the 9 | # Action::Chained controller. 10 | # 11 | sub child :Chained('.') :Args(1) { } 12 | 13 | # Should be at /chained/rootdef/*/chained_rel/*/* 14 | sub chained_rel :Chained('../one') Args(2) { 15 | } 16 | 17 | # Should chain to loose in parent namespace - i.e. at /chained/loose/*/loose/*/* 18 | sub loose : ChainedParent Args(2) { 19 | } 20 | 21 | # Should be at /chained/cross/*/up_down/* 22 | sub up_down : Chained('../bar/cross1') Args(1) { 23 | } 24 | 25 | 1; 26 | -------------------------------------------------------------------------------- /t/aggregate/unit_utils_request.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More tests => 4; 5 | 6 | use Catalyst::Utils; 7 | 8 | { 9 | my $url = "/dump"; 10 | ok( 11 | my $request = Catalyst::Utils::request($url), 12 | "Request: simple get without protocol nor host" 13 | ); 14 | like( $request->uri, qr|^http://localhost/|, 15 | " has default protocol and host" ); 16 | } 17 | 18 | { 19 | my $url = "/dump?url=http://www.somewhere.com/"; 20 | ok( 21 | my $request = Catalyst::Utils::request($url), 22 | "Same with param containing a url" 23 | ); 24 | like( $request->uri, qr|^http://localhost/|, 25 | " has default protocol and host" ); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /t/psgi_file_testapp.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | no warnings 'once'; 4 | use FindBin qw/$Bin/; 5 | use lib "$Bin/lib"; 6 | 7 | use Test::More; 8 | 9 | use File::Spec; 10 | use File::Temp qw/ tempdir /; 11 | 12 | my $temp; 13 | BEGIN { 14 | $temp = tempdir( CLEANUP => 1 ); 15 | 16 | $ENV{CATALYST_HOME} = $temp; 17 | open(my $psgi, '>', File::Spec->catfile($temp, 'testapp.psgi')) or die; 18 | print $psgi q{ 19 | use strict; 20 | use TestApp; 21 | 22 | $main::have_loaded_psgi = 1; 23 | my $app = TestApp->psgi_app; 24 | }; 25 | close($psgi); 26 | } 27 | use Catalyst::Test qw/ TestApp /; 28 | 29 | ok request('/'); 30 | ok $main::have_loaded_psgi; 31 | 32 | done_testing; 33 | 34 | -------------------------------------------------------------------------------- /lib/Catalyst/Model.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Model; 2 | 3 | use Moose; 4 | extends qw/Catalyst::Component/; 5 | 6 | no Moose; 7 | 8 | =head1 NAME 9 | 10 | Catalyst::Model - Catalyst Model base class 11 | 12 | =head1 SYNOPSIS 13 | 14 | See L. 15 | 16 | =head1 DESCRIPTION 17 | 18 | Catalyst Model base class. 19 | 20 | =head1 METHODS 21 | 22 | Implements the same methods as other Catalyst components, see 23 | L 24 | 25 | =head1 AUTHORS 26 | 27 | Catalyst Contributors, see Catalyst.pm 28 | 29 | =head1 COPYRIGHT 30 | 31 | This library is free software. You can redistribute it and/or modify it under 32 | the same terms as Perl itself. 33 | 34 | =cut 35 | 36 | __PACKAGE__->meta->make_immutable; 37 | 38 | 1; 39 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_script_help.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Fatal; 5 | 6 | use FindBin qw/$Bin/; 7 | use lib "$Bin/../lib"; 8 | 9 | no warnings 'once'; 10 | *CORE::GLOBAL::exit = sub {}; 11 | 12 | { 13 | package TestHelpScript; 14 | use Moose; 15 | with 'Catalyst::ScriptRole'; 16 | our $help; 17 | sub print_usage_text { $help++ } 18 | } 19 | 20 | test('--help'); 21 | test('-?'); 22 | 23 | sub test { 24 | local $TestHelpScript::help; 25 | local @ARGV = (@_); 26 | is exception { 27 | TestHelpScript->new_with_options(application_name => 'TestAppToTestScripts')->run; 28 | }, undef, 'Lives'; 29 | ok $TestHelpScript::help, 'Got help'; 30 | } 31 | 32 | done_testing; 33 | -------------------------------------------------------------------------------- /t/live_show_internal_actions_warnings.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin '$Bin'; 4 | use lib "$Bin/lib"; 5 | use Test::More; 6 | use File::Spec; 7 | BEGIN { # Shut up debug output, app needs debug on for the issue to 8 | # appear, but we don't want the spraff to the screen 9 | 10 | my $devnull = File::Spec->devnull; 11 | open my $fh, '>', $devnull or die "Cannot write to $devnull: $!"; 12 | 13 | *STDERR = $fh; 14 | } 15 | 16 | use Catalyst::Test 'TestAppShowInternalActions'; 17 | 18 | my $last_warning; 19 | { 20 | local $SIG{__WARN__} = sub { $last_warning = shift }; 21 | my $res = get('/'); 22 | } 23 | is( $last_warning, undef, 'there should be no warnings about uninitialized value' ); 24 | 25 | done_testing; 26 | -------------------------------------------------------------------------------- /t/lib/DeprecatedActionsInAppClassTestApp.pm: -------------------------------------------------------------------------------- 1 | package DeprecatedActionsInAppClassTestApp; 2 | 3 | use strict; 4 | use warnings; 5 | use Catalyst; 6 | 7 | our $VERSION = '0.01'; 8 | 9 | __PACKAGE__->config( name => 'DeprecatedActionsInAppClassTestApp', root => '/some/dir' ); 10 | __PACKAGE__->log(DeprecatedActionsInAppClassTestApp::Log->new); 11 | __PACKAGE__->setup; 12 | 13 | sub foo : Local { 14 | my ($self, $c) = @_; 15 | $c->res->body('OK'); 16 | } 17 | 18 | package DeprecatedActionsInAppClassTestApp::Log; 19 | use strict; 20 | use warnings; 21 | use base qw/Catalyst::Log/; 22 | 23 | our $warnings; 24 | 25 | sub warn { 26 | my ($self, $warning) = @_; 27 | $warnings++ if $warning =~ /action methods .+ found defined/i; 28 | } 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /t/aggregate/live_recursion.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 3; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | local $^W = 0; 11 | 12 | SKIP: 13 | { 14 | # Net::HTTP::Methods crashes when talking to a remote server because this 15 | # test causes a very long header line to be sent 16 | if ( $ENV{CATALYST_SERVER} ) { 17 | skip 'Using remote server', 3; 18 | } 19 | 20 | ok( my $response = request('http://localhost/recursion_test'), 'Request' ); 21 | ok( !$response->is_success, 'Response Not Successful' ); 22 | is( $response->header('X-Catalyst-Error'), 'Deep recursion detected calling "/recursion_test"', 'Deep Recursion Detected' ); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_response_large.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 6; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | # phaylon noticed that refactored was truncating output on large images. 11 | # This test tests 100K and 1M output content. 12 | 13 | my $expected = { 14 | one => 'x' x (100 * 1024), 15 | two => 'y' x (1024 * 1024), 16 | }; 17 | 18 | for my $action ( keys %{$expected} ) { 19 | ok( my $response = request('http://localhost/engine/response/large/' . $action ), 20 | 'Request' ); 21 | ok( $response->is_success, 'Response Successful 2xx' ); 22 | 23 | is( length( $response->content ), length( $expected->{$action} ), 'Length OK' ); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Plugin/Test/Errors.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Test::Errors; 2 | 3 | use strict; 4 | use MRO::Compat; 5 | 6 | sub error { 7 | my $c = shift; 8 | 9 | unless ( $_[0] ) { 10 | return $c->next::method(@_); 11 | } 12 | 13 | if ( $_[0] =~ /^(Unknown resource|No default action defined)/ ) { 14 | $c->response->status(404); 15 | } 16 | 17 | if ( $_[0] =~ /^Couldn\'t forward/ ) { 18 | $c->response->status(404); 19 | } 20 | 21 | if ( $_[0] =~ /^Caught exception/ ) { 22 | $c->response->status(500); 23 | } 24 | 25 | my $error = $_[0]; 26 | $error =~ s/\n/, /g; 27 | 28 | $c->response->headers->push_header( 'X-Catalyst-Error' => $error ); 29 | 30 | $c->next::method(@_); 31 | } 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_script_cgi.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin qw/$Bin/; 5 | use lib "$Bin/../lib"; 6 | 7 | use Test::More; 8 | use Test::Fatal; 9 | 10 | use Catalyst::Script::CGI; 11 | 12 | local @ARGV; 13 | is exception { 14 | Catalyst::Script::CGI->new_with_options(application_name => 'TestAppToTestScripts')->run; 15 | }, undef, "new_with_options"; 16 | shift @TestAppToTestScripts::RUN_ARGS; 17 | my $server = pop @TestAppToTestScripts::RUN_ARGS; 18 | like ref($server), qr/^Plack::Handler/, 'Is a Plack::Handler'; 19 | is ref(delete($TestAppToTestScripts::RUN_ARGS[0]->{argv})), 'ARRAY'; 20 | is ref(delete($TestAppToTestScripts::RUN_ARGS[0]->{extra_argv})), 'ARRAY'; 21 | is_deeply \@TestAppToTestScripts::RUN_ARGS, [{}], "no args"; 22 | 23 | done_testing; 24 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/ActionRoles.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::ActionRoles; 2 | 3 | use Moose; 4 | 5 | BEGIN { extends 'Catalyst::Controller' } 6 | 7 | __PACKAGE__->config( 8 | action_roles => ['~Kooh'], 9 | action_args => { 10 | frew => { boo => 'hello' }, 11 | }, 12 | ); 13 | 14 | sub foo : Local Does('Guff') {} 15 | sub bar : Local Does('~Guff') {} 16 | sub baz : Local Does('+Guff') {} 17 | sub quux : Local Does('Zoo') {} 18 | 19 | sub corge : Local Does('Guff') ActionClass('TestAfter') { 20 | my ($self, $ctx) = @_; 21 | $ctx->stash(after_message => 'moo'); 22 | } 23 | 24 | sub frew : Local Does('Boo') { 25 | my ($self, $ctx) = @_; 26 | my $boo = $ctx->stash->{action_boo}; 27 | $ctx->response->body($boo); 28 | } 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /t/aggregate/caf_backcompat.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Class::Load 'load_class'; 5 | use Moose::Util (); 6 | 7 | # List of everything which used Class::Accessor::Fast in 5.70. 8 | my @modules = qw/ 9 | Catalyst::Action 10 | Catalyst::ActionContainer 11 | Catalyst::Component 12 | Catalyst::Dispatcher 13 | Catalyst::DispatchType 14 | Catalyst::Engine 15 | Catalyst::Log 16 | Catalyst::Request::Upload 17 | Catalyst::Request 18 | Catalyst::Response 19 | /; 20 | 21 | plan tests => scalar @modules; 22 | 23 | foreach my $module (@modules) { 24 | load_class($module); 25 | ok Moose::Util::does_role($module => 'MooseX::Emulate::Class::Accessor::Fast'), 26 | "$module has Class::Accessor::Fast back-compat"; 27 | } 28 | -------------------------------------------------------------------------------- /t/lib/TestAppOneView/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppOneView::Controller::Root; 2 | 3 | use base 'Catalyst::Controller'; 4 | use Scalar::Util (); 5 | 6 | __PACKAGE__->config->{namespace} = ''; 7 | 8 | sub view_no_args : Local { 9 | my ( $self, $c ) = @_; 10 | 11 | my $v = $c->view; 12 | 13 | $c->res->body(Scalar::Util::blessed($v)); 14 | } 15 | 16 | sub view_by_name : Local { 17 | my ( $self, $c ) = @_; 18 | 19 | my $v = $c->view($c->req->param('view')); 20 | 21 | $c->res->body(Scalar::Util::blessed($v)); 22 | } 23 | 24 | sub view_by_regex : Local { 25 | my ( $self, $c ) = @_; 26 | 27 | my $v_name = $c->req->param('view'); 28 | 29 | my ($v) = $c->view(qr/$v_name/); 30 | 31 | $c->res->body(Scalar::Util::blessed($v)); 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Redirect.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Redirect; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one : Relative { 7 | my ( $self, $c ) = @_; 8 | $c->response->redirect('/test/writing/is/boring'); 9 | } 10 | 11 | sub two : Relative { 12 | my ( $self, $c ) = @_; 13 | $c->response->redirect('http://www.google.com/'); 14 | } 15 | 16 | sub three : Relative { 17 | my ( $self, $c ) = @_; 18 | $c->response->redirect('http://www.google.com/'); 19 | $c->response->status(301); # Moved Permanently 20 | } 21 | 22 | sub four : Relative { 23 | my ( $self, $c ) = @_; 24 | $c->response->redirect('http://www.google.com/'); 25 | $c->response->status(307); # Temporary Redirect 26 | } 27 | 28 | 1; 29 | 30 | -------------------------------------------------------------------------------- /t/unit_core_methodattributes_method_metaclass_on_subclasses.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Test::More; 3 | 4 | { 5 | package NoAttributes::CT; 6 | use Moose; 7 | BEGIN { extends qw/Catalyst::Controller/; }; 8 | 9 | sub test {} 10 | } 11 | { 12 | package NoAttributes::RT; 13 | use Moose; 14 | extends qw/Catalyst::Controller/; 15 | 16 | sub test {} 17 | } 18 | my $c = 0; 19 | foreach my $class (qw/ CT RT /) { 20 | my $class_name = 'NoAttributes::' . $class; 21 | my $meta = $class_name->meta; 22 | my $meth = $meta->find_method_by_name('test'); 23 | { 24 | local $TODO = "Known MX::MethodAttributes issue" if $c++; 25 | ok $meth->can('attributes'), 'method metaclass has ->attributes method for ' . $class;; 26 | } 27 | } 28 | 29 | done_testing; 30 | 31 | -------------------------------------------------------------------------------- /t/set_allowed_method.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | use Test::More; 4 | 5 | # Test case for reported issue when an action consumes JSON but a 6 | # POST sends nothing we get a hard error 7 | 8 | { 9 | package MyApp::Controller::Root; 10 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 11 | 12 | use base 'Catalyst::Controller'; 13 | 14 | sub root :Chained(/) CaptureArgs(0) { } 15 | 16 | sub get :GET Chained(root) PathPart('') Args(0) { } 17 | sub post :POST Chained(root) PathPart('') Args(0) { } 18 | sub put :PUT Chained(root) PathPart('') Args(0) { } 19 | 20 | package MyApp; 21 | use Catalyst; 22 | MyApp->setup; 23 | } 24 | 25 | use HTTP::Request::Common; 26 | use Catalyst::Test 'MyApp'; 27 | 28 | { 29 | ok my $res = request POST 'root/'; 30 | } 31 | 32 | done_testing(); 33 | -------------------------------------------------------------------------------- /t/args-empty-parens-bug.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | use Test::More; 4 | use FindBin qw< $Bin >; 5 | use lib "$Bin/lib"; 6 | use constant App => 'TestAppArgsEmptyParens'; 7 | use Catalyst::Test App; 8 | 9 | { 10 | my $res = request('/chain_base/args/foo/bar'); 11 | is $res->content, 'Args', "request '/chain_base/args/foo/bar'"; 12 | } 13 | 14 | { 15 | my $res = request('/chain_base/args_empty/foo/bar'); 16 | is $res->content, 'Args()', "request '/chain_base/args_empty/foo/bar'"; 17 | } 18 | 19 | eval { App->dispatcher->dispatch_type('Chained')->list(App) }; 20 | ok !$@, "didn't die" 21 | or diag "Died with: $@"; 22 | like $TestLogger::LOGS[-1], qr{chain_base\/args\/\.\.\.}; 23 | like $TestLogger::LOGS[-1], qr{chain_base\/args_empty\/\.\.\.}; 24 | 25 | done_testing; 26 | 27 | __END__ 28 | 29 | -------------------------------------------------------------------------------- /t/lib/TestApp/Plugin/AddDispatchTypes.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Plugin::AddDispatchTypes; 2 | use strict; 3 | use warnings; 4 | use MRO::Compat; 5 | 6 | sub setup_dispatcher { 7 | my $class = shift; 8 | 9 | ### Load custom DispatchTypes, as done by Catalyst::Plugin::Server 10 | # There should be a waaay less ugly method for doing this, 11 | # FIXME in 5.9 12 | $class->next::method( @_ ); 13 | $class->dispatcher->preload_dispatch_types( 14 | @{$class->dispatcher->preload_dispatch_types}, 15 | qw/ +TestApp::DispatchType::CustomPreLoad / 16 | ); 17 | $class->dispatcher->postload_dispatch_types( 18 | @{$class->dispatcher->postload_dispatch_types}, 19 | qw/ +TestApp::DispatchType::CustomPostLoad / 20 | ); 21 | 22 | return $class; 23 | } 24 | 25 | 1; 26 | 27 | -------------------------------------------------------------------------------- /xt/author/podcoverage.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use Pod::Coverage 0.19; 6 | use Test::Pod::Coverage 1.04; 7 | 8 | my @modules = all_modules; 9 | our @private = ( 'BUILD' ); 10 | foreach my $module (@modules) { 11 | next if $module =~ /Unicode::Encoding/; 12 | local @private = (@private, 'run', 'dont_close_all_files') if $module =~ /^Catalyst::Script::/; 13 | local @private = (@private, 'plugin') if $module =~ /^Catalyst$/; 14 | local @private = (@private, 'snippets') if $module =~ /^Catalyst::Request$/; 15 | local @private = (@private, 'prepare_connection') if $module =~ /^Catalyst::Engine$/; 16 | 17 | pod_coverage_ok($module, { 18 | also_private => \@private, 19 | coverage_class => 'Pod::Coverage::TrustPod', 20 | }); 21 | } 22 | 23 | done_testing; 24 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Local.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Local; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub one : Action Relative { 7 | my ( $self, $c ) = @_; 8 | $c->forward('TestApp::View::Dump::Request'); 9 | } 10 | 11 | sub two : Action Local Args(2) { 12 | my ( $self, $c ) = @_; 13 | $c->forward('TestApp::View::Dump::Request'); 14 | } 15 | 16 | sub three : Action Path('three') { 17 | my ( $self, $c ) = @_; 18 | $c->forward('TestApp::View::Dump::Request'); 19 | } 20 | 21 | sub four : Action Path('four/five/six') { 22 | my ( $self, $c ) = @_; 23 | $c->forward('TestApp::View::Dump::Request'); 24 | } 25 | 26 | sub five : Action Local Args(1) { 27 | my ( $self, $c ) = @_; 28 | $c->forward('TestApp::View::Dump::Request'); 29 | } 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Private.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Private; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub default : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->output('access denied'); 9 | } 10 | 11 | sub one : Private { 12 | my ( $self, $c ) = @_; 13 | $c->res->output('access allowed'); 14 | } 15 | 16 | sub two : Private { 17 | my ( $self, $c ) = @_; 18 | $c->res->output('access allowed'); 19 | } 20 | 21 | sub three : Private { 22 | my ( $self, $c ) = @_; 23 | $c->res->output('access allowed'); 24 | } 25 | 26 | sub four : Private { 27 | my ( $self, $c ) = @_; 28 | $c->res->output('access allowed'); 29 | } 30 | 31 | sub five : Private { 32 | my ( $self, $c ) = @_; 33 | $c->res->output('access allowed'); 34 | } 35 | 36 | 1; 37 | -------------------------------------------------------------------------------- /t/lib/TestAppArgsEmptyParens.pm: -------------------------------------------------------------------------------- 1 | package TestAppArgsEmptyParens::Controller::Root; 2 | $INC{'TestAppArgsEmptyParens/Controller/Root.pm'} = __FILE__; 3 | use Moose; 4 | use MooseX::MethodAttributes; 5 | 6 | extends 'Catalyst::Controller'; 7 | 8 | sub chain_base :Chained(/) PathPart('chain_base') CaptureArgs(0) { } 9 | 10 | sub args : Chained(chain_base) PathPart('args') Args { $_[1]->res->body('Args') } 11 | sub args_empty : Chained(chain_base) PathPart('args_empty') Args() { $_[1]->res->body('Args()') } 12 | 13 | TestAppArgsEmptyParens::Controller::Root->config(namespace=>''); 14 | 15 | package TestAppArgsEmptyParens; 16 | $INC{'TestAppArgsEmptyParens.pm'} = __FILE__; 17 | 18 | use Catalyst; 19 | use TestLogger; 20 | 21 | TestAppArgsEmptyParens->setup; 22 | TestAppArgsEmptyParens->log( TestLogger->new ); 23 | 24 | 1; 25 | -------------------------------------------------------------------------------- /t/accept_context_regression.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | BEGIN { 6 | package MyApp::Model::AcceptContext; 7 | use base 'Catalyst::Model'; 8 | 9 | sub ACCEPT_CONTEXT { 10 | my ($self, $c, @args) = @_; 11 | Test::More::ok( ref $c); 12 | } 13 | 14 | $INC{'MyApp/Model/AcceptContext.pm'} = __FILE__; 15 | } 16 | 17 | BEGIN { 18 | package MyApp::Controller::Root; 19 | use base 'Catalyst::Controller'; 20 | 21 | sub test_model :Local { 22 | my ($self, $c) = @_; 23 | $c->res->body('test'); 24 | } 25 | 26 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 27 | } 28 | 29 | BEGIN { 30 | package MyApp; 31 | use Catalyst; 32 | 33 | MyApp->setup; 34 | } 35 | 36 | use Catalyst::Test 'MyApp'; 37 | 38 | my ($res, $c) = ctx_request('/root/test_model'); 39 | 40 | ok $res; 41 | 42 | done_testing; 43 | -------------------------------------------------------------------------------- /t/aggregate/utf8_content_length.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/../lib"; 5 | use File::Spec; 6 | use Test::More; 7 | 8 | BEGIN { delete $ENV{CATALYST_HOME} } 9 | 10 | use Catalyst::Test qw/TestAppEncoding/; 11 | 12 | if ( $ENV{CATALYST_SERVER} ) { 13 | plan skip_all => 'This test does not run live'; 14 | exit 0; 15 | } 16 | 17 | my $fn = "$Bin/../catalyst_130pix.gif"; 18 | ok -r $fn, 'Can read catalyst_130pix.gif'; 19 | my $size = -s $fn; 20 | { 21 | my $r = request('/binary'); 22 | is $r->code, 200, '/binary OK'; 23 | is $r->header('Content-Length'), $size, '/binary correct content length'; 24 | } 25 | { 26 | my $r = request('/binary_utf8'); 27 | is $r->code, 200, '/binary_utf8 OK'; 28 | is $r->header('Content-Length'), $size, '/binary_utf8 correct content length'; 29 | } 30 | 31 | done_testing; 32 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Priorities.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Priorities; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | # 7 | # Local vs. Path (depends on definition order) 8 | # 9 | 10 | sub loc_vs_path1_loc :Path('/priorities/loc_vs_path1') { $_[1]->res->body( 'path' ) } 11 | sub loc_vs_path1 :Local { $_[1]->res->body( 'local' ) } 12 | 13 | sub loc_vs_path2 :Local { $_[1]->res->body( 'local' ) } 14 | sub loc_vs_path2_loc :Path('/priorities/loc_vs_path2') { $_[1]->res->body( 'path' ) } 15 | 16 | # 17 | # Local vs. index (has sub controller) 18 | # 19 | 20 | sub loc_vs_index :Local { $_[1]->res->body( 'local' ) } 21 | 22 | # 23 | # Path vs. index (has sub controller) 24 | # 25 | 26 | sub path_vs_idx :Path('/priorities/path_vs_index') { $_[1]->res->body( 'path' ) } 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_scriptrunner.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use FindBin qw/$Bin/; 5 | use Test::Fatal; 6 | use lib "$Bin/../lib"; 7 | 8 | use_ok('Catalyst::ScriptRunner'); 9 | 10 | is Catalyst::ScriptRunner->run('ScriptTestApp', 'Foo'), 'mooScriptTestApp::Script::Foo42', 11 | 'Script existing only in app got trait applied'; 12 | is Catalyst::ScriptRunner->run('ScriptTestApp', 'Bar'), 'mooScriptTestApp::Script::Bar23', 13 | 'Script existing in both app and Catalyst - prefers app'; 14 | is Catalyst::ScriptRunner->run('ScriptTestApp', 'Baz'), 'mooCatalyst::Script::Baz', 15 | 'Script existing only in Catalyst'; 16 | # +1 test for the params passed to new_with_options in t/lib/Catalyst/Script/Baz.pm 17 | 18 | like exception { 19 | Catalyst::ScriptRunner->run('ScriptTestApp', 'CompileTest'); 20 | }, qr/Couldn't load class/; 21 | 22 | done_testing; 23 | -------------------------------------------------------------------------------- /t/evil_stash.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | use Test::More; 4 | 5 | { 6 | package MyApp::Controller::Root; 7 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 8 | 9 | use base 'Catalyst::Controller'; 10 | 11 | sub root :Path('') Args(0) { 12 | my ($self, $c) = @_; 13 | $c->{stash}->{foo} = 'bar'; 14 | $c->stash(baz=>'boor'); 15 | $c->{stash}->{baz} = $c->stash->{baz} . 2; 16 | 17 | Test::More::is($c->stash->{foo}, 'bar'); 18 | Test::More::is($c->stash->{baz}, 'boor2'); 19 | Test::More::is($c->{stash}->{foo}, 'bar'); 20 | Test::More::is($c->{stash}->{baz}, 'boor2'); 21 | 22 | $c->res->body('return'); 23 | } 24 | 25 | package MyApp; 26 | use Catalyst; 27 | MyApp->setup; 28 | } 29 | 30 | use HTTP::Request::Common; 31 | use Catalyst::Test 'MyApp'; 32 | 33 | { 34 | ok my $res = request POST 'root/'; 35 | } 36 | 37 | done_testing(); 38 | -------------------------------------------------------------------------------- /lib/Catalyst/Script/CGI.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Script::CGI; 2 | use Moose; 3 | use namespace::clean -except => [ 'meta' ]; 4 | 5 | sub _plack_engine_name { 'CGI' } 6 | 7 | with 'Catalyst::ScriptRole'; 8 | 9 | __PACKAGE__->meta->make_immutable; 10 | 1; 11 | 12 | =head1 NAME 13 | 14 | Catalyst::Script::CGI - The CGI Catalyst Script 15 | 16 | =head1 SYNOPSIS 17 | 18 | myapp_cgi.pl [options] 19 | 20 | Options: 21 | -? --help display this help and exits 22 | 23 | =head1 DESCRIPTION 24 | 25 | This is a script to run the Catalyst engine specialized for the CGI environment. 26 | 27 | =head1 SEE ALSO 28 | 29 | L 30 | 31 | =head1 AUTHORS 32 | 33 | Catalyst Contributors, see Catalyst.pm 34 | 35 | =head1 COPYRIGHT 36 | 37 | This library is free software. You can redistribute it and/or modify it under 38 | the same terms as Perl itself. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_action_path_matchsingle.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More; 12 | use Catalyst::Test 'TestAppMatchSingleArg'; 13 | 14 | plan 'skip_all' if ( $ENV{CATALYST_SERVER} ); 15 | 16 | plan tests => 3*$iters; 17 | 18 | if ( $ENV{CAT_BENCHMARK} ) { 19 | require Benchmark; 20 | Benchmark::timethis( $iters, \&run_tests ); 21 | } 22 | else { 23 | for ( 1 .. $iters ) { 24 | run_tests(); 25 | } 26 | } 27 | 28 | sub run_tests { 29 | { 30 | is(get('/foo/bar/baz'), 'Path', 'multiple args matched :Path'); 31 | is(get('/foo'), 'Path Args(1)', 'single arg matched :Path Args(1)'); 32 | is(get('/foo/bar'), 'Path Args(2)', 'two args matched :Path Args(2)'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /t/aggregate/unit_controller_actions.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More tests => 4; 4 | 5 | use Catalyst (); 6 | { 7 | package TestController; 8 | use Moose; 9 | BEGIN { extends 'Catalyst::Controller' } 10 | 11 | sub action : Local {} 12 | 13 | sub foo : Path {} 14 | 15 | no Moose; 16 | } 17 | 18 | my $mock_app = Class::MOP::Class->create_anon_class( superclasses => ['Catalyst'] ); 19 | my $app = $mock_app->name->new; 20 | my $controller = TestController->new($app, {actions => { foo => { Path => '/some/path' }}}); 21 | 22 | ok $controller->can('_controller_actions'); 23 | is_deeply $controller->_controller_actions => { foo => { Path => '/some/path' }}; 24 | is_deeply $controller->{actions} => { foo => { Path => '/some/path' }}; # Back compat. 25 | is_deeply [ sort grep { ! /^_/ } map { $_->name } $controller->get_action_methods ], [sort qw/action foo/]; 26 | 27 | -------------------------------------------------------------------------------- /t/aggregate/custom_live_path_bug.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More tests => 2*$iters; 12 | use Catalyst::Test 'TestAppPathBug'; 13 | 14 | if ( $ENV{CAT_BENCHMARK} ) { 15 | require Benchmark; 16 | Benchmark::timethis( $iters, \&run_tests ); 17 | } 18 | else { 19 | for ( 1 .. $iters ) { 20 | run_tests(); 21 | } 22 | } 23 | 24 | sub run_tests { 25 | SKIP: 26 | { 27 | if ( $ENV{CATALYST_SERVER} ) { 28 | skip 'Using remote server', 2; 29 | } 30 | 31 | { 32 | my $expected = 'This is the foo method.'; 33 | ok( my $response = request('http://localhost/'), 'response ok' ); 34 | is( $response->content, $expected, 'Content OK' ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_ctx_attr.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$FindBin::Bin/../lib"; 5 | use Test::More; 6 | use URI; 7 | 8 | use_ok('TestApp'); 9 | 10 | my $request = Catalyst::Request->new( { 11 | _log => Catalyst::Log->new, 12 | base => URI->new('http://127.0.0.1/foo') 13 | } ); 14 | my $dispatcher = TestApp->dispatcher; 15 | my $context = TestApp->new( { 16 | request => $request, 17 | namespace => 'yada', 18 | } ); 19 | 20 | is( $context->hello_lazy, 'hello there', '$context->hello_lazy'); 21 | eval { is( $context->hello_notlazy, 'hello there', '$context->hello_notlazy') }; 22 | TODO: { 23 | local $TODO = 'we appear to have a lazy bug'; 24 | if ($@) { 25 | fail('$context->hello_notlazy'); 26 | warn $@; 27 | } 28 | } 29 | 30 | done_testing; 31 | 32 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Auto.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Auto; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # Provided for sub-auto tests. This just always returns true. 9 | # 10 | sub auto : Private { 1 } 11 | 12 | # 13 | # Simple chains with auto actions returning 1 and 0 14 | # 15 | sub foo : Chained PathPart('chained/autochain1') CaptureArgs(1) { } 16 | sub bar : Chained PathPart('chained/autochain2') CaptureArgs(1) { } 17 | 18 | # 19 | # Detaching out of an auto action. 20 | # 21 | sub dt1 : Chained PathPart('chained/auto_detach') CaptureArgs(1) { } 22 | 23 | # 24 | # Forwarding out of an auto action. 25 | # 26 | sub fw1 : Chained PathPart('chained/auto_forward') CaptureArgs(1) { } 27 | 28 | # 29 | # Target for dispatch and forward tests. 30 | # 31 | sub fw3 : Private { } 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /t/unicode_plugin_charset_utf8.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use FindBin qw/ $Bin /; 5 | use lib "$Bin/lib"; 6 | use Data::Dumper; 7 | 8 | BEGIN { 9 | # $ENV{TESTAPP_ENCODING} = 'UTF-8'; # This is now default 10 | $ENV{TESTAPP_DEBUG} = 0; 11 | $ENV{CATALYST_DEBUG} = 0; 12 | } 13 | 14 | use Catalyst::Test 'TestAppUnicode'; 15 | 16 | ok request('/capture_charset/utf-8'); 17 | is scalar(@TestLogger::LOGS), 0; 18 | 19 | ok request('/capture_charset/latin1'); 20 | is scalar(@TestLogger::LOGS), 1 21 | or diag Dumper(\@TestLogger::LOGS); 22 | 23 | @TestLogger::LOGS = (); 24 | 25 | ok request('/capture_charset/iso-8859-1; header=present'); 26 | is scalar(@TestLogger::LOGS), 1 27 | or diag Dumper(\@TestLogger::LOGS); 28 | like $TestLogger::LOGS[0], qr/content type is 'iso-8859-1'/; 29 | 30 | #like $TestLogger::ELOGS[0], qr/Unicode::Encoding plugin/; #no longer a plugin 31 | 32 | done_testing; 33 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_script_server-without_modules.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | 5 | # Package::Stash::XS has a weird =~ XS invocation during its compilation 6 | # This interferes with @INC hooks that do rematcuing on their own on 7 | # perls before 5.8.7. Just use the PP version to work around this. 8 | BEGIN { $ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP' if $] < '5.008007' } 9 | 10 | use Test::More; 11 | use Try::Tiny; 12 | 13 | my %hidden = map { (my $m = "$_.pm") =~ s{::}{/}g; $m => 1 } qw( 14 | Starman::Server 15 | Plack::Handler::Starman 16 | MooseX::Daemonize 17 | MooseX::Daemonize::Pid::File 18 | MooseX::Daemonize::Core 19 | ); 20 | local @INC = (sub { 21 | return unless exists $hidden{$_[1]}; 22 | die "Can't locate $_[1] in \@INC (hidden)\n"; 23 | }, @INC); 24 | 25 | do "$Bin/../aggregate/unit_core_script_server.t" 26 | or die $@ || 'test returned false'; 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Plugin/Test/Headers.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Test::Headers; 2 | 3 | use strict; 4 | use MRO::Compat; 5 | 6 | sub prepare { 7 | my $class = shift; 8 | 9 | my $c = $class->next::method(@_); 10 | 11 | $c->response->header( 'X-Catalyst-Engine' => $c->engine ); 12 | $c->response->header( 'X-Catalyst-Debug' => $c->debug ? 1 : 0 ); 13 | 14 | { 15 | my $components = join( ', ', sort keys %{ $c->components } ); 16 | $c->response->header( 'X-Catalyst-Components' => $components ); 17 | } 18 | 19 | { 20 | no strict 'refs'; 21 | my $plugins = join ', ', $class->registered_plugins; 22 | $c->response->header( 'X-Catalyst-Plugins' => $plugins ); 23 | } 24 | 25 | return $c; 26 | } 27 | 28 | sub prepare_action { 29 | my $c = shift; 30 | $c->next::method(@_); 31 | $c->res->header( 'X-Catalyst-Action' => $c->req->action ); 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /maint/Makefile.PL.include: -------------------------------------------------------------------------------- 1 | BEGIN { -e 'Distar' or system qw(git clone https://github.com/p5sagit/Distar.git) } 2 | use lib 'Distar/lib'; 3 | use Distar 0.001; 4 | 5 | author 'Sebastian Riedel '; 6 | 7 | manifest_include '' => '.yath.rc'; 8 | manifest_include script => 'catalyst.pl'; 9 | manifest_include t => 'catalyst_130pix.gif'; 10 | manifest_include 't/conf' => 'extra.conf.in'; 11 | manifest_include 't/lib/TestContentNegotiation/share', 'file.txt'; 12 | manifest_include 't/lib/TestMiddleware/share' => qr/.*/; 13 | manifest_include 't/lib/TestMiddlewareFromPlugin/share' => qr/.*/; 14 | manifest_include 't/lib/TestMiddlewareFromPlugin' => 'testmiddlewarefromplugin.pl'; 15 | manifest_include t => qr/optional_apache-.*\.pl/; 16 | manifest_include t => 'optional_stress.json'; 17 | manifest_include t => 'something/Makefile.PL'; 18 | manifest_include t => 'something/script/foo/bar/for_dist'; 19 | manifest_include t => 'utf8.txt'; 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /t/aggregate/unit_dispatcher_requestargs_restore.t: -------------------------------------------------------------------------------- 1 | # Insane test case for the behavior needed by Plugin::Auhorization::ACL 2 | 3 | # We have to localise $c->request->{arguments} in 4 | # Catalyst::Dispatcher::_do_forward, rather than using save and restore, 5 | # as otherwise, the calling $c->detach on an action which says 6 | # die $Catalyst:DETACH causes the request arguments to not get restored, 7 | # and therefore sub gorch gets the wrong string $frozjob parameter. 8 | 9 | # Please feel free to break this behavior once a sane hook for safely 10 | # executing another action from the dispatcher (i.e. wrapping actions) 11 | # is present, so that the Authorization::ACL plugin can be re-written 12 | # to not be full of such crazy shit. 13 | 14 | use strict; 15 | use warnings; 16 | use FindBin qw/$Bin/; 17 | use lib "$Bin/../lib"; 18 | use Catalyst::Test 'ACLTestApp'; 19 | use Test::More tests => 1; 20 | 21 | request('http://localhost/gorch/wozzle'); 22 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/ContextClosure.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::ContextClosure; 2 | 3 | use Moose; 4 | 5 | BEGIN { 6 | extends 'Catalyst::Controller'; 7 | with 'Catalyst::Component::ContextClosure'; 8 | } 9 | 10 | sub normal_closure : Local { 11 | my ($self, $ctx) = @_; 12 | $ctx->stash(closure => sub { 13 | $ctx->response->body('from normal closure'); 14 | }); 15 | $ctx->response->body('stashed normal closure'); 16 | } 17 | 18 | sub context_closure : Local { 19 | my ($self, $ctx) = @_; 20 | $ctx->stash(closure => $self->make_context_closure(sub { 21 | my ($ctx) = @_; 22 | $ctx->response->body('from context closure'); 23 | }, $ctx)); 24 | $ctx->response->body('stashed context closure'); 25 | } 26 | 27 | sub non_closure : Local { 28 | my ($self, $ctx) = @_; 29 | $ctx->stash(no_closure => "not a closure"); 30 | } 31 | 32 | __PACKAGE__->meta->make_immutable; 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /t/aggregate/live_plugin_loaded.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 5; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | my @expected = qw[ 11 | Catalyst::Plugin::Test::Errors 12 | Catalyst::Plugin::Test::Headers 13 | Catalyst::Plugin::Test::Inline 14 | Catalyst::Plugin::Test::MangleDollarUnderScore 15 | Catalyst::Plugin::Test::Plugin 16 | TestApp::Plugin::AddDispatchTypes 17 | TestApp::Plugin::FullyQualified 18 | ]; 19 | 20 | my $expected = join( ", ", @expected ); 21 | 22 | ok( my $response = request('http://localhost/dump/request'), 'Request' ); 23 | ok( $response->is_success, 'Response Successful 2xx' ); 24 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); 25 | like( $response->content, qr/'Catalyst::Request'/, 26 | 'Content is a serialized Catalyst::Request' ); 27 | is( $response->header('X-Catalyst-Plugins'), $expected, 'Loaded plugins' ); 28 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Auto/Detach.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Auto::Detach; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub auto : Private { 7 | my ( $self, $c ) = @_; 8 | $c->res->body( "detach auto" ); 9 | if ($c->req->param("with_forward_detach")) { 10 | $c->forward("with_forward_detach"); 11 | } else { 12 | $c->detach; 13 | } 14 | return 1; 15 | } 16 | 17 | sub default : Path { 18 | my ( $self, $c ) = @_; 19 | $c->res->body( 'detach default' ); 20 | } 21 | 22 | sub with_forward_detach : Private { 23 | my ($self, $c) = @_; 24 | $c->res->body( "detach with_forward_detach" ); 25 | if ($c->req->param("detach_to_action")) { 26 | $c->detach("detach_action"); 27 | } else { 28 | $c->detach; 29 | } 30 | } 31 | 32 | sub detach_action : Private { 33 | my ($self, $c) = @_; 34 | $c->res->body("detach_action"); 35 | } 36 | 37 | 1; 38 | -------------------------------------------------------------------------------- /t/lib/TestAppOnDemand/Controller/Body.pm: -------------------------------------------------------------------------------- 1 | package TestAppOnDemand::Controller::Body; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | use Data::Dump (); 7 | 8 | sub body_params : Local { 9 | my ( $self, $c ) = @_; 10 | 11 | $c->res->body( Data::Dump::dump( $c->req->body_parameters ) ); 12 | } 13 | 14 | sub query_params : Local { 15 | my ( $self, $c ) = @_; 16 | 17 | $c->res->body( Data::Dump::dump( $c->req->query_parameters ) ); 18 | } 19 | 20 | sub params : Local { 21 | my ( $self, $c ) = @_; 22 | 23 | $c->res->body( Data::Dump::dump( $c->req->parameters ) ); 24 | } 25 | 26 | sub read : Local { 27 | my ( $self, $c ) = @_; 28 | 29 | # read some data 30 | my @chunks; 31 | 32 | while ( my $data = $c->read( 10_000 ) ) { 33 | push @chunks, $data; 34 | } 35 | 36 | $c->res->content_type( 'text/plain'); 37 | 38 | $c->res->body( join ( '|', map { length $_ } @chunks ) ); 39 | } 40 | 41 | 1; 42 | -------------------------------------------------------------------------------- /t/lib/TestMiddlewareFromPlugin/testmiddlewarefromplugin.pl: -------------------------------------------------------------------------------- 1 | use Plack::Middleware::Static; 2 | 3 | my $static = Plack::Middleware::Static->new( 4 | path => qr{^/static/}, root => TestMiddlewareFromPlugin->path_to('share')); 5 | 6 | my $conf = +{ 7 | 'Controller::Root', { namespace => '' }, 8 | 'psgi_middleware', [ 9 | $static, 10 | 'Static', { path => qr{^/static2/}, root => TestMiddlewareFromPlugin->path_to('share') }, 11 | 'Runtime', 12 | '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromPlugin->path_to('share') }, 13 | sub { 14 | my $app = shift; 15 | return sub { 16 | my $env = shift; 17 | if($env->{PATH_INFO} =~m/forced/) { 18 | Plack::App::File->new(file=>TestMiddlewareFromPlugin->path_to(qw/share static forced.txt/)) 19 | ->call($env); 20 | } else { 21 | return $app->($env); 22 | } 23 | }, 24 | }, 25 | 26 | ], 27 | }; 28 | -------------------------------------------------------------------------------- /t/aggregate/live_component_view_single.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More; 12 | use Catalyst::Test 'TestAppOneView'; 13 | 14 | plan 'skip_all' if ( $ENV{CATALYST_SERVER} ); 15 | 16 | plan tests => 3*$iters; 17 | 18 | if ( $ENV{CAT_BENCHMARK} ) { 19 | require Benchmark; 20 | Benchmark::timethis( $iters, \&run_tests ); 21 | } 22 | else { 23 | for ( 1 .. $iters ) { 24 | run_tests(); 25 | } 26 | } 27 | 28 | sub run_tests { 29 | { 30 | is(get('/view_by_name?view=Dummy'), 'AClass', 31 | '$c->view("name") returns blessed instance'); 32 | is(get('/view_by_regex?view=Dummy'), 'AClass', 33 | '$c->view(qr/name/) returns blessed instance'); 34 | is(get('/view_no_args'), 'AClass', 35 | '$c->view() returns blessed instance'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_component_layers.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 6; 2 | use strict; 3 | use warnings; 4 | use lib 't/lib'; 5 | 6 | # This tests that we actually load the physical 7 | # copy of Model::Foo::Bar, in the case that Model::Foo 8 | # defines the Model::Foo::Bar namespace in memory, 9 | # but does not load the corresponding file. 10 | 11 | use_ok 'TestApp'; 12 | 13 | my $model_foo = TestApp->model('Foo'); 14 | 15 | can_ok($model_foo, 'model_foo_method'); 16 | can_ok($model_foo, 'bar'); 17 | 18 | my $model_foo_bar = $model_foo->bar; 19 | 20 | can_ok($model_foo_bar, 'model_foo_bar_method_from_foo'); 21 | can_ok($model_foo_bar, 'model_foo_bar_method_from_foo_bar'); 22 | 23 | # I commented out this line since we seem to just massively 24 | # fail on the 'you already did setup. I have no idea why its 25 | # here - jnap 26 | #TestApp->setup; 27 | 28 | is($model_foo->model_quux_method, 'chunkybacon', 'Model method getting $self->{quux} from config'); 29 | 30 | -------------------------------------------------------------------------------- /t/lib/Catalyst/Plugin/Test/Plugin.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Plugin::Test::Plugin; 2 | use Moose; 3 | use MRO::Compat; 4 | 5 | with 'Catalyst::ClassData'; 6 | 7 | __PACKAGE__->mk_classdata('ran_setup'); 8 | 9 | sub setup { 10 | my $c = shift; 11 | $c->ran_setup('1'); 12 | 13 | return $c->next::method( @_ ); 14 | } 15 | 16 | sub prepare { 17 | my $class = shift; 18 | 19 | my $c = $class->next::method(@_); 20 | $c->response->header( 'X-Catalyst-Plugin-Setup' => $c->ran_setup ); 21 | 22 | return $c; 23 | } 24 | 25 | # Note: Catalyst::Plugin::Server forces the body to 26 | # be parsed, by calling the $c->req->body method in prepare_action. 27 | # We need to test this, as this was broken by 5.80. See also 28 | # t/aggregate/live_engine_request_body.t. 29 | sub prepare_action { 30 | my $c = shift; 31 | $c->res->header('X-Have-Request-Body', 1) if $c->req->body; 32 | $c->next::method(@_); 33 | } 34 | 35 | no Moose; 36 | 1; 37 | -------------------------------------------------------------------------------- /t/lib/PluginTestApp.pm: -------------------------------------------------------------------------------- 1 | package PluginTestApp; 2 | use Test::More; 3 | 4 | use Catalyst ( 5 | 'Test::Plugin', 6 | '+TestApp::Plugin::FullyQualified', 7 | (eval { require MooseX::Role::Parameterized; 1 } 8 | ? ('+TestApp::Plugin::ParameterizedRole' => { method_name => 'affe' }) 9 | : ()), 10 | ); 11 | 12 | sub _test_plugins { 13 | my $c = shift; 14 | is_deeply [ $c->registered_plugins ], 15 | [ 16 | qw/Catalyst::Plugin::Test::Plugin 17 | TestApp::Plugin::FullyQualified/ 18 | ], 19 | '... and it should report the correct plugins'; 20 | ok $c->registered_plugins('Catalyst::Plugin::Test::Plugin'), 21 | '... or if we have a particular plugin'; 22 | ok $c->registered_plugins('Test::Plugin'), 23 | '... even if it is not fully qualified'; 24 | ok !$c->registered_plugins('No::Such::Plugin'), 25 | '... and it should return false if the plugin does not exist'; 26 | } 27 | 28 | __PACKAGE__->setup; 29 | -------------------------------------------------------------------------------- /t/aggregate/unit_engineloader.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Catalyst::EngineLoader; 5 | 6 | my $cases = { 7 | FastCGI => { 8 | expected_catalyst_engine_class => 'Catalyst::Engine', 9 | ENV => { CATALYST_ENGINE => 'FastCGI' }, 10 | }, 11 | CGI => { 12 | expected_catalyst_engine_class => 'Catalyst::Engine', 13 | ENV => { CATALYST_ENGINE => 'CGI' }, 14 | }, 15 | Apache1 => { 16 | expected_catalyst_engine_class => 'Catalyst::Engine', 17 | ENV => { CATALYST_ENGINE => 'Apache1' }, 18 | }, 19 | }; 20 | 21 | foreach my $name (keys %$cases) { 22 | local %ENV = %{ $cases->{$name}->{ENV} }; 23 | my $loader = Catalyst::EngineLoader->new(application_name => "TestApp"); 24 | if (my $expected = $cases->{$name}->{expected_catalyst_engine_class}) { 25 | is $loader->catalyst_engine_class, $expected, $name . " catalyst_engine_class"; 26 | } 27 | } 28 | 29 | done_testing; 30 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Immutable/HardToReload.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Immutable::HardToReload::Role; 2 | use Moose::Role; # Role metaclass does not have make_immutable.. 3 | no Moose::Role; 4 | 5 | package TestApp::Controller::Immutable::HardToReload; 6 | use Moose; 7 | BEGIN { extends 'Catalyst::Controller' } 8 | no Moose; 9 | __PACKAGE__->meta->make_immutable; 10 | 11 | package # Standard PAUSE hiding technique 12 | TestApp::Controller::Immutable::HardToReload::PAUSEHide; 13 | use Moose; 14 | BEGIN { extends 'Catalyst::Controller' } 15 | no Moose; 16 | __PACKAGE__->meta->make_immutable; 17 | 18 | # Not an inner package 19 | package TestApp::Controller::Immutable2; 20 | use Moose; 21 | BEGIN { extends 'Catalyst::Controller' } 22 | no Moose; 23 | __PACKAGE__->meta->make_immutable; 24 | 25 | # Not even in the app namespace 26 | package Frobnitz; 27 | use Moose; 28 | BEGIN { extends 'Catalyst::Controller' } 29 | no Moose; 30 | __PACKAGE__->meta->make_immutable; 31 | -------------------------------------------------------------------------------- /t/aggregate/catalyst_test_utf8.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/../lib"; 5 | 6 | use Test::More; 7 | # "binmode STDOUT, ':utf8'" is insufficient, see http://code.google.com/p/test-more/issues/detail?id=46#c1 8 | binmode Test::More->builder->output, ":utf8"; 9 | binmode Test::More->builder->failure_output, ":utf8"; 10 | 11 | use Catalyst::Test 'TestAppEncoding'; 12 | 13 | plan skip_all => 'This test does not run live' 14 | if $ENV{CATALYST_SERVER}; 15 | 16 | { 17 | # Test for https://rt.cpan.org/Ticket/Display.html?id=53678 18 | # Catalyst::Test::get currently returns the raw octets, but it 19 | # would be more useful if it decoded the content based on the 20 | # Content-Type charset, as Test::WWW::Mechanize::Catalyst does 21 | use utf8; 22 | my $body = get('/utf8_non_ascii_content'); 23 | utf8::decode($body); 24 | is $body, 'ʇsʎlɐʇɐɔ', 'Catalyst::Test::get returned content correctly UTF-8 encoded'; 25 | } 26 | 27 | done_testing; 28 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Moose.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Moose; 2 | 3 | use Moose; 4 | 5 | use namespace::clean -except => 'meta'; 6 | 7 | BEGIN { extends qw/Catalyst::Controller/; } 8 | use MooseX::MethodAttributes; # FIXME - You need to say this if you have 9 | # modifiers so that you get the correct 10 | # method metaclass, why does the modifier 11 | # on MODIFY_CODE_ATTRIBUTES not work. 12 | 13 | has attribute => ( 14 | is => 'ro', 15 | default => 42, 16 | ); 17 | 18 | sub get_attribute : Local { 19 | my ($self, $c) = @_; 20 | $c->response->body($self->attribute); 21 | } 22 | 23 | sub with_local_modifier : Local { 24 | my ($self, $c) = @_; 25 | $c->forward('get_attribute'); 26 | } 27 | 28 | before with_local_modifier => sub { 29 | my ($self, $c) = @_; 30 | $c->response->header( 'X-Catalyst-Test-Before' => 'before called' ); 31 | }; 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/TestRelative.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::TestRelative; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | __PACKAGE__->config( 7 | path => 'action/relative' 8 | ); 9 | 10 | sub relative : Local { 11 | my ( $self, $c ) = @_; 12 | $c->forward('/action/forward/one'); 13 | } 14 | 15 | sub relative_two : Local { 16 | my ( $self, $c ) = @_; 17 | $c->forward( 'TestApp::Controller::Action::Forward', 'one' ); 18 | } 19 | 20 | sub relative_go : Local { 21 | my ( $self, $c ) = @_; 22 | $c->go('/action/go/one'); 23 | } 24 | 25 | sub relative_go_two : Local { 26 | my ( $self, $c ) = @_; 27 | $c->go( 'TestApp::Controller::Action::Go', 'one' ); 28 | } 29 | 30 | sub relative_visit : Local { 31 | my ( $self, $c ) = @_; 32 | $c->visit('/action/visit/one'); 33 | } 34 | 35 | sub relative_visit_two : Local { 36 | my ( $self, $c ) = @_; 37 | $c->visit( 'TestApp::Controller::Action::Visit', 'one' ); 38 | } 39 | 40 | 1; 41 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_action_chained2.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/../lib"; 5 | use Catalyst::Test 'ChainedActionsApp'; 6 | use Test::More; 7 | 8 | plan 'skip_all' if $ENV{CATALYST_SERVER}; # This is not TestApp 9 | 10 | content_like('/', qr/Application Home Page/, 'Application home'); 11 | content_like('/15/GoldFinger', qr/List project GoldFinger pages/, 'GoldFinger Project Index'); 12 | content_like('/15/GoldFinger/4/007', qr/This is 007 page of GoldFinger project/, '007 page in GoldFinger Project'); 13 | 14 | content_like('/account', qr/New account o login/, 'no account'); 15 | content_like('/account/ferz', qr/This is account ferz/, '/account/ferz'); 16 | content_like('/account/123', qr/This is account 123/, '/account/123'); 17 | content_like('/account/profile/007/James Bond', qr/This is profile of James Bond/, 'account'); 18 | 19 | content_like('/downloads/', qr/This is download index/, 'downloads'); 20 | 21 | action_notfound('/c'); 22 | 23 | done_testing; 24 | 25 | -------------------------------------------------------------------------------- /lib/Catalyst/Engine/HTTP.pm: -------------------------------------------------------------------------------- 1 | package # Hide from PAUSE 2 | Catalyst::Engine::HTTP; 3 | use strict; 4 | use warnings; 5 | 6 | use base 'Catalyst::Engine'; 7 | 8 | warn("You are loading Catalyst::Engine::HTTP explicitly. 9 | 10 | This is almost certainly a bad idea, as Catalyst::Engine::HTTP 11 | has been removed in this version of Catalyst. 12 | 13 | Please update your application's scripts with: 14 | 15 | catalyst.pl -force -scripts MyApp 16 | 17 | to update your scripts to not do this.\n") unless $ENV{HARNESS_ACTIVE}; 18 | 19 | 1; 20 | 21 | __END__ 22 | 23 | =head1 NAME 24 | 25 | Catalyst::Engine::HTTP - removed module 26 | 27 | =head1 SYNOPSIS 28 | 29 | See L. 30 | 31 | =head1 DESCRIPTION 32 | 33 | This is here only as some old generated scripts require Catalyst::Engine::HTTP 34 | 35 | =head1 AUTHORS 36 | 37 | Catalyst Contributors, see Catalyst.pm 38 | 39 | =head1 COPYRIGHT 40 | 41 | This library is free software. You can redistribute it and/or modify it under 42 | the same terms as Perl itself. 43 | 44 | =cut 45 | -------------------------------------------------------------------------------- /lib/Catalyst/Exception/Go.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Exception::Go; 2 | 3 | use Moose; 4 | use namespace::clean -except => 'meta'; 5 | 6 | with 'Catalyst::Exception::Basic'; 7 | 8 | has '+message' => ( 9 | default => "catalyst_go\n", 10 | ); 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | 14 | 1; 15 | 16 | __END__ 17 | 18 | =head1 NAME 19 | 20 | Catalyst::Exception::Go - Exception for redispatching using $ctx->go() 21 | 22 | =head1 DESCRIPTION 23 | 24 | This is the class for the Catalyst Exception which is thrown then you call 25 | C<< $c->go() >>. 26 | 27 | This class is not intended to be used directly by users. 28 | 29 | =head2 meta 30 | 31 | Provided by Moose 32 | 33 | =head1 SEE ALSO 34 | 35 | =over 4 36 | 37 | =item L 38 | 39 | =item L 40 | 41 | =back 42 | 43 | =head1 AUTHORS 44 | 45 | Catalyst Contributors, see Catalyst.pm 46 | 47 | =head1 COPYRIGHT 48 | 49 | This library is free software. You can redistribute it and/or modify 50 | it under the same terms as Perl itself. 51 | 52 | =cut 53 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_anon.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 6; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | { 11 | my $response = request('http://localhost/anon/test'); 12 | ok($response->is_success); 13 | is($response->header('X-Component-Name-Action'), 14 | 'TestApp::Controller::Anon', 'Action can see correct catalyst_component_name'); 15 | isnt($response->header('X-Component-Instance-Name-Action'), 16 | 'TestApp::Controller::Anon', 'ref($controller) ne catalyst_component_name'); 17 | is($response->header('X-Component-Name-Controller'), 18 | 'TestApp::Controller::Anon', 'Controller can see correct catalyst_component_name'); 19 | is($response->header('X-Class-In-Action'), 20 | 'TestApp::Controller::Anon', '$action->class is catalyst_component_name'); 21 | is($response->header('X-Anon-Trait-Applied'), 22 | '1', 'Anon controller class has trait applied correctly'); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Status.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Status; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub begin : Private { 7 | my ( $self, $c ) = @_; 8 | $c->response->content_type('text/plain'); 9 | return 1; 10 | } 11 | 12 | sub s200 : Relative { 13 | my ( $self, $c ) = @_; 14 | $c->res->status(200); 15 | $c->res->output("200 OK\n"); 16 | } 17 | 18 | sub s400 : Relative { 19 | my ( $self, $c ) = @_; 20 | $c->res->status(400); 21 | $c->res->output("400 Bad Request\n"); 22 | } 23 | 24 | sub s403 : Relative { 25 | my ( $self, $c ) = @_; 26 | $c->res->status(403); 27 | $c->res->output("403 Forbidden\n"); 28 | } 29 | 30 | sub s404 : Relative { 31 | my ( $self, $c ) = @_; 32 | $c->res->status(404); 33 | $c->res->output("404 Not Found\n"); 34 | } 35 | 36 | sub s500 : Relative { 37 | my ( $self, $c ) = @_; 38 | $c->res->status(500); 39 | $c->res->output("500 Internal Server Error\n"); 40 | } 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_actionroles.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use FindBin; 6 | use lib "$FindBin::Bin/../lib"; 7 | 8 | use Catalyst::Test 'TestApp'; 9 | 10 | my %roles = ( 11 | foo => 'TestApp::ActionRole::Guff', 12 | bar => 'TestApp::ActionRole::Guff', 13 | baz => 'Guff', 14 | quux => 'Catalyst::ActionRole::Zoo', 15 | ); 16 | 17 | while (my ($path, $role) = each %roles) { 18 | my $resp = request("/actionroles/${path}"); 19 | ok($resp->is_success); 20 | is($resp->content, $role); 21 | is($resp->header('X-Affe'), 'Tiger'); 22 | } 23 | 24 | { 25 | my $resp = request("/actionroles/corge"); 26 | ok($resp->is_success); 27 | is($resp->content, 'TestApp::ActionRole::Guff'); 28 | is($resp->header('X-Affe'), 'Tiger'); 29 | is($resp->header('X-Action-After'), 'moo'); 30 | } 31 | { 32 | my $resp = request("/actionroles/frew"); 33 | ok($resp->is_success); 34 | is($resp->content, 'hello', 'action_args are honored with ActionRoles'); 35 | } 36 | done_testing; 37 | -------------------------------------------------------------------------------- /lib/Catalyst/Exception/Detach.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Exception::Detach; 2 | 3 | use Moose; 4 | use namespace::clean -except => 'meta'; 5 | 6 | with 'Catalyst::Exception::Basic'; 7 | 8 | has '+message' => ( 9 | default => "catalyst_detach\n", 10 | ); 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | 14 | 1; 15 | 16 | __END__ 17 | 18 | =head1 NAME 19 | 20 | Catalyst::Exception::Detach - Exception for redispatching using $ctx->detach() 21 | 22 | =head1 DESCRIPTION 23 | 24 | This is the class for the Catalyst Exception which is thrown then you call 25 | C<< $c->detach() >>. 26 | 27 | This class is not intended to be used directly by users. 28 | 29 | =head2 meta 30 | 31 | Provided by Moose 32 | 33 | =head1 SEE ALSO 34 | 35 | =over 4 36 | 37 | =item L 38 | 39 | =item L 40 | 41 | =back 42 | 43 | =head1 AUTHORS 44 | 45 | Catalyst Contributors, see Catalyst.pm 46 | 47 | =head1 COPYRIGHT 48 | 49 | This library is free software. You can redistribute it and/or modify 50 | it under the same terms as Perl itself. 51 | 52 | =cut 53 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_path_to.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | use FindBin; 6 | use Path::Class; 7 | use File::Basename; 8 | BEGIN { 9 | delete $ENV{CATALYST_HOME}; # otherwise it'll set itself up to the wrong place 10 | } 11 | use lib "$FindBin::Bin/../lib"; 12 | use TestApp; 13 | 14 | my %non_unix = ( 15 | MacOS => 1, 16 | MSWin32 => 1, 17 | os2 => 1, 18 | VMS => 1, 19 | epoc => 1, 20 | NetWare => 1, 21 | dos => 1, 22 | cygwin => 1 23 | ); 24 | 25 | my $os = $non_unix{$^O} ? $^O : 'Unix'; 26 | 27 | if ( $os ne 'Unix' ) { 28 | plan skip_all => 'tests require Unix'; 29 | } 30 | 31 | use_ok('Catalyst'); 32 | 33 | my $context = 'TestApp'; 34 | my $base; 35 | 36 | isa_ok( $base = Catalyst::path_to( $context, '' ), 'Path::Class::Dir' ); 37 | 38 | my $config = Catalyst->config; 39 | 40 | is( Catalyst::path_to( $context, 'foo' ), "$base/foo", 'Unix path' ); 41 | 42 | is( Catalyst::path_to( $context, 'foo', 'bar' ), 43 | "$base/foo/bar", 'deep Unix path' ); 44 | 45 | done_testing; 46 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/Foo.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::Foo; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use base qw/Catalyst::Controller/; 7 | 8 | # 9 | # Child of current namespace 10 | # 11 | sub spoon :Chained('.') :Args(0) { } 12 | 13 | # 14 | # Root for a action in a "parent" controller 15 | # 16 | sub higher_root :PathPart('chained/higher_root') :Chained('/') :CaptureArgs(1) { } 17 | 18 | # 19 | # Parent controller -> this subcontroller -> parent controller test 20 | # 21 | sub pcp2 :Chained('/action/chained/pcp1') :CaptureArgs(1) { } 22 | 23 | # 24 | # Controllers not in parent/child relation. This tests the end. 25 | # 26 | sub cross2 :PathPart('end') :Chained('/action/chained/bar/cross1') :Args(1) { } 27 | 28 | # 29 | # Create a uri to the root index 30 | # 31 | sub to_root : Chained('/') PathPart('action/chained/to_root') { 32 | my ( $self, $c ) = @_; 33 | my $uri = $c->uri_for_action('/chain_root_index'); 34 | $c->res->body( "URI:$uri" ); 35 | $c->stash->{no_end}++; 36 | } 37 | 38 | 1; 39 | -------------------------------------------------------------------------------- /t/remove_redundant_body.t: -------------------------------------------------------------------------------- 1 | use FindBin; 2 | use lib "$FindBin::Bin/lib"; 3 | use Catalyst::Test 'TestApp', {default_host => 'default.com'}; 4 | use Catalyst::Request; 5 | 6 | use Test::More; 7 | 8 | { 9 | my @routes = ( 10 | ["test_remove_body_with_304", 11 | 304 ], 12 | ["test_remove_body_with_204", 13 | 204 ], 14 | ["test_remove_body_with_100", 15 | 100 ], 16 | ["test_nobody_with_100", 17 | 100 ] 18 | ); 19 | 20 | foreach my $element (@routes ) { 21 | my $route = $element->[0]; 22 | my $expected_code = $element->[1]; 23 | my $request = 24 | HTTP::Request->new( GET => "http://localhost:3000/$route" ); 25 | ok( my $response = request($request), "Request for $route"); 26 | is( $response->code, 27 | $expected_code, 28 | "Status code for $route is $expected_code"); 29 | is( $response->content, 30 | '', 31 | "Body for $route is not present"); 32 | } 33 | } 34 | 35 | done_testing; 36 | -------------------------------------------------------------------------------- /t/lib/TestMiddleware.pm: -------------------------------------------------------------------------------- 1 | package TestMiddleware; 2 | 3 | use Moose; 4 | use Plack::Middleware::Static; 5 | use Plack::App::File; 6 | use Catalyst; 7 | 8 | extends 'Catalyst'; 9 | 10 | my $static = Plack::Middleware::Static->new( 11 | path => qr{^/static/}, root => TestMiddleware->path_to('share')); 12 | 13 | __PACKAGE__->config( 14 | 'Controller::Root', { namespace => '' }, 15 | 'psgi_middleware', [ 16 | 'Head', 17 | $static, 18 | 'Static', { path => qr{^/static2/}, root => TestMiddleware->path_to('share') }, 19 | 'Runtime', 20 | '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddleware->path_to('share') }, 21 | sub { 22 | my $app = shift; 23 | return sub { 24 | my $env = shift; 25 | if($env->{PATH_INFO} =~m/forced/) { 26 | Plack::App::File->new(file=>TestMiddleware->path_to(qw/share static forced.txt/)) 27 | ->call($env); 28 | } else { 29 | return $app->($env); 30 | } 31 | }, 32 | }, 33 | 34 | ], 35 | ); 36 | 37 | __PACKAGE__->setup; 38 | 39 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/PassedArgs.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::PassedArgs; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # This controller builds a simple chain of three actions that 9 | # will output the arguments they got passed to @_ after the 10 | # context object. We do this to test if that passing works 11 | # as it should. 12 | # 13 | 14 | sub first : PathPart('chained/passedargs/a') Chained('/') CaptureArgs(1) { 15 | my ( $self, $c, $arg ) = @_; 16 | $c->stash->{ passed_args } = [ $arg ]; 17 | } 18 | 19 | sub second : PathPart('b') Chained('first') CaptureArgs(1) { 20 | my ( $self, $c, $arg ) = @_; 21 | push @{ $c->stash->{ passed_args } }, $arg; 22 | } 23 | 24 | sub third : PathPart('c') Chained('second') Args(1) { 25 | my ( $self, $c, $arg ) = @_; 26 | push @{ $c->stash->{ passed_args } }, $arg; 27 | } 28 | 29 | sub end : Private { 30 | my ( $self, $c ) = @_; 31 | $c->response->body( join '; ', @{ $c->stash->{ passed_args } } ); 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /t/undef_encoding_regression.t: -------------------------------------------------------------------------------- 1 | use utf8; 2 | use warnings; 3 | use strict; 4 | use Test::More; 5 | use HTTP::Request::Common; 6 | use HTTP::Message::PSGI (); 7 | use Encode 2.21 'decode_utf8', 'encode_utf8', 'encode'; 8 | 9 | { 10 | package MyApp::Controller::Root; 11 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 12 | 13 | use base 'Catalyst::Controller'; 14 | 15 | sub heart :Local Args(1) { 16 | my ($self, $c, $arg) = @_; 17 | 18 | Test::More::is $c->req->query_parameters->{a}, 111; 19 | Test::More::is $c->req->query_parameters->{b}, 222; 20 | Test::More::is $arg, 1; 21 | 22 | $c->response->content_type('text/html'); 23 | $c->response->body("

This is path local

"); 24 | } 25 | 26 | package MyApp; 27 | use Catalyst; 28 | 29 | MyApp->config(encoding => undef); 30 | 31 | Test::More::ok(MyApp->setup, 'setup app'); 32 | } 33 | 34 | use Catalyst::Test 'MyApp'; 35 | 36 | { 37 | my $res = request "/root/heart/1?a=111&b=222"; 38 | is $res->code, 200, 'OK'; 39 | is $res->content, '

This is path local

'; 40 | } 41 | 42 | done_testing; 43 | -------------------------------------------------------------------------------- /t/optional_stress.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | BEGIN { 6 | plan skip_all => 'set TEST_STRESS to enable this test' 7 | unless $ENV{TEST_STRESS}; 8 | } 9 | 10 | use FindBin; 11 | use lib "$FindBin::Bin/lib"; 12 | use Catalyst::Test 'TestApp'; 13 | 14 | our ( $iters, $tests ); 15 | 16 | BEGIN { 17 | use JSON::MaybeXS qw(decode_json); 18 | 19 | my $test_data = do { 20 | open my $fh, '<:raw', "$FindBin::Bin/optional_stress.json" or die "$!"; 21 | local $/; 22 | <$fh>; 23 | }; 24 | 25 | $iters = $ENV{TEST_STRESS} || 10; 26 | $tests = decode_json($test_data); 27 | 28 | my $total_tests = 0; 29 | map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests}; 30 | plan tests => $iters * $total_tests; 31 | } 32 | 33 | for ( 1 .. $iters ) { 34 | run_tests(); 35 | } 36 | 37 | sub run_tests { 38 | foreach my $test_group ( keys %{$tests} ) { 39 | foreach my $test ( @{ $tests->{$test_group} } ) { 40 | ok( request($test), $test_group . ' - ' . $test ); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_script_run_options.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use FindBin qw/$Bin/; 5 | use IO::Handle; 6 | use Try::Tiny; 7 | use File::Temp qw/ tempfile /; 8 | use lib "$Bin/../lib"; 9 | 10 | use_ok('Catalyst::ScriptRunner'); 11 | use_ok('ScriptTestApp'); 12 | 13 | is ScriptTestApp->run_options, undef; 14 | 15 | my ($fh, $fn) = tempfile(); 16 | 17 | binmode( $fh ); 18 | binmode( STDOUT ); 19 | 20 | local @ARGV = (); 21 | local %ENV; 22 | 23 | my $saved; 24 | open( $saved, '>&'. STDOUT->fileno ) 25 | or croak("Can't dup stdout: $!"); 26 | open( STDOUT, '>&='. $fh->fileno ) 27 | or croak("Can't open stdout: $!"); 28 | local $SIG{__WARN__} = sub {}; # Shut up warnings... 29 | try { Catalyst::ScriptRunner->run('ScriptTestApp', 'CGI'); pass("Ran ok") } 30 | catch { fail "Failed to run $_" }; 31 | 32 | STDOUT->flush 33 | or croak("Can't flush stdout: $!"); 34 | 35 | open( STDOUT, '>&'. fileno($saved) ) 36 | or croak("Can't restore stdout: $!"); 37 | 38 | is_deeply ScriptTestApp->run_options, { argv => [], extra_argv => [] }; 39 | 40 | done_testing; 41 | -------------------------------------------------------------------------------- /lib/Catalyst/Base.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Base; 2 | use Moose; 3 | BEGIN { extends 'Catalyst::Controller' } 4 | 5 | after 'BUILD' => sub { 6 | my $self = shift; 7 | warn(ref($self) . " is using the deprecated Catalyst::Base, update your application as this will be removed in the next major release"); 8 | }; 9 | 10 | no Moose; 11 | 12 | __PACKAGE__->meta->make_immutable; 13 | 14 | 1; 15 | 16 | __END__ 17 | 18 | =head1 NAME 19 | 20 | Catalyst::Base - Deprecated base class 21 | 22 | =head1 DESCRIPTION 23 | 24 | This used to be the base class for Catalyst Controllers. It 25 | remains here for compatibility reasons, but its use is highly deprecated. 26 | 27 | If your application produces a warning, then please update your application to 28 | inherit from L instead. 29 | 30 | =head1 SEE ALSO 31 | 32 | L, L. 33 | 34 | =head1 AUTHORS 35 | 36 | Catalyst Contributors, see Catalyst.pm 37 | 38 | =head1 COPYRIGHT 39 | 40 | This library is free software. You can redistribute it and/or modify it under 41 | the same terms as Perl itself. 42 | 43 | =cut 44 | -------------------------------------------------------------------------------- /t/path_action_empty_brackets.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/lib"; 6 | 7 | use Test::More tests => 12; 8 | use Catalyst::Test 'TestPath'; 9 | 10 | 11 | { 12 | ok( my $response = request('http://localhost/one'), 'Request' ); 13 | ok( $response->is_success, '"Path" - Response Successful 2xx' ); 14 | is( $response->content, 'OK', '"Path" - Body okay' ); 15 | } 16 | { 17 | ok( my $response = request('http://localhost/two'), 'Request' ); 18 | ok( $response->is_success, '"Path()" - Response Successful 2xx' ); 19 | is( $response->content, 'OK', '"Path()" - Body okay' ); 20 | } 21 | { 22 | ok( my $response = request('http://localhost/three'), 'Request' ); 23 | ok( $response->is_success, '"Path(\'\')" - Response Successful 2xx' ); 24 | is( $response->content, 'OK', '"Path(\'\')" - Body okay' ); 25 | } 26 | { 27 | ok( my $response = request('http://localhost/four'), 'Request' ); 28 | ok( $response->is_success, '"Path(\'\')" - Response Successful 2xx' ); 29 | is( $response->content, 'OK', '"Path() Args()" - Body okay' ); 30 | } 31 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Chained/ArgsOrder.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Chained::ArgsOrder; 2 | use warnings; 3 | use strict; 4 | 5 | use base qw( Catalyst::Controller ); 6 | 7 | # 8 | # This controller builds a simple chain of three actions that 9 | # will output the arguments they got passed to @_ after the 10 | # context object. We do this to test if that passing works 11 | # as it should. 12 | # 13 | 14 | sub base :Chained('/') PathPart('argsorder') CaptureArgs(0) { 15 | my ( $self, $c, $arg ) = @_; 16 | push @{ $c->stash->{ passed_args } }, 'base', $arg; 17 | } 18 | 19 | sub index :Chained('base') PathPart('') Args(0) { 20 | my ( $self, $c, $arg ) = @_; 21 | push @{ $c->stash->{ passed_args } }, 'index', $arg; 22 | } 23 | 24 | sub all :Chained('base') PathPart('') Args() { 25 | my ( $self, $c, $arg ) = @_; 26 | push @{ $c->stash->{ passed_args } }, 'all', $arg; 27 | } 28 | 29 | sub end : Private { 30 | my ( $self, $c ) = @_; 31 | no warnings 'uninitialized'; 32 | $c->response->body( join '; ', @{ $c->stash->{ passed_args } } ); 33 | } 34 | 35 | 1; 36 | -------------------------------------------------------------------------------- /t/aggregate/c3_mro.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | require Catalyst; 6 | require Module::Pluggable::Object; 7 | use MRO::Compat; 8 | 9 | # Get a list of all Catalyst:: packages in blib via M::P::O 10 | my @cat_mods; 11 | { 12 | # problem with @INC on win32, see: 13 | # http://rt.cpan.org/Ticket/Display.html?id=26452 14 | if ($^O eq 'MSWin32') { require Win32; Win32::GetCwd(); } 15 | 16 | local @INC = grep {/blib/} @INC; 17 | @cat_mods = ( 18 | 'Catalyst', 19 | Module::Pluggable::Object->new(search_path => ['Catalyst'])->plugins, 20 | ); 21 | } 22 | 23 | # plan one test per found package name 24 | plan tests => scalar @cat_mods; 25 | 26 | # Try to calculate the C3 MRO for each package 27 | # 28 | # In the case that the initial require fails (as in 29 | # Catalyst::Engine::FastCGI when FCGI is not installed), 30 | # the calculateMRO eval will not error out, which is 31 | # effectively a test skip. 32 | # 33 | foreach my $cat_mod (@cat_mods) { 34 | eval " require $cat_mod "; 35 | eval { mro::get_linear_isa($cat_mod, 'c3') }; 36 | ok(!$@, "calculateMRO for $cat_mod: $@"); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /lib/Catalyst/Script/Test.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Script::Test; 2 | use Moose; 3 | use Catalyst::Test (); 4 | use namespace::clean -except => [ 'meta' ]; 5 | 6 | with 'Catalyst::ScriptRole'; 7 | 8 | sub run { 9 | my $self = shift; 10 | 11 | Catalyst::Test->import($self->application_name); 12 | 13 | foreach my $arg (@{ $self->ARGV }) { 14 | print request($arg)->content . "\n"; 15 | } 16 | } 17 | 18 | 19 | __PACKAGE__->meta->make_immutable; 20 | 1; 21 | 22 | =head1 NAME 23 | 24 | Catalyst::Script::Test - Test Catalyst application on the command line 25 | 26 | =head1 SYNOPSIS 27 | 28 | myapp_test.pl [options] /path 29 | 30 | Options: 31 | -h --help display this help and exits 32 | 33 | =head1 DESCRIPTION 34 | 35 | Script to perform a test hit against your application and display the output. 36 | 37 | =head1 SEE ALSO 38 | 39 | L 40 | 41 | =head1 AUTHORS 42 | 43 | Catalyst Contributors, see Catalyst.pm 44 | 45 | =head1 COPYRIGHT 46 | 47 | This library is free software. You can redistribute it and/or modify it under 48 | the same terms as Perl itself. 49 | 50 | =cut 51 | -------------------------------------------------------------------------------- /t/aggregate/unit_utils_prefix.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More tests => 8; 5 | 6 | use lib "t/lib"; 7 | 8 | use Catalyst::Utils; 9 | 10 | is( Catalyst::Utils::class2prefix('MyApp::V::Foo::Bar'), 'foo/bar', 'class2prefix works with M/V/C' ); 11 | 12 | is( Catalyst::Utils::class2prefix('MyApp::Controller::Foo::Bar'), 'foo/bar', 'class2prefix works with Model/View/Controller' ); 13 | 14 | is( Catalyst::Utils::class2prefix('MyApp::Controller::Foo::View::Bar'), 'foo/view/bar', 'class2prefix works with tricky components' ); 15 | 16 | is( Catalyst::Utils::appprefix('MyApp::Foo'), 'myapp_foo', 'appprefix works' ); 17 | 18 | is( Catalyst::Utils::class2appclass('MyApp::Foo::Controller::Bar::View::Baz'), 'MyApp::Foo', 'class2appclass works' ); 19 | 20 | is( Catalyst::Utils::class2classprefix('MyApp::Foo::Controller::Bar::View::Baz'), 'MyApp::Foo::Controller', 'class2classprefix works' ); 21 | 22 | is( Catalyst::Utils::class2classsuffix('MyApp::Foo::Controller::Bar::View::Baz'), 'Controller::Bar::View::Baz', 'class2classsuffix works' ); 23 | 24 | is( Catalyst::Utils::class2env('MyApp::Foo'), 'MYAPP_FOO', 'class2env works' ); 25 | -------------------------------------------------------------------------------- /t/aggregate/unit_utils_home.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | use File::Temp qw/ tempdir /; 6 | use Catalyst::Utils; 7 | use File::Spec; 8 | use Path::Class qw/ dir /; 9 | use Cwd qw/ cwd /; 10 | 11 | my @dists = Catalyst::Utils::dist_indicator_file_list(); 12 | is(scalar(@dists), 4, 'Makefile.PL Build.PL dist.ini cpanfile'); 13 | 14 | my $cwd = cwd(); 15 | foreach my $inc ('', 'lib', 'blib'){ 16 | my $d = tempdir(CLEANUP => 1); 17 | chdir($d); 18 | local $INC{'MyApp.pm'} = File::Spec->catfile($d, $inc, 'MyApp.pm'); 19 | ok !Catalyst::Utils::home('MyApp'), "No files found inc $inc"; 20 | open(my $fh, '>', "Makefile.PL"); 21 | close($fh); 22 | is Catalyst::Utils::home('MyApp'), dir($d)->absolute->cleanup, "Did find inc '$inc'"; 23 | } 24 | 25 | { 26 | my $d = tempdir(CLEANUP => 1); 27 | local $INC{'MyApp.pm'} = File::Spec->catfile($d, 'MyApp.pm'); 28 | ok !Catalyst::Utils::home('MyApp'), 'No files found'; 29 | mkdir File::Spec->catdir($d, 'MyApp'); 30 | is Catalyst::Utils::home('MyApp'), dir($d, 'MyApp')->absolute->cleanup; 31 | } 32 | 33 | chdir($cwd); 34 | 35 | done_testing; 36 | 37 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Attributes.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | package My::AttributesBaseClass; 5 | use base qw( Catalyst::Controller ); 6 | 7 | sub fetch : Chained('/') PathPrefix CaptureArgs(0) { } 8 | 9 | sub left_alone :Chained('fetch') PathPart Args(0) { } 10 | 11 | sub view : PathPart Chained('fetch') Args(0) { } 12 | 13 | sub foo { } # no attributes 14 | 15 | package TestApp::Controller::Attributes; 16 | use base qw(My::AttributesBaseClass); 17 | 18 | sub _parse_MakeMeVisible_attr { 19 | my ($self, $c, $name, $value) = @_; 20 | if (!$value){ 21 | return Chained => 'fetch', PathPart => 'all_attrs', Args => 0; 22 | } 23 | elsif ($value eq 'some'){ 24 | return Chained => 'fetch', Args => 0; 25 | } 26 | elsif ($value eq 'one'){ 27 | return PathPart => 'one_attr'; 28 | } 29 | } 30 | 31 | sub view { } # override attributes to "hide" url 32 | 33 | sub foo : Local { } 34 | 35 | sub all_attrs_action :MakeMeVisible { } 36 | 37 | sub some_attrs_action :MakeMeVisible('some') PathPart('some_attrs') { } 38 | 39 | sub one_attr_action :MakeMeVisible('one') Chained('fetch') Args(0) { } 40 | 41 | 1; 42 | -------------------------------------------------------------------------------- /t/not_utf8_query_bug.t: -------------------------------------------------------------------------------- 1 | use utf8; 2 | use warnings; 3 | use strict; 4 | 5 | # For reported: https://rt.cpan.org/Ticket/Display.html?id=103063 6 | 7 | { 8 | package MyApp::Controller::Root; 9 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 10 | 11 | use base 'Catalyst::Controller'; 12 | 13 | sub example :Local Args(0) { 14 | pop->stash->{testing1} = 'testing2'; 15 | } 16 | 17 | package MyApp; 18 | use Catalyst; 19 | 20 | #MyApp->config(decode_query_using_global_encoding=>1, encoding => 'SHIFT_JIS'); 21 | #MyApp->config(do_not_decode_query=>1); 22 | #MyApp->config(decode_query_using_global_encoding=>1, encoding => undef); 23 | MyApp->config(default_query_encoding=>'SHIFT_JIS'); 24 | 25 | MyApp->setup; 26 | } 27 | 28 | use Test::More; 29 | use Catalyst::Test 'MyApp'; 30 | use Encode; 31 | use HTTP::Request::Common; 32 | 33 | { 34 | my $shiftjs = 'test テスト'; 35 | my $encoded = Encode::encode('SHIFT_JIS', $shiftjs); 36 | 37 | ok my $req = GET "/root/example?a=$encoded"; 38 | my ($res, $c) = ctx_request $req; 39 | 40 | is $c->req->query_parameters->{'a'}, $shiftjs, 'got expected value'; 41 | } 42 | 43 | 44 | done_testing; 45 | 46 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Path.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Path; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | __PACKAGE__->config( 7 | actions => { 8 | 'one' => { 'Path' => [ 'a path with spaces' ] }, 9 | 'two' => { 'Path' => "åäö" }, 10 | 'six' => { 'Local' => undef }, 11 | }, 12 | ); 13 | 14 | sub one : Action Path("this_will_be_overriden") { 15 | my ( $self, $c ) = @_; 16 | $c->forward('TestApp::View::Dump::Request'); 17 | } 18 | 19 | sub two : Action { 20 | my ( $self, $c ) = @_; 21 | $c->forward('TestApp::View::Dump::Request'); 22 | } 23 | 24 | sub three :Path { 25 | my ( $self, $c ) = @_; 26 | $c->forward('TestApp::View::Dump::Request'); 27 | } 28 | 29 | sub four : Path( 'spaces_near_parens_singleq' ) { 30 | my ( $self, $c ) = @_; 31 | $c->forward('TestApp::View::Dump::Request'); 32 | } 33 | 34 | sub five : Path( "spaces_near_parens_doubleq" ) { 35 | my ( $self, $c ) = @_; 36 | $c->forward('TestApp::View::Dump::Request'); 37 | } 38 | 39 | sub six { 40 | my ( $self, $c ) = @_; 41 | $c->forward('TestApp::View::Dump::Request'); 42 | } 43 | 44 | 1; 45 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_request_prepare_parameters.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | use Test::More tests => 8; 8 | use Catalyst::Test 'TestApp'; 9 | 10 | use Catalyst::Request; 11 | use HTTP::Headers; 12 | use HTTP::Request::Common; 13 | 14 | { 15 | my $creq; 16 | 17 | my $parameters = { 'a' => [qw(A b C d E f G)], }; 18 | 19 | my $query = join( '&', map { 'a=' . $_ } @{ $parameters->{a} } ); 20 | 21 | ok( my $response = request("http://localhost/dump/prepare_parameters?$query"), 22 | 'Request' ); 23 | ok( $response->is_success, 'Response Successful 2xx' ); 24 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); 25 | like( 26 | $response->content, 27 | qr/^bless\( .* 'Catalyst::Request' \)$/s, 28 | 'Content is a serialized Catalyst::Request' 29 | ); 30 | ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ); 31 | isa_ok( $creq, 'Catalyst::Request' ); 32 | is( $creq->method, 'GET', 'Catalyst::Request method' ); 33 | is_deeply( $creq->parameters, $parameters, 34 | 'Catalyst::Request parameters' ); 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Detach.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Detach; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub one : Local { 7 | my ( $self, $c ) = @_; 8 | $c->detach('two'); 9 | $c->forward('error'); 10 | } 11 | 12 | sub two : Private { 13 | my ( $self, $c ) = @_; 14 | $c->forward('TestApp::View::Dump::Request'); 15 | } 16 | 17 | sub error : Local { 18 | my ( $self, $c ) = @_; 19 | $c->res->output('error'); 20 | } 21 | 22 | sub path : Local { 23 | my ( $self, $c ) = @_; 24 | $c->detach('/action/detach/two'); 25 | $c->forward('error'); 26 | } 27 | 28 | sub with_args : Local { 29 | my ( $self, $c, $orig ) = @_; 30 | $c->detach( 'args', [qq/new/] ); 31 | } 32 | 33 | sub with_method_and_args : Local { 34 | my ( $self, $c, $orig ) = @_; 35 | $c->detach( qw/TestApp::Controller::Action::Detach args/, [qq/new/] ); 36 | } 37 | 38 | sub args : Local { 39 | my ( $self, $c, $val ) = @_; 40 | die "Expected argument 'new', got '$val'" unless $val eq 'new'; 41 | die "passed argument does not match args" unless $val eq $c->req->args->[0]; 42 | $c->res->body( $c->req->args->[0] ); 43 | } 44 | 45 | 1; 46 | -------------------------------------------------------------------------------- /t/aggregate/unit_core_merge_config_hashes.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | 6 | my @tests = ( 7 | { 8 | given => [ { a => 1 }, { b => 1 } ], 9 | expects => { a => 1, b => 1 } 10 | }, 11 | { 12 | given => [ { a => 1 }, { a => { b => 1 } } ], 13 | expects => { a => { b => 1 } } 14 | }, 15 | { 16 | given => [ { a => { b => 1 } }, { a => 1 } ], 17 | expects => { a => 1 } 18 | }, 19 | { 20 | given => [ { a => 1 }, { a => [ 1 ] } ], 21 | expects => { a => [ 1 ] } 22 | }, 23 | { 24 | given => [ { a => [ 1 ] }, { a => 1 } ], 25 | expects => { a => 1 } 26 | }, 27 | { 28 | given => [ { a => { b => 1 } }, { a => { b => 2 } } ], 29 | expects => { a => { b => 2 } } 30 | }, 31 | { 32 | given => [ { a => { b => 1 } }, { a => { c => 1 } } ], 33 | expects => { a => { b => 1, c => 1 } } 34 | }, 35 | ); 36 | 37 | plan tests => scalar @tests; 38 | 39 | use Catalyst::Component; 40 | 41 | for my $test ( @ tests ) { 42 | is_deeply( Catalyst::Component->merge_config_hashes( @{ $test->{ given } } ), $test->{ expects } ); 43 | } 44 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_request_auth.t: -------------------------------------------------------------------------------- 1 | # This tests to make sure the Authorization header is passed through by the engine. 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | 9 | use Test::More tests => 7; 10 | use Catalyst::Test 'TestApp'; 11 | 12 | use Catalyst::Request; 13 | use HTTP::Headers; 14 | use HTTP::Request::Common; 15 | 16 | { 17 | my $creq; 18 | 19 | my $request = GET( 20 | 'http://localhost/dump/request', 21 | 'Authorization' => 'Basic dGVzdDoxMjM0NQ==', 22 | ); 23 | 24 | ok( my $response = request($request), 'Request' ); 25 | ok( $response->is_success, 'Response Successful 2xx' ); 26 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); 27 | like( $response->content, qr/'Catalyst::Request'/, 28 | 'Content is a serialized Catalyst::Request' ); 29 | 30 | { 31 | no strict 'refs'; 32 | ok( 33 | eval '$creq = ' . $response->content, 34 | 'Unserialize Catalyst::Request' 35 | ); 36 | } 37 | 38 | isa_ok( $creq, 'Catalyst::Request' ); 39 | 40 | is( $creq->header('Authorization'), 'Basic dGVzdDoxMjM0NQ==', 'auth header ok' ); 41 | } 42 | -------------------------------------------------------------------------------- /t/aggregate/live_component_controller_action_index_or_default.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More; 12 | use Catalyst::Test 'TestAppIndexDefault'; 13 | 14 | plan 'skip_all' if ( $ENV{CATALYST_SERVER} ); 15 | 16 | plan tests => 6*$iters; 17 | 18 | if ( $ENV{CAT_BENCHMARK} ) { 19 | require Benchmark; 20 | Benchmark::timethis( $iters, \&run_tests ); 21 | } 22 | else { 23 | for ( 1 .. $iters ) { 24 | run_tests(); 25 | } 26 | } 27 | 28 | sub run_tests { 29 | is(get('/indexchained'), 'index_chained', ':Chained overrides index'); 30 | is(get('/indexprivate'), 'index_private', 'index : Private still works'); 31 | 32 | # test :Path overriding default 33 | is(get('/one_arg'), 'path_one_arg', ':Path overrides default'); 34 | is(get('/one_arg/foo/bar'), 'default', 'default still works'); 35 | 36 | # now the same thing with a namespace, and a trailing / on the :Path 37 | is(get('/default/one_arg'), 'default_path_one_arg', 38 | ':Path overrides default'); 39 | is(get('/default/one_arg/foo/bar'), 'default_default', 40 | 'default still works'); 41 | } 42 | -------------------------------------------------------------------------------- /t/dead_recursive_chained_attributes.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use lib 't/lib'; 4 | 5 | use Test::More tests => 6; 6 | 7 | use Catalyst::Test 'TestApp'; 8 | 9 | eval q{ 10 | package TestApp::Controller::Action::Chained; 11 | sub should_fail : Chained('should_fail') Args(0) {} 12 | }; 13 | ok(!$@); 14 | 15 | eval { TestApp->setup_actions; }; 16 | like($@, qr|Actions cannot chain to themselves registering /action/chained/should_fail|, 17 | 'Local self referencing attributes makes action setup fail'); 18 | 19 | eval q{ 20 | package TestApp::Controller::Action::Chained; 21 | no warnings 'redefine'; 22 | sub should_fail {} 23 | use warnings 'redefine'; 24 | sub should_also_fail : Chained('/action/chained/should_also_fail') Args(0) {} 25 | }; 26 | ok(!$@); 27 | 28 | eval { TestApp->setup_actions }; 29 | like($@, qr|Actions cannot chain to themselves registering /action/chained/should_also_fail|, 30 | 'Full path self referencing attributes makes action setup fail'); 31 | 32 | eval q{ 33 | package TestApp::Controller::Action::Chained; 34 | no warnings 'redefine'; 35 | sub should_also_fail {} 36 | }; 37 | ok(!$@); 38 | 39 | eval { TestApp->setup_actions }; 40 | ok(!$@, 'And ok again') or warn $@; 41 | 42 | -------------------------------------------------------------------------------- /t/lib/TestAppEncoding/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestAppEncoding::Controller::Root; 2 | use strict; 3 | use warnings; 4 | use base 'Catalyst::Controller'; 5 | use Test::More; 6 | 7 | __PACKAGE__->config->{namespace} = ''; 8 | 9 | sub binary : Local { 10 | my ($self, $c) = @_; 11 | $c->res->content_type('image/gif'); 12 | $c->res->body(do { 13 | open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!; 14 | binmode($fh); 15 | local $/ = undef; <$fh>; 16 | }); 17 | } 18 | 19 | sub binary_utf8 : Local { 20 | my ($self, $c) = @_; 21 | $c->forward('binary'); 22 | my $str = $c->res->body; 23 | utf8::upgrade($str); 24 | ok utf8::is_utf8($str), 'Body is variable width encoded string'; 25 | $c->res->body($str); 26 | } 27 | 28 | # called by t/aggregate/catalyst_test_utf8.t 29 | sub utf8_non_ascii_content : Local { 30 | use utf8; 31 | my ($self, $c) = @_; 32 | 33 | my $str = 'ʇsʎlɐʇɐɔ'; # 'catalyst' flipped at http://www.revfad.com/flip.html 34 | ok utf8::is_utf8($str), '$str is in UTF8 internally'; 35 | 36 | $c->res->content_type('text/plain'); 37 | $c->res->body($str); 38 | } 39 | 40 | 41 | sub end : Private { 42 | my ($self,$c) = @_; 43 | } 44 | 45 | 1; 46 | -------------------------------------------------------------------------------- /t/live_component_controller_context_closure.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | BEGIN { 6 | unless (eval 'use Devel::Cycle 1.11; 1') { 7 | plan skip_all => 'Devel::Cycle 1.11 required for this test'; 8 | } 9 | 10 | plan tests => 6; 11 | } 12 | 13 | use FindBin; 14 | use lib "$FindBin::Bin/lib"; 15 | 16 | BEGIN { $::setup_leakchecker = 1 } 17 | local $SIG{__WARN__} = sub { return if $_[0] =~ /Unhandled type: (GLOB|REGEXP)/; warn $_[0] }; 18 | use Catalyst::Test 'TestApp'; 19 | 20 | { 21 | my ($resp, $ctx) = ctx_request('/contextclosure/normal_closure'); 22 | ok($resp->is_success); 23 | #is($ctx->count_leaks, 1); 24 | # FIXME: find out why this changed from 1 to 2 after 52af51596d 25 | # ^^ probably has something to do with env being in Engine and Request - JNAP 26 | # ^^ I made the env in Engine a weak ref, should help until we can remove it 27 | is($ctx->count_leaks, 1); 28 | } 29 | 30 | { 31 | my ($resp, $ctx) = ctx_request('/contextclosure/context_closure'); 32 | ok($resp->is_success); 33 | is($ctx->count_leaks, 0); 34 | } 35 | 36 | { 37 | my ($resp, $ctx) = ctx_request('/contextclosure/non_closure'); 38 | ok($resp->is_success); 39 | is($ctx->count_leaks, 0); 40 | } 41 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_request_env.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $EXPECTED_ENV_VAR; 8 | our $EXPECTED_ENV_VAL; 9 | 10 | BEGIN { 11 | $EXPECTED_ENV_VAR = "CATALYSTTEST$$"; # has to be uppercase otherwise fails on Win32 12 | $EXPECTED_ENV_VAL = "Test env value " . rand(100000); 13 | } 14 | 15 | use Test::More; 16 | use Catalyst::Test 'TestApp'; 17 | 18 | use Catalyst::Request; 19 | use HTTP::Headers; 20 | use HTTP::Request::Common; 21 | 22 | my $response = request("http://localhost/dump/env", { 23 | extra_env => { $EXPECTED_ENV_VAR => $EXPECTED_ENV_VAL }, 24 | }); 25 | 26 | ok( $response, 'Request' ); 27 | ok( $response->is_success, 'Response Successful 2xx' ); 28 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); 29 | 30 | my $env; 31 | ok( eval '$env = ' . $response->content, 'Unserialize Catalyst::Request' ); 32 | is ref($env), 'HASH'; 33 | ok exists($env->{PATH_INFO}), 'Have a PATH_INFO env var for dump/env'; 34 | 35 | SKIP: 36 | { 37 | if ( $ENV{CATALYST_SERVER} ) { 38 | skip 'Using remote server', 1; 39 | } 40 | is $env->{$EXPECTED_ENV_VAR}, $EXPECTED_ENV_VAL, 41 | 'Value we set as expected for /dump/env' 42 | } 43 | 44 | done_testing; 45 | 46 | -------------------------------------------------------------------------------- /t/lib/TestAppDoubleAutoBug.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | package TestAppDoubleAutoBug; 5 | 6 | use TestLogger; 7 | use Catalyst qw/ 8 | Test::Errors 9 | Test::Headers 10 | Test::Plugin 11 | /; 12 | 13 | our $VERSION = '0.01'; 14 | 15 | __PACKAGE__->config( name => 'TestAppDoubleAutoBug', root => '/some/dir' ); 16 | 17 | __PACKAGE__->log(TestLogger->new); 18 | 19 | __PACKAGE__->setup; 20 | 21 | sub execute { 22 | my $c = shift; 23 | my $class = ref( $c->component( $_[0] ) ) || $_[0]; 24 | my $action = $_[1]->reverse(); 25 | 26 | my $method; 27 | 28 | if ( $action =~ /->(\w+)$/ ) { 29 | $method = $1; 30 | } 31 | elsif ( $action =~ /\/(\w+)$/ ) { 32 | $method = $1; 33 | } 34 | elsif ( $action =~ /^(\w+)$/ ) { 35 | $method = $action; 36 | } 37 | 38 | if ( $class && $method && $method !~ /^_/ ) { 39 | my $executed = sprintf( "%s->%s", $class, $method ); 40 | my @executed = $c->response->headers->header('X-Catalyst-Executed'); 41 | push @executed, $executed; 42 | $c->response->headers->header( 43 | 'X-Catalyst-Executed' => join ', ', 44 | @executed 45 | ); 46 | } 47 | 48 | return $c->SUPER::execute(@_); 49 | } 50 | 51 | 1; 52 | 53 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Anon.pm: -------------------------------------------------------------------------------- 1 | package Anon::Trait; 2 | use Moose::Role -traits => 'MethodAttributes'; # Needed for role composition to work correctly with anon classes. 3 | 4 | after test => sub { 5 | my ($self, $c) = @_; 6 | $c->res->header('X-Anon-Trait-Applied', 1); 7 | }; 8 | 9 | no Moose::Role; 10 | 11 | package TestApp::Controller::Anon; 12 | use Moose; 13 | use Moose::Util qw/find_meta/; 14 | use namespace::clean -except => 'meta'; 15 | BEGIN { extends 'Catalyst::Controller' }; 16 | 17 | sub COMPONENT { # Don't do this yourself, use CatalystX::Component::Traits! 18 | my ($class, $app, $args) = @_; 19 | 20 | my $meta = $class->meta->create_anon_class( 21 | superclasses => [ $class->meta->name ], 22 | roles => ['Anon::Trait'], 23 | cache => 1, 24 | ); 25 | # Special move as the methodattributes trait has changed our metaclass.. 26 | $meta = find_meta($meta->name); 27 | 28 | $class = $meta->name; 29 | $class->new($app, $args); 30 | } 31 | 32 | sub test : Local ActionClass('+TestApp::Action::TestMyAction') { 33 | my ($self, $c) = @_; 34 | $c->res->header('X-Component-Name-Controller', $self->catalyst_component_name); 35 | $c->res->body('It works'); 36 | } 37 | 38 | __PACKAGE__->meta->make_immutable; 39 | 40 | -------------------------------------------------------------------------------- /t/aggregate/custom_live_component_controller_action_auto_doublebug.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use FindBin; 5 | use lib "$FindBin::Bin/../lib"; 6 | 7 | our $iters; 8 | 9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } 10 | 11 | use Test::More tests => 3*$iters; 12 | use Catalyst::Test 'TestAppDoubleAutoBug'; 13 | 14 | if ( $ENV{CAT_BENCHMARK} ) { 15 | require Benchmark; 16 | Benchmark::timethis( $iters, \&run_tests ); 17 | } 18 | else { 19 | for ( 1 .. $iters ) { 20 | run_tests(); 21 | } 22 | } 23 | 24 | sub run_tests { 25 | SKIP: 26 | { 27 | if ( $ENV{CATALYST_SERVER} ) { 28 | skip 'Using remote server', 3; 29 | } 30 | 31 | { 32 | my @expected = qw[ 33 | TestAppDoubleAutoBug::Controller::Root->auto 34 | TestAppDoubleAutoBug::Controller::Root->default 35 | TestAppDoubleAutoBug::Controller::Root->end 36 | ]; 37 | 38 | my $expected = join( ", ", @expected ); 39 | 40 | ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' ); 41 | is( $response->header('X-Catalyst-Executed'), 42 | $expected, 'Executed actions' ); 43 | is( $response->content, 'default, auto=1', 'Content OK' ); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Engine/Response/Cookies.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Engine::Response::Cookies; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub one : Local { 7 | my ( $self, $c ) = @_; 8 | $c->res->cookies->{catalyst} = { value => 'cool', path => '/bah' }; 9 | $c->res->cookies->{cool} = { value => 'catalyst', path => '/' }; 10 | $c->forward('TestApp::View::Dump::Request'); 11 | } 12 | 13 | sub two : Local { 14 | my ( $self, $c ) = @_; 15 | $c->res->cookies->{catalyst} = { value => 'cool', path => '/bah' }; 16 | $c->res->cookies->{cool} = { value => 'catalyst', path => '/' }; 17 | $c->res->redirect('http://www.google.com/'); 18 | } 19 | 20 | sub three : Local { 21 | my ( $self, $c ) = @_; 22 | 23 | $c->res->cookies->{object} = CGI::Simple::Cookie->new( 24 | -name => "this_is_the_real_name", 25 | -value => [qw/foo bar/], 26 | ); 27 | 28 | $c->res->cookies->{hash} = { 29 | value => [qw/a b c/], 30 | }; 31 | 32 | $c->forward('TestApp::View::Dump::Request'); 33 | } 34 | 35 | sub four : Local { 36 | my ( $self, $c ) = @_; 37 | $c->res->cookies->{good} = { value => 'good_cookie', path => '/' }; 38 | $c->res->cookies->{bad} = { value => undef }; 39 | $c->forward('TestApp::View::Dump::Request'); 40 | } 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /t/deprecated.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use FindBin qw/$Bin/; 4 | use lib "$Bin/lib"; 5 | use Test::More tests => 4; 6 | 7 | my $warnings; 8 | BEGIN { # Do this at compile time in case we generate a warning when use 9 | # DeprecatedTestApp 10 | $SIG{__WARN__} = sub { 11 | $warnings++ if $_[0] =~ /uses NEXT, which is deprecated/; 12 | $warnings++ if $_[0] =~ /trying to use NEXT, which is deprecated/; 13 | }; 14 | } 15 | use Catalyst; # Cause catalyst to be used so I can fiddle with the logging. 16 | my $mvc_warnings; 17 | BEGIN { 18 | my $logger = Class::MOP::Class->create_anon_class( 19 | methods => { 20 | debug => sub {0}, 21 | info => sub {0}, 22 | warn => sub { 23 | if ($_[1] =~ /switch your class names/) { 24 | $mvc_warnings++; 25 | return; 26 | } 27 | die "Caught unexpected warning: " . $_[1]; 28 | }, 29 | }, 30 | )->new_object; 31 | Catalyst->log($logger); 32 | } 33 | 34 | use Catalyst::Test 'DeprecatedTestApp'; 35 | is( $mvc_warnings, 1, 'Get the ::MVC:: warning' ); 36 | 37 | ok( my $response = request('http://localhost/'), 'Request' ); 38 | is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' ); 39 | 40 | is( $warnings, 1, 'Got one and only one Adopt::NEXT warning'); 41 | -------------------------------------------------------------------------------- /t/head_middleware.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict; 3 | use Test::More; 4 | use HTTP::Request::Common; 5 | use Plack::Test; 6 | 7 | # Test to make sure we the order of some middleware is correct. Basically 8 | # we want to make sure that if the request is a HEAD we properly remove the 9 | # body BUT not so quickly that we fail to calculate the length. This test 10 | # exists mainly to prevent regressions. 11 | 12 | { 13 | package MyApp::Controller::Root; 14 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 15 | 16 | use base 'Catalyst::Controller'; 17 | 18 | sub test :Local { 19 | my ($self, $c) = @_; 20 | $c->response->body("This is the body"); 21 | } 22 | 23 | package MyApp; 24 | use Catalyst; 25 | 26 | Test::More::ok(MyApp->setup, 'setup app'); 27 | } 28 | 29 | 30 | 31 | ok my $psgi = MyApp->psgi_app, 'build psgi app'; 32 | 33 | test_psgi $psgi, sub { 34 | my $cb = shift; 35 | my $res = $cb->(GET "/root/test"); 36 | is $res->code, 200, 'OK'; 37 | is $res->content, 'This is the body', 'correct body'; 38 | is $res->content_length, 16, 'correct length'; 39 | }; 40 | 41 | test_psgi $psgi, sub { 42 | my $cb = shift; 43 | my $res = $cb->(HEAD "/root/test"); 44 | is $res->code, 200, 'OK'; 45 | is $res->content, '', 'correct body'; 46 | is $res->content_length, 16, 'correct length'; 47 | }; 48 | 49 | done_testing; 50 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Action/Streaming.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Action::Streaming; 2 | 3 | use strict; 4 | use base 'TestApp::Controller::Action'; 5 | 6 | sub streaming : Global { 7 | my ( $self, $c ) = @_; 8 | for my $line ( split "\n", <<'EOF' ) { 9 | foo 10 | bar 11 | baz 12 | EOF 13 | $c->res->write("$line\n"); 14 | } 15 | } 16 | 17 | sub body : Local { 18 | my ( $self, $c ) = @_; 19 | 20 | my $file = "$FindBin::Bin/../lib/TestApp/Controller/Action/Streaming.pm"; 21 | my $fh = IO::File->new( $file, 'r' ); 22 | if ( defined $fh ) { 23 | $c->res->body( $fh ); 24 | } 25 | else { 26 | $c->res->body( "Unable to read $file" ); 27 | } 28 | } 29 | 30 | sub body_glob : Local { 31 | my ( $self, $c ) = @_; 32 | 33 | my $file = "$FindBin::Bin/../lib/TestApp/Controller/Action/Streaming.pm"; 34 | open my $fh, '<', $file; 35 | if ( defined $fh ) { 36 | $c->res->body( $fh ); 37 | } 38 | else { 39 | $c->res->body( "Unable to read $file" ); 40 | } 41 | } 42 | 43 | sub body_large : Local { 44 | my ($self, $c) = @_; 45 | 46 | # more than one write with the default chunksize 47 | my $size = 128 * 1024; 48 | 49 | my $data = "\0" x $size; 50 | open my $fh, '<', \$data; 51 | $c->res->content_length($size); 52 | $c->res->body($fh); 53 | } 54 | 55 | 1; 56 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Fork.pm: -------------------------------------------------------------------------------- 1 | # Fork.pm 2 | # Copyright (c) 2006 Jonathan Rockway 3 | 4 | package TestApp::Controller::Fork; 5 | 6 | use strict; 7 | use warnings; 8 | use base 'Catalyst::Controller'; 9 | 10 | use JSON::MaybeXS qw(encode_json); 11 | 12 | sub system : Local { 13 | my ($self, $c, $ls) = @_; 14 | my ($result, $code) = (undef, 1); 15 | 16 | if(!-e $ls || !-x _){ 17 | $result = 'skip'; 18 | } 19 | else { 20 | $result = system($ls, $ls, $ls); 21 | $result = $! if $result != 0; 22 | } 23 | 24 | $c->response->body(encode_json({result => $result})); 25 | } 26 | 27 | sub backticks : Local { 28 | my ($self, $c, $ls) = @_; 29 | my ($result, $code) = (undef, 1); 30 | 31 | if(!-e $ls || !-x _){ 32 | $result = 'skip'; 33 | $code = 0; 34 | } 35 | else { 36 | $result = `$ls $ls $ls` || $!; 37 | $code = $?; 38 | } 39 | 40 | $c->response->body(encode_json({result => $result, code => $code})); 41 | } 42 | 43 | sub fork : Local { 44 | my ($self, $c) = @_; 45 | my $pid; 46 | my $x = 0; 47 | 48 | if($pid = fork()){ 49 | $x = "ok"; 50 | } 51 | else { 52 | exit(0); 53 | } 54 | 55 | waitpid $pid,0 or die; 56 | 57 | $c->response->body(encode_json({pid => $pid, result => $x})); 58 | } 59 | 60 | 1; 61 | -------------------------------------------------------------------------------- /t/lib/MakeTestApp.pm: -------------------------------------------------------------------------------- 1 | package MakeTestApp; 2 | use strict; 3 | use warnings; 4 | 5 | use Exporter 'import'; 6 | use Cwd qw(abs_path); 7 | use File::Spec::Functions qw(updir catdir); 8 | use File::Basename qw(dirname); 9 | use File::Path qw(rmtree); 10 | use File::Copy::Recursive qw(dircopy); 11 | 12 | our @EXPORT = qw(make_test_app); 13 | 14 | our $root = abs_path(catdir(dirname(__FILE__), (updir) x 2)); 15 | 16 | sub make_test_app { 17 | my $tmp = "$root/t/tmp"; 18 | rmtree $tmp if -d $tmp; 19 | mkdir $tmp; 20 | 21 | # create a TestApp and copy the test libs into it 22 | my $testapp = "$tmp/TestApp"; 23 | mkdir $testapp; 24 | 25 | mkdir "$testapp/lib"; 26 | mkdir "$testapp/script"; 27 | 28 | for my $command (qw(CGI FastCGI Server)) { 29 | my $script = "$testapp/script/testapp_\L$command\E.pl"; 30 | open my $fh, '>:raw', $script 31 | or die "can't create $script: $!"; 32 | print $fh <<"END_CODE"; 33 | #!/usr/bin/env perl 34 | 35 | use Catalyst::ScriptRunner; 36 | Catalyst::ScriptRunner->run('TestApp', '$command'); 37 | 38 | 1; 39 | END_CODE 40 | close $fh; 41 | chmod 0755, $script; 42 | } 43 | 44 | open my $fh, '>:raw', "$testapp/cpanfile"; 45 | close $fh; 46 | 47 | File::Copy::Recursive::dircopy( "$root/t/lib", "$testapp/lib" ); 48 | 49 | return $testapp; 50 | } 51 | 52 | 1; 53 | -------------------------------------------------------------------------------- /t/abort-chain-1.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More tests => 1; 4 | use HTTP::Request::Common; 5 | 6 | BEGIN { 7 | package TestApp::Controller::Root; 8 | $INC{'TestApp/Controller/Root.pm'} = __FILE__; 9 | use Moose; 10 | use MooseX::MethodAttributes; 11 | extends 'Catalyst::Controller'; 12 | 13 | has counter => (is => 'rw', isa => 'Int', default => sub { 0 }); 14 | sub increment { 15 | my $self = shift; 16 | $self->counter($self->counter + 1); 17 | } 18 | sub root :Chained('/') :PathPart('') :CaptureArgs(0) { 19 | my ($self, $c, $arg) = @_; 20 | die "Died in root"; 21 | } 22 | sub main :Chained('root') :PathPart('') :Args(0) { 23 | my ($self, $c, $arg) = @_; 24 | $self->increment; 25 | die "Died in main"; 26 | } 27 | sub hits :Path('hits') :Args(0) { 28 | my ($self, $c, $arg) = @_; 29 | $c->response->body($self->counter); 30 | } 31 | __PACKAGE__->config(namespace => ''); 32 | } 33 | { 34 | package TestApp; 35 | $INC{'TestApp.pm'} = __FILE__; 36 | use Catalyst; 37 | __PACKAGE__->setup('-Log=fatal'); 38 | } 39 | 40 | use Catalyst::Test 'TestApp'; 41 | 42 | { 43 | my $res = request('/'); 44 | } 45 | { 46 | my $res = request('/hits'); 47 | is $res->content, 0, "main action not touched on crash with no explicit setting"; 48 | } 49 | -------------------------------------------------------------------------------- /t/aggregate/live_engine_request_remote_user.t: -------------------------------------------------------------------------------- 1 | # This tests to make sure the REMOTE_USER environment variable is properly passed through by the engine. 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | 9 | use Test::More tests => 7; 10 | use Catalyst::Test 'TestApp'; 11 | 12 | use Catalyst::Request; 13 | use HTTP::Request::Common; 14 | 15 | { 16 | my $creq; 17 | 18 | my $request = GET( 19 | 'http://localhost/dump/request', 20 | ); 21 | 22 | ok( my $response = request($request, { extra_env => { REMOTE_USER => 'dwc' } }), 'Request' ); 23 | ok( $response->is_success, 'Response Successful 2xx' ); 24 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); 25 | like( $response->content, qr/'Catalyst::Request'/, 26 | 'Content is a serialized Catalyst::Request' ); 27 | 28 | { 29 | no strict 'refs'; 30 | ok( 31 | eval '$creq = ' . $response->content, 32 | 'Unserialize Catalyst::Request' 33 | ) 34 | or fail("Failed to deserialize $@ from " . $response->content); 35 | } 36 | 37 | isa_ok( $creq, 'Catalyst::Request' ); 38 | SKIP: 39 | { 40 | if ( $ENV{CATALYST_SERVER} ) { 41 | skip 'Using remote server', 1; 42 | } 43 | is( $creq->remote_user, 'dwc', '$c->req->remote_user ok' ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/Catalyst/Exception.pm: -------------------------------------------------------------------------------- 1 | package Catalyst::Exception; 2 | 3 | # XXX: See bottom of file for Exception implementation 4 | 5 | =head1 NAME 6 | 7 | Catalyst::Exception - Catalyst Exception Class 8 | 9 | =head1 SYNOPSIS 10 | 11 | Catalyst::Exception->throw( qq/Fatal exception/ ); 12 | 13 | See also L. 14 | 15 | =head1 DESCRIPTION 16 | 17 | This is the Catalyst Exception class. 18 | 19 | =head1 METHODS 20 | 21 | =head2 throw( $message ) 22 | 23 | =head2 throw( message => $message ) 24 | 25 | =head2 throw( error => $error ) 26 | 27 | Throws a fatal exception. 28 | 29 | =head2 meta 30 | 31 | Provided by Moose 32 | 33 | =head1 AUTHORS 34 | 35 | Catalyst Contributors, see Catalyst.pm 36 | 37 | =head1 COPYRIGHT 38 | 39 | This library is free software. You can redistribute it and/or modify 40 | it under the same terms as Perl itself. 41 | 42 | =cut 43 | 44 | { 45 | package Catalyst::Exception::Base; 46 | 47 | use Moose; 48 | use namespace::clean -except => 'meta'; 49 | 50 | with 'Catalyst::Exception::Basic'; 51 | 52 | __PACKAGE__->meta->make_immutable; 53 | } 54 | 55 | { 56 | package Catalyst::Exception; 57 | 58 | use Moose; 59 | use namespace::clean -except => 'meta'; 60 | 61 | BEGIN { 62 | extends(our $CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base'); 63 | } 64 | 65 | __PACKAGE__->meta->make_immutable; 66 | } 67 | 68 | 1; 69 | -------------------------------------------------------------------------------- /t/optional_apache-cgi.pl: -------------------------------------------------------------------------------- 1 | # Run all tests against CGI mode under Apache 2 | # 3 | # Note, to get this to run properly, you may need to give it the path to your 4 | # httpd.conf: 5 | # 6 | # perl t/optional_apache-cgi.pl -httpd_conf /etc/apache/httpd.conf 7 | 8 | use strict; 9 | use warnings; 10 | 11 | use Apache::Test; 12 | use Apache::TestRun (); 13 | 14 | use File::Path; 15 | use File::Copy::Recursive; 16 | use FindBin; 17 | use IO::Socket; 18 | 19 | use lib 't/lib'; 20 | use MakeTestApp; 21 | 22 | make_test_app; 23 | 24 | $ENV{CATALYST_SERVER} = 'http://localhost:8529/cgi'; 25 | 26 | if ( !-e 't/optional_apache-cgi.pl' ) { 27 | die "ERROR: Please run test from the Catalyst-Runtime directory\n"; 28 | } 29 | 30 | push @ARGV, glob( 't/aggregate/live_*' ); 31 | 32 | Apache::TestRun->new->run(@ARGV); 33 | 34 | # clean up if the server has shut down 35 | # this allows the test files to stay around if the user ran -start-httpd 36 | if ( !check_port( 'localhost', 8529 ) ) { 37 | rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp"; 38 | } 39 | 40 | sub check_port { 41 | my ( $host, $port ) = @_; 42 | 43 | my $remote = IO::Socket::INET->new( 44 | Proto => "tcp", 45 | PeerAddr => $host, 46 | PeerPort => $port 47 | ); 48 | if ($remote) { 49 | close $remote; 50 | return 1; 51 | } 52 | else { 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /t/lib/TestApp/Controller/Dump.pm: -------------------------------------------------------------------------------- 1 | package TestApp::Controller::Dump; 2 | 3 | use strict; 4 | use base 'Catalyst::Controller'; 5 | 6 | sub default : Action { 7 | my ( $self, $c ) = @_; 8 | $c->forward('TestApp::View::Dump'); 9 | } 10 | 11 | sub env : Action Relative { 12 | my ( $self, $c ) = @_; 13 | $c->stash(env => $c->req->env); 14 | $c->forward('TestApp::View::Dump::Env'); 15 | } 16 | 17 | sub request : Action Relative { 18 | my ( $self, $c ) = @_; 19 | $c->req->params(undef); # Should be a no-op, and be ignored. 20 | # Back compat test for 5.7 21 | $c->forward('TestApp::View::Dump::Request'); 22 | } 23 | 24 | sub prepare_parameters : Action Relative { 25 | my ( $self, $c ) = @_; 26 | 27 | die 'Must pass in parameters' unless keys %{$c->req->parameters}; 28 | 29 | $c->req->parameters( {} ); 30 | die 'parameters are not empty' if keys %{$c->req->parameters}; 31 | 32 | # Now reset and reload 33 | $c->prepare_parameters; 34 | die 'Parameters were not reset' unless keys %{$c->req->parameters}; 35 | 36 | $c->forward('TestApp::View::Dump::Request'); 37 | } 38 | sub response : Action Relative { 39 | my ( $self, $c ) = @_; 40 | $c->forward('TestApp::View::Dump::Response'); 41 | } 42 | 43 | sub body : Action Relative { 44 | my ( $self, $c ) = @_; 45 | $c->forward('TestApp::View::Dump::Body'); 46 | } 47 | 48 | 1; 49 | -------------------------------------------------------------------------------- /t/optional_apache-fastcgi.pl: -------------------------------------------------------------------------------- 1 | # Run all tests against FastCGI mode under Apache 2 | # 3 | # Note, to get this to run properly, you may need to give it the path to your 4 | # httpd.conf: 5 | # 6 | # perl t/optional_apache-fastcgi.pl -httpd_conf /etc/apache/httpd.conf 7 | 8 | use strict; 9 | use warnings; 10 | 11 | use Apache::Test; 12 | use Apache::TestRun (); 13 | 14 | use File::Path; 15 | use File::Copy::Recursive; 16 | use FindBin; 17 | use IO::Socket; 18 | 19 | use lib 't/lib'; 20 | use MakeTestApp; 21 | 22 | make_test_app; 23 | 24 | $ENV{CATALYST_SERVER} = 'http://localhost:8529'; 25 | 26 | if ( !-e 't/optional_apache-fastcgi.pl' ) { 27 | die "ERROR: Please run test from the Catalyst-Runtime directory\n"; 28 | } 29 | 30 | push @ARGV, glob( 't/aggregate/live_*' ); 31 | 32 | Apache::TestRun->new->run(@ARGV); 33 | 34 | # clean up if the server has shut down 35 | # this allows the test files to stay around if the user ran -start-httpd 36 | if ( !check_port( 'localhost', 8529 ) ) { 37 | rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp"; 38 | } 39 | 40 | sub check_port { 41 | my ( $host, $port ) = @_; 42 | 43 | my $remote = IO::Socket::INET->new( 44 | Proto => "tcp", 45 | PeerAddr => $host, 46 | PeerPort => $port 47 | ); 48 | if ($remote) { 49 | close $remote; 50 | return 1; 51 | } 52 | else { 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /t/optional_apache-cgi-rewrite.pl: -------------------------------------------------------------------------------- 1 | # Run all tests against CGI mode under Apache 2 | # 3 | # Note, to get this to run properly, you may need to give it the path to your 4 | # httpd.conf: 5 | # 6 | # perl t/optional_apache-cgi.pl -httpd_conf /etc/apache/httpd.conf 7 | 8 | use strict; 9 | use warnings; 10 | 11 | use Apache::Test; 12 | use Apache::TestRun (); 13 | 14 | use File::Path; 15 | use File::Copy::Recursive; 16 | use FindBin; 17 | use IO::Socket; 18 | 19 | use lib 't/lib'; 20 | use MakeTestApp; 21 | 22 | make_test_app; 23 | 24 | $ENV{CATALYST_SERVER} = 'http://localhost:8529/rewrite'; 25 | 26 | if ( !-e 't/optional_apache-cgi-rewrite.pl' ) { 27 | die "ERROR: Please run test from the Catalyst-Runtime directory\n"; 28 | } 29 | 30 | push @ARGV, glob( 't/aggregate/live_*' ); 31 | 32 | Apache::TestRun->new->run(@ARGV); 33 | 34 | # clean up if the server has shut down 35 | # this allows the test files to stay around if the user ran -start-httpd 36 | if ( !check_port( 'localhost', 8529 ) ) { 37 | rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp"; 38 | } 39 | 40 | sub check_port { 41 | my ( $host, $port ) = @_; 42 | 43 | my $remote = IO::Socket::INET->new( 44 | Proto => "tcp", 45 | PeerAddr => $host, 46 | PeerPort => $port 47 | ); 48 | if ($remote) { 49 | close $remote; 50 | return 1; 51 | } 52 | else { 53 | return 0; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /t/lib/TestFromPSGI/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package TestFromPSGI::Controller::Root; 2 | 3 | use Moose; 4 | use MooseX::MethodAttributes; 5 | 6 | extends 'Catalyst::Controller'; 7 | 8 | sub test_psgi_keys :Local { 9 | my ($self, $c) = @_; 10 | $c->res->body('ok'); 11 | } 12 | 13 | sub from_psgi_array : Local { 14 | my ($self, $c) = @_; 15 | my $res = sub { 16 | my ($env) = @_; 17 | return [200, ['Content-Type'=>'text/plain'], 18 | [qw/hello world today/]]; 19 | }->($c->req->env); 20 | 21 | $c->res->from_psgi_response($res); 22 | } 23 | 24 | sub from_psgi_code : Local { 25 | my ($self, $c) = @_; 26 | 27 | my $res = sub { 28 | my ($env) = @_; 29 | return sub { 30 | my $responder = shift; 31 | return $responder->([200, ['Content-Type'=>'text/plain'], 32 | [qw/hello world today2/]]); 33 | }; 34 | }->($c->req->env); 35 | 36 | $c->res->from_psgi_response($res); 37 | } 38 | 39 | sub from_psgi_code_itr : Local { 40 | my ($self, $c) = @_; 41 | my $res = sub { 42 | my ($env) = @_; 43 | return sub { 44 | my $responder = shift; 45 | my $writer = $responder->([200, ['Content-Type'=>'text/plain']]); 46 | $writer->write('hello'); 47 | $writer->write('world'); 48 | $writer->write('today3'); 49 | $writer->close; 50 | }; 51 | }->($c->req->env); 52 | 53 | $c->res->from_psgi_response($res); 54 | } 55 | 56 | __PACKAGE__->meta->make_immutable; 57 | -------------------------------------------------------------------------------- /t/plugin_new_method_backcompat.t: -------------------------------------------------------------------------------- 1 | # Test that plugins with their own new method don't break applications. 2 | 3 | # 5.70 creates all of the request/response structure itself in prepare, 4 | # and as the new method in our plugin just blesses our args, that works nicely. 5 | 6 | # In 5.80, we rely on the new method to appropriately initialise data 7 | # structures, and therefore we need to inline a new method on MyApp to ensure 8 | # that plugins don't get it wrong for us. 9 | 10 | # Also tests method modifiers and etc in MyApp.pm still work as expected. 11 | use Test::More; 12 | use Moose::Util qw/find_meta/; 13 | use FindBin; 14 | use lib "$FindBin::Bin/lib"; 15 | 16 | use Catalyst::Test qw/TestAppPluginWithConstructor/; 17 | TestAppPluginWithConstructor->_make_immutable_if_needed; 18 | ok find_meta('TestAppPluginWithConstructor')->is_immutable, 19 | 'Am immutable after use'; 20 | 21 | ok request('/foo')->is_success, 'Can get /foo'; 22 | is $TestAppPluginWithConstructor::MODIFIER_FIRED, 1, 'Before modifier was fired correctly.'; 23 | 24 | my $warning; 25 | eval "use TestAppBadlyImmutable"; 26 | local $SIG{__WARN__} = sub { $warning .= $_[0] }; 27 | 28 | TestAppBadlyImmutable->_make_immutable_if_needed; 29 | 30 | like $warning, qr/\QYou made your application class (TestAppBadlyImmutable) immutable/, 31 | 'An application class that is already immutable but does not inline the constructor warns at ->setup'; 32 | 33 | done_testing; 34 | 35 | -------------------------------------------------------------------------------- /t/undef-params.t: -------------------------------------------------------------------------------- 1 | use warnings; 2 | use strict ; 3 | use Test::More; 4 | use HTTP::Request::Common; 5 | use Plack::Test; 6 | 7 | # If someone does $c->req->params(undef) you don't get a very good 8 | # error message. This is a test to see if the proposed change improves 9 | # that. 10 | 11 | 12 | { 13 | package MyApp::Controller::Root; 14 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; 15 | 16 | use base 'Catalyst::Controller'; 17 | 18 | sub test :Local { 19 | my ($self, $c) = @_; 20 | my $value = $c->req->param(undef); 21 | 22 | $c->response->body("This is the body"); 23 | } 24 | 25 | sub set_params :Local { 26 | my ($self, $c) = @_; 27 | $c->req->param(foo => 'a', 'b', 'c'); 28 | $c->res->body(join ',', $c->req->param('foo')); 29 | } 30 | 31 | package MyApp; 32 | use Catalyst; 33 | 34 | $SIG{__WARN__} = sub { 35 | my $error = shift; 36 | Test::More::like($error, qr[You called ->params with an undefined value]) 37 | unless MyApp->debug; 38 | }; 39 | 40 | MyApp->setup; 41 | } 42 | 43 | ok my $psgi = MyApp->psgi_app, 'build psgi app'; 44 | 45 | test_psgi $psgi, sub { 46 | my $cb = shift; 47 | 48 | { 49 | my $res = $cb->(GET "/root/test"); 50 | is $res->code, 200, 'OK'; 51 | } 52 | 53 | { 54 | my $res = $cb->(GET "/root/set_params"); 55 | is $res->code, 200, 'OK'; 56 | is $res->content, 'a,b,c'; 57 | } 58 | }; 59 | 60 | done_testing; 61 | -------------------------------------------------------------------------------- /t/lib/CDICompatTestPlugin.pm: -------------------------------------------------------------------------------- 1 | package CDICompatTestPlugin; 2 | 3 | # This plugin specificially tests an edge case of C::D::I compat, 4 | # where you load a plugin which creates an accessor with the same 5 | # name as a class data accessor (_config in this case).. 6 | 7 | # This is what happens if you use the authentication back-compat 8 | # stuff, as C::A::Plugin::Credential::Password is added to the plugin 9 | # list, and that uses base C::A::C::P class, does the mk_accessors. 10 | 11 | # If a class data method called _config hasn't been created in 12 | # MyApp ($app below), then our call to ->config gets our accessor 13 | # (rather than the class data one), and we fail.. 14 | 15 | use strict; 16 | use warnings; 17 | use base qw/Class::Accessor::Fast/; 18 | use MRO::Compat; 19 | __PACKAGE__->mk_accessors(qw/_config/); 20 | 21 | sub setup { 22 | my $app = shift; 23 | 24 | $app->config; 25 | $app->next::method(@_); 26 | } 27 | 28 | # However, if we are too enthusiastic about adding accessors to the 29 | # MyApp package, then this method isn't called (as there is a local 30 | # symbol already). 31 | 32 | # Note - use a different package here, so that Moose's 33 | # package detection code doesn't get confused.. 34 | $CDICompatTestPlugin::Data::HAS_RUN_SETUP_FINISHED = 0; 35 | 36 | sub setup_finished { 37 | my $app = shift; 38 | $CDICompatTestPlugin::Data::HAS_RUN_SETUP_FINISHED = 1; 39 | $app->next::method(@_); 40 | } 41 | 42 | 1; 43 | --------------------------------------------------------------------------------