Fix bug stopping fastcgi script working
Tomas Doran [Sun, 27 Mar 2011 15:20:50 +0000 (16:20 +0100)]
lib/Catalyst/EngineLoader.pm
t/aggregate/unit_engineloader.t [new file with mode: 0644]

index b48022e..818b9f0 100644 (file)
@@ -39,7 +39,7 @@ sub _guess_catalyst_engine_class {
     if (!defined $old_engine) {
         return 'Catalyst::Engine';
     }
-    elsif ($old_engine =~ /^(PSGI|CGI|FCGI|HTTP|Apache.*)$/) {
+    elsif ($old_engine =~ /^(PSGI|CGI|FastCGI|HTTP|Apache.*)$/) {
         return 'Catalyst::Engine';
     }
     else {
@@ -82,7 +82,8 @@ around guess => sub {
     my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
     if (!defined $old_engine) { # Not overridden
     }
-    elsif ($old_engine =~ /^(PSGI|CGI|FCGI|HTTP|Apache.*)$/) {
+    elsif ($old_engine =~ /^(PSGI|CGI|FastCGI|HTTP|Apache.*)$/) {
+>>>>>>> Fix bug stopping fastcgi script working
         # Trust autodetect
     }
     elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options
diff --git a/t/aggregate/unit_engineloader.t b/t/aggregate/unit_engineloader.t
new file mode 100644 (file)
index 0000000..7758636
--- /dev/null
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+use Test::More;
+use Catalyst::EngineLoader;
+
+my $cases = {
+    FastCGI => {
+        expected_catalyst_engine_class => 'Catalyst::Engine',
+        ENV => { CATALYST_ENGINE => 'FastCGI' },
+    },
+    CGI => {
+        expected_catalyst_engine_class => 'Catalyst::Engine',
+        ENV => { CATALYST_ENGINE => 'CGI' },
+    },
+    Apache1 => {
+        expected_catalyst_engine_class => 'Catalyst::Engine',
+        ENV => { CATALYST_ENGINE => 'Apache1' },
+    },
+};
+
+foreach my $name (keys %$cases) {
+    local %ENV = %{ $cases->{$name}->{ENV} };
+    my $loader = Catalyst::EngineLoader->new(application_name => "TestApp");
+    if (my $expected = $cases->{$name}->{expected_catalyst_engine_class}) {
+        is $loader->catalyst_engine_class, $expected, $name . " catalyst_engine_class";
+    }
+}
+
+done_testing;