Skip to content

Commit

Permalink
MDL-56006 theme: Set Boost as the default theme
Browse files Browse the repository at this point in the history
Units tests have been adjusted e.g. 'boost' instead of 'clean' in pix urls.

Some places I didn't update the test to reflect the boost markup and reset
the theme to clean. This is because the test was not testing the markup - but the
functionality (e.g. looking for specific structures to indicate an error in a form element).
  • Loading branch information
Damyon Wiese committed Oct 25, 2016
1 parent 6858c7a commit e56b58e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions enrol/lti/tests/helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function test_update_user_profile_image() {

// Get the user's profile picture and make sure it is correct.
$userpicture = new user_picture($this->user1);
$this->assertSame($CFG->wwwroot . '/pluginfile.php/' . $usercontext->id . '/user/icon/clean/f2?rev=' .$this->user1->picture,
$this->assertSame($CFG->wwwroot . '/pluginfile.php/' . $usercontext->id . '/user/icon/boost/f2?rev=' .$this->user1->picture,
$userpicture->get_url($page, $renderer)->out(false));
}

Expand Down Expand Up @@ -533,7 +533,7 @@ public function test_create_cartridge() {

$cartridge = \enrol_lti\helper::create_cartridge($tool1->id);
$this->assertContains('<blti:title>Test LTI</blti:title>', $cartridge);
$this->assertContains("<blti:icon>$CFG->wwwroot/theme/image.php/_s/clean/theme/1/favicon</blti:icon>", $cartridge);
$this->assertContains("<blti:icon>$CFG->wwwroot/theme/image.php/_s/boost/theme/1/favicon</blti:icon>", $cartridge);
$this->assertContains("<blti:launch_url>$CFG->wwwroot/enrol/lti/tool.php?id=$tool1->id</blti:launch_url>", $cartridge);
}
}
2 changes: 1 addition & 1 deletion filter/emoticon/tests/filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function test_filter_emoticon_formats() {

// And texts matching target formats are filtered.
$expected = '<img class="emoticon" alt="angry" title="angry"'.
' src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/s/angry" />';
' src="http://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/angry" />';
$options = array('originalformat' => FORMAT_HTML); // Only FORMAT_HTML is filtered, see {@link testable_filter_emoticon}.
$this->assertEquals($expected, $filter->filter('(grr)', $options));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class theme_config {
/**
* @var string Default theme, used when requested theme not found.
*/
const DEFAULT_THEME = 'clean';
const DEFAULT_THEME = 'boost';

/**
* @var array You can base your theme on other themes by linking to the other theme as
Expand Down
2 changes: 1 addition & 1 deletion lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@

// Ensure a valid theme is set.
if (!isset($CFG->theme)) {
$CFG->theme = 'clean';
$CFG->theme = 'boost';
}

// Set language/locale of printed times. If user has chosen a language that
Expand Down
1 change: 1 addition & 0 deletions lib/tests/admintree_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function test_admin_setting_configexecutable() {
global $CFG;
$this->resetAfterTest();

$CFG->theme = 'clean';
$executable = new admin_setting_configexecutable('test1', 'Text 1', 'Help Path', '');

// Check for an invalid path.
Expand Down
6 changes: 5 additions & 1 deletion lib/tests/formslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,10 @@ public function test_type_cleaning() {
* MDL-52873
*/
public function test_multiple_modgrade_fields() {
global $CFG;
$this->resetAfterTest(true);

$CFG->theme = 'clean';
$form = new formslib_multiple_modgrade_form();
ob_start();
$form->display();
Expand All @@ -582,7 +584,9 @@ public function test_multiple_modgrade_fields() {
* Test persistant freeze elements have different id's.
*/
public function test_persistantrreeze_element() {
global $CFG;
$this->resetAfterTest(true);
$CFG->theme = 'clean';

$form = new formslib_persistantrreeze_element();
ob_start();
Expand Down Expand Up @@ -928,4 +932,4 @@ public function definition() {
$mform->addElement('text', 'textnotpersistant', 'test', 'test');
$mform->setType('textnotpersistant', PARAM_TEXT);
}
}
}
22 changes: 11 additions & 11 deletions lib/tests/outputcomponents_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function test_get_url() {
$CFG->svgicons = true;

// Verify new install contains expected defaults.
$this->assertSame('clean', $CFG->theme);
$this->assertSame(theme_config::DEFAULT_THEME, $CFG->theme);
$this->assertEquals(1, $CFG->slasharguments);
$this->assertEquals(1, $CFG->themerev);
$this->assertEquals(0, $CFG->themedesignermode);
Expand Down Expand Up @@ -150,15 +150,15 @@ public function test_get_url() {
// Try legacy picture == 1.
$user1->picture = 1;
$up1 = new user_picture($user1);
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/clean/f2?rev=1', $up1->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/boost/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->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/clean/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/boost/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.
Expand All @@ -167,15 +167,15 @@ public function test_get_url() {
$reads = $DB->perf_get_reads();
$up1 = new user_picture($user1);
$this->assertEquals($reads, $DB->perf_get_reads());
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/clean/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/boost/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.
context_helper::reset_caches();
$reads = $DB->perf_get_reads();
$up2 = new user_picture($user2);
$this->assertEquals($reads, $DB->perf_get_reads());
$this->assertSame($CFG->wwwroot.'/theme/image.php/clean/core/1/u/f2', $up2->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/theme/image.php/boost/core/1/u/f2', $up2->get_url($page, $renderer)->out(false));
$this->assertEquals($reads, $DB->perf_get_reads());

// Try guessing of deleted users - no queries expected.
Expand All @@ -184,7 +184,7 @@ public function test_get_url() {
$reads = $DB->perf_get_reads();
$up3 = new user_picture($user3);
$this->assertEquals($reads, $DB->perf_get_reads());
$this->assertSame($CFG->wwwroot.'/theme/image.php/clean/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/theme/image.php/boost/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertEquals($reads, $DB->perf_get_reads());

// Try incorrectly deleted users (with valid email and pciture flag) - some DB reads expected.
Expand All @@ -193,7 +193,7 @@ public function test_get_url() {
$reads = $DB->perf_get_reads();
$up3 = new user_picture($user3);
$this->assertEquals($reads, $DB->perf_get_reads());
$this->assertSame($CFG->wwwroot.'/theme/image.php/clean/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/theme/image.php/boost/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertGreaterThan($reads, $DB->perf_get_reads());

// Test gravatar.
Expand All @@ -203,7 +203,7 @@ public function test_get_url() {
$user3->email = 'deleted';
$user3->picture = 0;
$up3 = new user_picture($user3);
$this->assertSame($CFG->wwwroot.'/theme/image.php/clean/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/theme/image.php/boost/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));

// Verify defaults to misteryman (mm).
$up2 = new user_picture($user2);
Expand All @@ -215,16 +215,16 @@ public function test_get_url() {
$this->assertSame('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->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/clean/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->wwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/boost/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->assertSame($CFG->httpswwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/clean/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->httpswwwroot.'/pluginfile.php/'.$context1->id.'/user/icon/boost/f2?rev=11', $up1->get_url($page, $renderer)->out(false));

$up3 = new user_picture($user3);
$this->assertSame($CFG->httpswwwroot.'/theme/image.php/clean/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
$this->assertSame($CFG->httpswwwroot.'/theme/image.php/boost/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));

$up2 = new user_picture($user2);
$this->assertSame('https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?s=35&d=https%3A%2F%2Fwww.example.com%2Fmoodle%2Fpix%2Fu%2Ff2.png', $up2->get_url($page, $renderer)->out(false));
Expand Down
1 change: 1 addition & 0 deletions lib/tests/user_menu_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function test_custom_user_menu($data, $entrycount, $dividercount) {
// Test using an admin user at the root of Moodle; this way we don't have to create a test user with avatar.
$this->setAdminUser();
$PAGE->set_url('/');
$CFG->theme = 'clean';

// Set the configuration.
set_config('customusermenuitems', $data);
Expand Down

0 comments on commit e56b58e

Please sign in to comment.