X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_setup.t;h=cbc5aaccf6f73932fc21773aa19aafeb2c844b37;hb=c68a3c90180235a2a464ce237a96fef79db468bf;hp=bcf3030df8985eac2ebaa934cc5a67adf35e679c;hpb=d31581c60ff345e3fa71ca66bc83e826935b158b;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_setup.t b/t/unit_core_setup.t index bcf3030..cbc5aac 100644 --- a/t/unit_core_setup.t +++ b/t/unit_core_setup.t @@ -1,5 +1,6 @@ use strict; use warnings; +use Class::MOP::Class; use Catalyst::Runtime; use Test::More tests => 29; @@ -25,22 +26,29 @@ sub build_test_app_with_setup { return $name; } +local %ENV = %ENV; + +# Remove all relevant env variables to avoid accidental fail +foreach my $name (grep { /^(CATALYST|TESTAPP)/ } keys %ENV) { + delete $ENV{$name}; +} + { - my $app = build_test_app_with_setup('MyTestDebug', '-Debug'); + my $app = build_test_app_with_setup('TestAppMyTestDebug', '-Debug'); - ok my $c = MyTestDebug->new, 'Get debug app object'; + ok my $c = $app->new, 'Get debug app object'; ok my $log = $c->log, 'Get log object'; isa_ok $log, 'Catalyst::Log', 'It should be a Catalyst::Log object'; - ok !$log->is_warn, 'Warnings should be disabled'; - ok !$log->is_error, 'Errors should be disabled'; - ok !$log->is_fatal, 'Fatal errors should be disabled'; - ok !$log->is_info, 'Info should be disabled'; + ok $log->is_warn, 'Warnings should be enabled'; + ok $log->is_error, 'Errors should be enabled'; + ok $log->is_fatal, 'Fatal errors should be enabled'; + ok $log->is_info, 'Info should be enabled'; ok $log->is_debug, 'Debugging should be enabled'; ok $app->debug, 'debug method should return true'; } { - my $app = build_test_app_with_setup('MyTestLogParam', '-Log=warn,error,fatal'); + my $app = build_test_app_with_setup('TestAppMyTestLogParam', '-Log=warn,error,fatal'); ok my $c = $app->new, 'Get log app object'; ok my $log = $c->log, 'Get log object'; @@ -53,7 +61,7 @@ sub build_test_app_with_setup { ok !$c->debug, 'Catalyst debugging is off'; } { - my $app = build_test_app_with_setup('MyTestNoParams'); + my $app = build_test_app_with_setup('TestAppMyTestNoParams'); ok my $c = $app->new, 'Get log app object'; ok my $log = $c->log, 'Get log object'; @@ -65,16 +73,16 @@ sub build_test_app_with_setup { ok $log->is_debug, 'Debugging should be enabled'; ok !$c->debug, 'Catalyst debugging turned off'; } +my $log_meta = Class::MOP::Class->create_anon_class( + methods => { map { $_ => sub { 0 } } qw/debug error fatal info warn/ }, +); { - package MyTestAppWithOwnLogger; + package TestAppWithOwnLogger; use base qw/Catalyst/; - use Test::MockObject; - my $log = Test::MockObject->new; - $log->set_false(qw/debug error fatal info warn/); - __PACKAGE__->log($log); + __PACKAGE__->log($log_meta->new_object); __PACKAGE__->setup('-Debug'); } -ok my $c = MyTestAppWithOwnLogger->new, 'Get with own logger app object'; +ok my $c = TestAppWithOwnLogger->new, 'Get with own logger app object'; ok $c->debug, '$c->debug is true';