Permalink
Browse files

MDL-33550 Set default status for file =0 and correct setting user in …

…phpunit test
  • Loading branch information...
1 parent 0b2bfbd commit cfc4db405c9f0f747a0bdebb8ca4277b117c2bff @marinaglancy marinaglancy committed Jun 14, 2012
Showing with 4 additions and 1 deletion.
  1. +3 −0 lib/filestorage/file_storage.php
  2. +1 −1 lib/filestorage/tests/file_storage_test.php
@@ -1033,6 +1033,7 @@ public function create_file_from_pathname($filerecord, $pathname) {
$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 @@ public function create_file_from_string($filerecord, $content) {
$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 @@ public function create_file_from_reference($filerecord, $repositoryid, $referenc
$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 '/'.
@@ -159,9 +159,9 @@ public function test_create_file_from_reference() {
// 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();

0 comments on commit cfc4db4

Please sign in to comment.