mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'MDL-79341-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
0717d4ea0e
@ -1254,18 +1254,16 @@ EOF;
|
||||
$this->assertTrue(in_array("User-Agent: $moodlebot", $curl->header));
|
||||
|
||||
// Finally, test it via exttests, to ensure the agent is sent properly.
|
||||
// Matching.
|
||||
$testurl = $this->getExternalTestFileUrl('/test_agent.php');
|
||||
$extcurl = new \curl();
|
||||
|
||||
// Matching (assert we don't receive an error, and get back the content "OK").
|
||||
$contents = $extcurl->get($testurl, array(), array('CURLOPT_USERAGENT' => 'AnotherUserAgent/1.2'));
|
||||
$response = $extcurl->getResponse();
|
||||
$this->assertSame('200 OK', reset($response));
|
||||
$this->assertSame(0, $extcurl->get_errno());
|
||||
$this->assertSame('OK', $contents);
|
||||
// Not matching.
|
||||
|
||||
// Not matching (assert we don't receive an error, and get back empty content - not "OK").
|
||||
$contents = $extcurl->get($testurl, array(), array('CURLOPT_USERAGENT' => 'NonMatchingUserAgent/1.2'));
|
||||
$response = $extcurl->getResponse();
|
||||
$this->assertSame('200 OK', reset($response));
|
||||
$this->assertSame(0, $extcurl->get_errno());
|
||||
$this->assertSame('', $contents);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user