Browse files

Merge branch 'MDL-36646_23' of git://github.com/timhunt/moodle into M…

…OODLE_23_STABLE
  • Loading branch information...
2 parents 254d78b + 877b243 commit 0299d83bc0bc70d965925f957ac543a63d4513c0 @danpoltawski danpoltawski committed Nov 20, 2012
Showing with 15 additions and 12 deletions.
  1. +9 −6 lib/tests/accesslib_test.php
  2. +6 −6 lib/tests/outputcomponents_test.php
View
15 lib/tests/accesslib_test.php
@@ -1686,7 +1686,8 @@ public function test_permission_evaluation() {
context_helper::reset_caches();
context_helper::preload_course($SITE->id);
- $this->assertEquals(7, context_inspection::test_context_cache_size()); // depends on number of default blocks
+ $numfrontpagemodules = $DB->count_records('course_modules', array('course' => $SITE->id));
+ $this->assertEquals(6 + $numfrontpagemodules, context_inspection::test_context_cache_size()); // depends on number of default blocks
// ====== assign_capability(), unassign_capability() ====================
@@ -1991,7 +1992,8 @@ public function test_permission_evaluation() {
load_all_capabilities();
$context = context_course::instance($testcourses[2]);
$page = $DB->get_record('page', array('course'=>$testcourses[2]));
- $pagecontext = context_module::instance($page->id);
+ $pagecm = get_coursemodule_from_instance('page', $page->id);
+ $pagecontext = context_module::instance($pagecm->id);
$context->mark_dirty();
$this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$context->path]));
@@ -2230,7 +2232,8 @@ public function test_permission_evaluation() {
context_helper::reset_caches();
preload_course_contexts($SITE->id);
- $this->assertEquals(context_inspection::test_context_cache_size(), 1);
+ $this->assertEquals(1 + $DB->count_records('course_modules', array('course' => $SITE->id)),
+ context_inspection::test_context_cache_size());
context_helper::reset_caches();
list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSECAT, 'ctx');
@@ -2276,11 +2279,11 @@ public function test_permission_evaluation() {
$url = get_context_url($coursecontext);
$this->assertFalse($url instanceof modole_url);
- $page = $DB->get_record('page', array('id'=>$testpages[7]));
- $context = get_context_instance(CONTEXT_MODULE, $page->id);
+ $pagecm = get_coursemodule_from_instance('page', $testpages[7]);
+ $context = get_context_instance(CONTEXT_MODULE, $pagecm->id);
$coursecontext = get_course_context($context);
$this->assertEquals($coursecontext->contextlevel, CONTEXT_COURSE);
- $this->assertEquals(get_courseid_from_context($context), $page->course);
+ $this->assertEquals(get_courseid_from_context($context), $pagecm->course);
$caps = fetch_context_capabilities($systemcontext);
$this->assertTrue(is_array($caps));
View
12 lib/tests/outputcomponents_test.php
@@ -148,15 +148,15 @@ public function test_get_url() {
// try legacy picture == 1
$user1->picture = 1;
$up1 = new user_picture($user1);
- $this->assertEquals($CFG->wwwroot.'/pluginfile.php/15/user/icon/standard/f2?rev=1', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/standard/f2?rev=1', $up1->get_url($page, $renderer)->out(false));
$user1->picture = 11;
// try valid user with picture when user context is not cached - 1 query expected
context_helper::reset_caches();
$reads = $DB->perf_get_reads();
$up1 = new user_picture($user1);
$this->assertEquals($reads, $DB->perf_get_reads());
- $this->assertEquals($CFG->wwwroot.'/pluginfile.php/15/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertEquals($reads+1, $DB->perf_get_reads());
// try valid user with contextid hint - no queries expected
@@ -165,7 +165,7 @@ public function test_get_url() {
$reads = $DB->perf_get_reads();
$up1 = new user_picture($user1);
$this->assertEquals($reads, $DB->perf_get_reads());
- $this->assertEquals($CFG->wwwroot.'/pluginfile.php/15/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertEquals($reads, $DB->perf_get_reads());
// try valid user without image - no queries expected
@@ -214,13 +214,13 @@ public function test_get_url() {
$this->assertEquals('http://www.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?s=35&d=http%3A%2F%2Fwww.example.com%2Fmoodle%2Fpix%2Fu%2Ff2.png', $up2->get_url($page, $renderer)->out(false));
// uploaded image takes precedence before gravatar
$up1 = new user_picture($user1);
- $this->assertEquals($CFG->wwwroot.'/pluginfile.php/15/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
// https version
$CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
$up1 = new user_picture($user1);
- $this->assertEquals($CFG->httpswwwroot.'/pluginfile.php/15/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->httpswwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$up3 = new user_picture($user3);
$this->assertEquals($CFG->httpswwwroot.'/theme/image.php/standard/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
@@ -258,7 +258,7 @@ public function test_get_url() {
$renderer = $page->get_renderer('core');
$up1 = new user_picture($user1);
- $this->assertEquals($CFG->wwwroot.'/pluginfile.php/15/user/icon/formal_white/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
+ $this->assertEquals($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/formal_white/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$up2 = new user_picture($user2);
$this->assertEquals($CFG->wwwroot.'/theme/image.php/formal_white/core/1/u/f2', $up2->get_url($page, $renderer)->out(false));

0 comments on commit 0299d83

Please sign in to comment.