MDL-45132 curl: Unit Tests for file uploads

This commit is contained in:
Frederic Massart
2014-04-16 17:29:22 +08:00
parent 4916184896
commit 218d751d07
+23
View File
@@ -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
*