X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_setup_stats.t;h=9f7a8d318002c2fb2e0135ec4d83b67bffe948fb;hb=08f9c84867673a57d45bacbda7a301734a720fe7;hp=ed79147252794b073cbef6c4670b60e2c8d9d825;hpb=69c272738eeb23ce56dfec8840581a167b0b88c3;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_setup_stats.t b/t/unit_core_setup_stats.t index ed79147..9f7a8d3 100644 --- a/t/unit_core_setup_stats.t +++ b/t/unit_core_setup_stats.t @@ -22,44 +22,47 @@ my $mock_log = Class::MOP::Class->create_anon_class( sub mock_app { my $name = shift; %log_messages = (); # Flatten log messages. - print "Setting up mock application: $name\n"; + diag "Setting up mock application: $name"; my $meta = Moose->init_meta( for_class => $name ); $meta->superclasses('Catalyst'); $meta->add_method('log', sub { $mock_log }); return $meta->name; } -mock_app('UnusedApp'); # Mock an app before localizing %ENV - # to ensure that anything which is dynamically - # loaded from the enviornment is loaded +local %ENV = %ENV; -local %ENV; # Ensure blank or someone, somewhere will fail.. +# Remove all relevant env variables to avoid accidental fail +foreach my $name (grep { /^(CATALYST|TESTAPP)/ } keys %ENV) { + delete $ENV{$name}; +} { - my $app = mock_app('TestNoStats'); + my $app = mock_app('TestAppNoStats'); $app->setup_stats(); ok !$app->use_stats, 'stats off by default'; } { - my $app = mock_app('TestStats'); + my $app = mock_app('TestAppStats'); $app->setup_stats(1); ok $app->use_stats, 'stats on if you say >setup_stats(1)'; } { - my $app = mock_app('TestStatsDebugTurnsStatsOn'); + my $app = mock_app('TestAppStatsDebugTurnsStatsOn'); $app->meta->add_method('debug' => sub { 1 }); $app->setup_stats(); ok $app->use_stats, 'debug on turns stats on'; } { - local %ENV = ( CATALYST_STATS => 1 ); - my $app = mock_app('TestStatsAppStatsEnvSet'); + local %ENV = %ENV; + $ENV{CATALYST_STATS} = 1; + my $app = mock_app('TestAppStatsEnvSet'); $app->setup_stats(); ok $app->use_stats, 'ENV turns stats on'; } { - local %ENV = ( CATALYST_STATS => 0 ); - my $app = mock_app('TestStatsAppStatsEnvUnset'); + local %ENV = %ENV; + $ENV{CATALYST_STATS} = 0; + my $app = mock_app('TestAppStatsEnvUnset'); $app->meta->add_method('debug' => sub { 1 }); $app->setup_stats(1); ok !$app->use_stats, 'ENV turns stats off, even when debug on and ->setup_stats(1)';