11 package TestCreateScript;
13 extends 'Catalyst::Script::Create';
15 sub _exit_with_usage { $help++ }
19 package TestHelperClass;
22 has 'newfiles' => ( is => 'ro', init_arg => '.newfiles' );
23 has 'mech' => ( is => 'ro' );
29 %p = ( '.newfiles' => $self->newfiles, mech => $self->mech);
30 return $self->_mk_component_return;
32 sub _mk_component_return { 1 }
35 package TestHelperClass::False;
37 extends 'TestHelperClass';
38 sub _mk_component_return { 0 }
42 local $TestCreateScript::help;
45 TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run;
47 ok $TestCreateScript::help, 'Exited with usage info';
50 local $TestCreateScript::help;
52 local @TestHelperClass::ARGS;
53 local %TestHelperClass::p;
55 TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run;
57 ok !$TestCreateScript::help, 'Did not exit with usage into';
58 is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct';
59 is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct';
63 local $TestCreateScript::help;
65 local @TestHelperClass::ARGS;
66 local %TestHelperClass::p;
68 TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass::False')->run;
70 ok $TestCreateScript::help, 'Did exit with usage into as mk_component returned false';
71 is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct';
72 is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct';