From 5d86baa5051145f23460bcc97a457056bd4595f5 Mon Sep 17 00:00:00 2001 From: Domenic Del Nano Date: Thu, 2 Feb 2017 06:13:46 -0500 Subject: [PATCH 1/3] Add test that should fail --- bin/dredd-hooks-php | 11 ++++--- features/configurable_port.feature | 49 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 features/configurable_port.feature diff --git a/bin/dredd-hooks-php b/bin/dredd-hooks-php index b25b386..eb22849 100755 --- a/bin/dredd-hooks-php +++ b/bin/dredd-hooks-php @@ -24,11 +24,12 @@ if (!$loaded) { } // Get options from the command line -$options = getopt('', [ - 'host:', - 'port:', - 'force', -]); +$options = []; +/* $options = getopt('', [ */ +/* '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 + """ From ba28ec9291101d1b33a20a5efe8bdf5af714547c Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Tue, 7 Feb 2017 22:11:32 -0500 Subject: [PATCH 2/3] Remove trusty --- .travis.yml | 1 - 1 file changed, 1 deletion(-) 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 From b52dd5bce850ac8adc0c5649b0dac6e7df2cdcbd Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Tue, 7 Feb 2017 22:15:21 -0500 Subject: [PATCH 3/3] Allow tests to pass --- bin/dredd-hooks-php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/dredd-hooks-php b/bin/dredd-hooks-php index eb22849..0eaca81 100755 --- a/bin/dredd-hooks-php +++ b/bin/dredd-hooks-php @@ -24,12 +24,11 @@ if (!$loaded) { } // Get options from the command line -$options = []; -/* $options = getopt('', [ */ -/* 'host:', */ -/* 'port:', */ -/* 'force', */ -/* ]); */ +$options = getopt('', [ + 'host:', + 'port:', + 'force', + ]); Hooks::loadHooks($argv);