diff --git a/.travis.yml b/.travis.yml index bd2c045..e6e2dee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ sudo: required -dist: trusty language: php before_install: - npm install -g dredd diff --git a/bin/dredd-hooks-php b/bin/dredd-hooks-php index b25b386..0eaca81 100755 --- a/bin/dredd-hooks-php +++ b/bin/dredd-hooks-php @@ -25,10 +25,10 @@ if (!$loaded) { // Get options from the command line $options = getopt('', [ - 'host:', - 'port:', - 'force', -]); + 'host:', + 'port:', + 'force', + ]); Hooks::loadHooks($argv); diff --git a/features/configurable_port.feature b/features/configurable_port.feature new file mode 100644 index 0000000..3ef310c --- /dev/null +++ b/features/configurable_port.feature @@ -0,0 +1,49 @@ +Feature: Configurable port + + Background: + Given I have "dredd-hooks-php" command installed + And I have "dredd" command installed + And a file named "server.rb" with: + """ + require 'sinatra' + get '/message' do + "Hello World!\n\n" + end + """ + + And a file named "apiary.apib" with: + """ + # My Api + ## GET /message + + Response 200 (text/html;charset=utf-8) + Hello World! + """ + + @announce + Scenario: + Given a file named "hooks/execution_order_hookfile.php" with: + """ + GET', function(&$transaction) use ($key) { + + if ( ! property_exists($transaction, $key)) $transaction->{$key} = []; + + $transaction->{$key}[] = "listening on different port"; + }); + """ + + Given I set the environment variables to: + | variable | value | + | TEST_DREDD_HOOKS_HANDLER_ORDER | true | + + When I run `dredd ./apiary.apib http://localhost:4567 --hooks-worker-handler-port 61325 --server "ruby server.rb" --language dredd-hooks-php --hookfiles hooks/execution_order_hookfile.php` + Then the exit status should be 0 + Then the output should contain: + """ + 0 listening on different port + """