Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56918632
assertHttp.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
915 B
Referenced Files
None
Subscribers
None
assertHttp.php
View Options
<?php
trait
assertHttp
{
/**
* Asserts the HTTP response code of an URL matches the expected code
*
* @param int $expectedCode the expected HTTP response code
* @param string $url the URL to check
* @param string $comment the comment to output if the test fails [facultative]
*/
private
function
assertHttpResponseCode
(
$expectedCode
,
$url
,
$comment
=
''
)
{
$actualCode
=
$this
->
getHttpResponseCode
(
$url
);
return
$this
->
assertEquals
(
$expectedCode
,
$actualCode
,
$comment
);
}
/**
* Gets the HTTP response code of the specified URL
*
* @param string $url
* @return int the HTTP response code
*/
private
function
getHttpResponseCode
(
$url
)
{
$ch
=
curl_init
(
$url
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
"Nasqueron-Ops-Tests"
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
$code
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
curl_close
(
$ch
);
return
$code
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Nov 12, 20:20 (6 d, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4217843
Default Alt Text
assertHttp.php (915 B)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment