Fixes port environment, RT#52604
Tomas Doran [Wed, 9 Dec 2009 20:21:13 +0000 (20:21 +0000)]
lib/Catalyst/Script/Server.pm
t/aggregate/unit_core_script_server.t

index 6d44bd4..8226af4 100644 (file)
@@ -8,6 +8,7 @@ BEGIN {
 use Moose;
 use MooseX::Types::Common::Numeric qw/PositiveInt/;
 use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/;
+use Catalyst::Utils;
 use namespace::autoclean;
 
 with 'Catalyst::ScriptRole';
@@ -45,7 +46,10 @@ has port => (
     cmd_aliases   => 'p',
     isa           => PositiveInt,
     is            => 'ro',
-    default       => 3000,
+    default       => sub {
+        my $self = shift;
+        $ENV{ Catalyst::Utils::class2env($self->application_name . '_PORT')}||3000
+    },
     documentation => 'Specify a different listening port (to the default port 3000)',
 );
 
index 258255e..96b7a9f 100644 (file)
@@ -26,6 +26,10 @@ testOption( [ qw/-h testhost/ ], ['3000', 'testhost', opthash()] );
 # port           -p -port --port           -l --listen
 testOption( [ qw/-p 3001/ ], ['3001', undef, opthash()] );
 testOption( [ qw/--port 3001/ ], ['3001', undef, opthash()] );
+{
+    local $ENV{TESTAPPTOTESTSCRIPTS_PORT} = 5000;
+    testOption( [ qw// ], [5000, undef, opthash()] );
+}
 
 # fork           -f -fork --fork           -f --fork
 testOption( [ qw/--fork/ ], ['3000', undef, opthash(fork => 1)] );