From 71e38b128e6b54589e531b02b3d8face26c1aab6 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 4 Jul 2013 10:47:38 +0800 Subject: [PATCH] MDL-40039 phpunit: Test core_files_external::upload() without the new params --- files/tests/externallib_test.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/files/tests/externallib_test.php b/files/tests/externallib_test.php index 38472be16dfbd..ce91c1c9749cd 100644 --- a/files/tests/externallib_test.php +++ b/files/tests/externallib_test.php @@ -147,4 +147,27 @@ public function test_upload_param_area() { $filename, $filecontent, $contextlevel, $instanceid); } + /* + * Make sure core_files_external::upload() works without new parameters. + */ + public function test_upload_without_new_param() { + global $USER; + + $this->resetAfterTest(); + $this->setAdminUser(); + $context = context_user::instance($USER->id); + $contextid = $context->id; + $component = "user"; + $filearea = "private"; + $itemid = 0; + $filepath = "/"; + $filename = "Simple4.txt"; + $filecontent = base64_encode("Let us create a nice simple file"); + + // Make sure the file is created. + @core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent); + $browser = get_file_browser(); + $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename); + $this->assertNotEmpty($file); + } } \ No newline at end of file