MDL-45132 curl: Unit Tests for file uploads
This commit is contained in:
@@ -471,6 +471,29 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertSame('OK', $contents);
|
||||
}
|
||||
|
||||
public function test_curl_file() {
|
||||
$this->resetAfterTest();
|
||||
$testurl = $this->getExternalTestFileUrl('/test_file.php');
|
||||
|
||||
$fs = get_file_storage();
|
||||
$filerecord = array(
|
||||
'contextid' => context_system::instance()->id,
|
||||
'component' => 'test',
|
||||
'filearea' => 'curl_post',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/',
|
||||
'filename' => 'test.txt'
|
||||
);
|
||||
$teststring = 'moodletest';
|
||||
$testfile = $fs->create_file_from_string($filerecord, $teststring);
|
||||
|
||||
// Test post with file.
|
||||
$data = array('testfile' => $testfile);
|
||||
$curl = new curl();
|
||||
$contents = $curl->post($testurl, $data);
|
||||
$this->assertSame('OK', $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing prepare draft area
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user