MDL-33550 Set default status for file =0 and correct setting user in phpunit test
authorMarina Glancy <marina@moodle.com>
Thu, 14 Jun 2012 06:52:31 +0000 (14:52 +0800)
committerMarina Glancy <marina@moodle.com>
Thu, 14 Jun 2012 06:52:31 +0000 (14:52 +0800)
lib/filestorage/file_storage.php
lib/filestorage/tests/file_storage_test.php

index fda3e5b..fd9f63c 100644 (file)
@@ -1033,6 +1033,7 @@ class file_storage {
         $newrecord->source       = empty($filerecord->source) ? null : $filerecord->source;
         $newrecord->author       = empty($filerecord->author) ? null : $filerecord->author;
         $newrecord->license      = empty($filerecord->license) ? null : $filerecord->license;
+        $newrecord->status       = empty($filerecord->status) ? 0 : $filerecord->status;
         $newrecord->sortorder    = $filerecord->sortorder;
 
         list($newrecord->contenthash, $newrecord->filesize, $newfile) = $this->add_file_to_pool($pathname);
@@ -1149,6 +1150,7 @@ class file_storage {
         $newrecord->source       = empty($filerecord->source) ? null : $filerecord->source;
         $newrecord->author       = empty($filerecord->author) ? null : $filerecord->author;
         $newrecord->license      = empty($filerecord->license) ? null : $filerecord->license;
+        $newrecord->status       = empty($filerecord->status) ? 0 : $filerecord->status;
         $newrecord->sortorder    = $filerecord->sortorder;
 
         list($newrecord->contenthash, $newrecord->filesize, $newfile) = $this->add_string_to_pool($content);
@@ -1223,6 +1225,7 @@ class file_storage {
         $filerecord->source            = empty($filerecord->source) ? null : $filerecord->source;
         $filerecord->author            = empty($filerecord->author) ? null : $filerecord->author;
         $filerecord->license           = empty($filerecord->license) ? null : $filerecord->license;
+        $filerecord->status            = empty($filerecord->status) ? 0 : $filerecord->status;
         $filerecord->filepath          = clean_param($filerecord->filepath, PARAM_PATH);
         if (strpos($filerecord->filepath, '/') !== 0 or strrpos($filerecord->filepath, '/') !== strlen($filerecord->filepath)-1) {
             // Path must start and end with '/'.
index 818d47b..d787bba 100644 (file)
@@ -159,9 +159,9 @@ class filestoragelib_testcase extends advanced_testcase {
         // create user
         $generator = $this->getDataGenerator();
         $user = $generator->create_user();
+        $this->setUser($user);
         $usercontext = context_user::instance($user->id);
         $syscontext = context_system::instance();
-        $USER = $DB->get_record('user', array('id'=>$user->id));
 
         $fs = get_file_storage();