Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-43926 files: Unit tests cannot assume id values.

  • Loading branch information...
commit 42e34c2882d8e3596477b3db56b411a5e4f5ada6 1 parent 37a079a
@mr-russ mr-russ authored marinaglancy committed
Showing with 8 additions and 7 deletions.
  1. +8 −7 files/tests/externallib_test.php
View
15 files/tests/externallib_test.php
@@ -251,6 +251,7 @@ public function test_get_files() {
$testfilelisting = core_files_external::get_files($context->id, $component, $filearea, $itemid, '/', $filename);
// With the information that we have provided we should get an object exactly like the one below.
+ $coursecontext = context_course::instance($course->id);
$testdata = array();
$testdata['parents'] = array();
$testdata['parents']['0'] = array('contextid' => 1,
@@ -265,36 +266,36 @@ public function test_get_files() {
'itemid' => null,
'filepath' => null,
'filename' => 'Miscellaneous');
- $testdata['parents']['2'] = array('contextid' => 15,
+ $testdata['parents']['2'] = array('contextid' => $coursecontext->id,
'component' => null,
'filearea' => null,
'itemid' => null,
'filepath' => null,
'filename' => 'Test course 1');
- $testdata['parents']['3'] = array('contextid' => 20,
+ $testdata['parents']['3'] = array('contextid' => $context->id,
'component' => null,
'filearea' => null,
'itemid' => null,
'filepath' => null,
'filename' => 'Mod data upload test (Database)');
- $testdata['parents']['4'] = array('contextid' => 20,
+ $testdata['parents']['4'] = array('contextid' => $context->id,
'component' => 'mod_data',
'filearea' => 'content',
'itemid' => null,
'filepath' => null,
'filename' => 'Fields');
$testdata['files'] = array();
- $testdata['files']['0'] = array('contextid' => 20,
+ $testdata['files']['0'] = array('contextid' => $context->id,
'component' => 'mod_data',
'filearea' => 'content',
- 'itemid' => '1',
+ 'itemid' => $itemid,
'filepath' => '/',
'filename' => 'Simple4.txt',
- 'url' => 'http://www.example.com/moodle/pluginfile.php/20/mod_data/content/1/Simple4.txt',
+ 'url' => 'http://www.example.com/moodle/pluginfile.php/'.$context->id.'/mod_data/content/'.$itemid.'/Simple4.txt',
'isdir' => false,
'timemodified' => $timemodified);
// Make sure that they are the same.
- $this->assertEquals($testfilelisting, $testdata);
+ $this->assertEquals($testdata, $testfilelisting);
// Try again but without the context. Minus one signals the function to use other variables to obtain the context.
$nocontext = -1;
Please sign in to comment.
Something went wrong with that request. Please try again.