Skip to content

Commit

Permalink
testcase request methods
Browse files Browse the repository at this point in the history
  • Loading branch information
schpill committed Jun 9, 2017
1 parent bb0822b commit ca978b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5636,7 +5636,7 @@ function mailer()
$transport = \Swift_SmtpTransport::newInstance(
appenv('SMTP_HOST', 'localhost'),
appenv('SMTP_PORT', 443),
'ssl'
appenv('SMTP_SECURITY', 'ssl')
)
->setUsername(appenv('SMTP_USER', 'root'))
->setPassword(appenv('SMTP_PASSWORD', 'root'));
Expand Down
26 changes: 25 additions & 1 deletion lib/testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,30 @@ public function patch($url, $options = [])

public function request($type, $url, $options = [])
{
return client()->request(Strings::upper($type), $url, $options);
if (!fnmatch('*://*', $url)) {
if (isset($_ENV['APPLICATION_URL'])) {
$url = $_ENV['APPLICATION_URL'] . $url;
}
}

$response = client()->request(Strings::upper($type), $url, $options);

$customResponse = dyn($response);

$customResponse->macro('content', function ($response) {
return $response->getBody()->getContents();
});

$customResponse->macro('header', function ($key, $response) {
if ($response->hasHeader($key)) {
$header = $response->getHeader($key);

return is_array($header) && count($header) == 1 ? current($header) : $header;
}

return null;
});

return $customResponse;
}
}

0 comments on commit ca978b4

Please sign in to comment.