Skip to content

Commit

Permalink
print postcode redirect if run under CLI for testing
Browse files Browse the repository at this point in the history
The test framework runs under CLI which means the headers aren't
printed so we can't test redirects. To get round this check if we are
running under the CLI and then print out the header.
  • Loading branch information
struan committed Apr 13, 2017
1 parent fbcd7f3 commit d30a7a1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion www/docs/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@ function member_redirect(&$MEMBER, $options = array()) {
} else {
$url = $MEMBER->url();
}
header("Location: $url");
// awfulness so we can test this works becuase we use the CLI
// in our test framework for page requests and the CLI doesn't
// print out headers
if (php_sapi_name() === 'cli') {
print("Location: $url");
} else {
header("Location: $url");
}
exit;
}
}
Expand Down

0 comments on commit d30a7a1

Please sign in to comment.