From 218d751d0781a29ce5ef9c42feed91cba91bad5c Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 16 Apr 2014 17:29:22 +0800 Subject: [PATCH] MDL-45132 curl: Unit Tests for file uploads --- lib/tests/filelib_test.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/tests/filelib_test.php b/lib/tests/filelib_test.php index 4b5c20a260b..aa07dc58b64 100644 --- a/lib/tests/filelib_test.php +++ b/lib/tests/filelib_test.php @@ -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 *