Skip to content

Commit

Permalink
MDL-64506 phpunit: Update unit tests to use classic
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Apr 3, 2019
1 parent c8edee4 commit e00f1c6
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 91 deletions.
2 changes: 1 addition & 1 deletion admin/cli/cfg.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
Stores the given configuration variable in the shell variable, escaped
so that it can be safely used as a shell argument.
# php cfg.php --name=theme --set=clean
# php cfg.php --name=theme --set=classic
Sets the given configuration variable to the given value.
# php cfg.php --name=noemailever --unset
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/templates/cohort-in-list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"visible": true,
"idnumber": "014",
"description": "Some users",
"theme": "clean"
"theme": "classic"
}
}}
{{> tool_lp/form-cohort-selector-suggestion }}
4 changes: 2 additions & 2 deletions admin/tool/uploadcourse/tests/course_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function test_data_saved() {
'idnumber' => 'changeidn',
'summary' => 'Summary 2',
'format' => 'topics',
'theme' => 'clean',
'theme' => 'classic',
'lang' => '',
'newsitems' => '2',
'showgrades' => '1',
Expand Down Expand Up @@ -566,7 +566,7 @@ public function test_default_data_saved() {
'idnumber' => 'changedid',
'summary' => 'Summary 2',
'format' => 'topics',
'theme' => 'clean',
'theme' => 'classic',
'lang' => '',
'newsitems' => '2',
'showgrades' => '1',
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/usertours/tests/theme_filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public function filter_matches_provider() {
true,
],
'Multiple values set including matching; Matches' => [
['boost', 'clean'],
['boost', 'classic'],
'boost',
true,
],
'Single value set; No match' => [
['clean'],
['classic'],
'boost',
false,
],
'Multiple values set; No match' => [
['clean', 'artificial'],
['classic', 'artificial'],
'boost',
false,
],
Expand Down
14 changes: 7 additions & 7 deletions cohort/tests/behat/upload_cohorts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ Feature: A privileged user can create cohorts using a CSV file
And I upload "cohort/tests/fixtures/uploadcohorts4.csv" file to "File" filemanager
And I click on "Preview" "button"
Then the following should exist in the "previewuploadedcohorts" table:
| name | idnumber | description | Context | visible | theme | Status |
| cohort name 1 | cohortid1 | first description | System | 1 | boost | |
| cohort name 2 | cohortid2 | | System | 1 | | |
| cohort name 3 | cohortid3 | | Miscellaneous | 0 | boost | |
| cohort name 4 | cohortid4 | | Cat 1 | 1 | clean | |
| cohort name 5 | cohortid5 | | Cat 2 | 0 | | |
| cohort name 6 | cohortid6 | | Cat 3 | 1 | clean | |
| name | idnumber | description | Context | visible | theme | Status |
| cohort name 1 | cohortid1 | first description | System | 1 | boost | |
| cohort name 2 | cohortid2 | | System | 1 | | |
| cohort name 3 | cohortid3 | | Miscellaneous | 0 | boost | |
| cohort name 4 | cohortid4 | | Cat 1 | 1 | classic | |
| cohort name 5 | cohortid5 | | Cat 2 | 0 | | |
| cohort name 6 | cohortid6 | | Cat 3 | 1 | classic | |
And I press "Upload cohorts"
And I should see "Uploaded 6 cohorts"
And I press "Continue"
Expand Down
10 changes: 5 additions & 5 deletions cohort/tests/cohortlib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public function test_cohort_add_theme_cohort() {

$systemctx = context_system::instance();
$cohort1 = $this->getDataGenerator()->create_cohort(array('contextid' => $systemctx->id, 'name' => 'test cohort 1',
'idnumber' => 'testid1', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'clean'));
'idnumber' => 'testid1', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'classic'));

$id = cohort_add_cohort($cohort1);
$this->assertNotEmpty($id);
Expand All @@ -690,7 +690,7 @@ public function test_cohort_add_theme_cohort() {
set_config('allowcohortthemes', 0);

$cohort2 = $this->getDataGenerator()->create_cohort(array('contextid' => $systemctx->id, 'name' => 'test cohort 2',
'idnumber' => 'testid2', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'clean'));
'idnumber' => 'testid2', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'classic'));

$id = cohort_add_cohort($cohort2);
$this->assertNotEmpty($id);
Expand All @@ -713,14 +713,14 @@ public function test_cohort_update_theme_cohort() {

$systemctx = context_system::instance();
$cohort1 = $this->getDataGenerator()->create_cohort(array('contextid' => $systemctx->id, 'name' => 'test cohort 1',
'idnumber' => 'testid1', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'clean'));
'idnumber' => 'testid1', 'description' => 'test cohort desc', 'descriptionformat' => FORMAT_HTML, 'theme' => 'classic'));
$id = cohort_add_cohort($cohort1);
$this->assertNotEmpty($id);

// Theme is updated when allowcohortthemes is enabled.
$cohort1 = $DB->get_record('cohort', array('id' => $id));
$cohort1->name = 'test cohort 1 updated';
$cohort1->theme = 'more';
$cohort1->theme = 'classic';
cohort_update_cohort($cohort1);
$updatedcohort = $DB->get_record('cohort', array('id' => $id));
$this->assertEquals($cohort1->contextid, $updatedcohort->contextid);
Expand All @@ -732,7 +732,7 @@ public function test_cohort_update_theme_cohort() {
// Theme is not updated neither overwritten when allowcohortthemes is disabled.
set_config('allowcohortthemes', 0);
$cohort2 = $DB->get_record('cohort', array('id' => $id));
$cohort2->theme = 'clean';
$cohort2->theme = 'classic';
cohort_update_cohort($cohort2);
$updatedcohort = $DB->get_record('cohort', array('id' => $id));
$this->assertEquals($cohort2->contextid, $updatedcohort->contextid);
Expand Down
16 changes: 8 additions & 8 deletions cohort/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function test_create_cohorts() {
'name' => 'cohort test 1',
'idnumber' => 'cohorttest1',
'description' => 'This is a description for cohorttest1',
'theme' => 'clean'
'theme' => 'classic'
);

$cohort2 = array(
Expand All @@ -76,7 +76,7 @@ public function test_create_cohorts() {
'name' => 'cohort test 4',
'idnumber' => 'cohorttest4',
'description' => 'This is a description for cohorttest4',
'theme' => 'clean'
'theme' => 'classic'
);

// Call the external function.
Expand Down Expand Up @@ -182,7 +182,7 @@ public function test_get_cohorts() {
'name' => 'cohortnametest1',
'idnumber' => 'idnumbertest1',
'description' => 'This is a description for cohort 1',
'theme' => 'clean'
'theme' => 'classic'
);
$cohort1 = self::getDataGenerator()->create_cohort($cohort1);
$cohort2 = self::getDataGenerator()->create_cohort();
Expand Down Expand Up @@ -250,7 +250,7 @@ public function test_update_cohorts() {
'name' => 'cohortnametest1',
'idnumber' => 'idnumbertest1',
'description' => 'This is a description for cohort 1',
'theme' => 'clean'
'theme' => 'classic'
);

$context = context_system::instance();
Expand Down Expand Up @@ -279,15 +279,15 @@ public function test_update_cohorts() {

// Call when $CFG->allowcohortthemes is enabled.
set_config('allowcohortthemes', 1);
core_cohort_external::update_cohorts(array($cohort1 + array('theme' => 'clean')));
core_cohort_external::update_cohorts(array($cohort1 + array('theme' => 'classic')));
$dbcohort = $DB->get_record('cohort', array('id' => $cohort1['id']));
$this->assertEquals('clean', $dbcohort->theme);
$this->assertEquals('classic', $dbcohort->theme);

// Call when $CFG->allowcohortthemes is disabled.
set_config('allowcohortthemes', 0);
core_cohort_external::update_cohorts(array($cohort1 + array('theme' => 'more')));
core_cohort_external::update_cohorts(array($cohort1 + array('theme' => 'boost')));
$dbcohort = $DB->get_record('cohort', array('id' => $cohort1['id']));
$this->assertEquals('clean', $dbcohort->theme);
$this->assertEquals('classic', $dbcohort->theme);

// Call without required capability.
$this->unassignUserCapability('moodle/cohort:manage', $context->id, $roleid);
Expand Down
4 changes: 2 additions & 2 deletions cohort/tests/fixtures/uploadcohorts4.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name,idnumber,description,category,visible,theme
cohort name 1,cohortid1,first description,,,boost
cohort name 2,cohortid2,,,,
cohort name 3,cohortid3,,Miscellaneous,no,boost
cohort name 4,cohortid4,,CAT1,yes,clean
cohort name 4,cohortid4,,CAT1,yes,classic
cohort name 5,cohortid5,,CAT2,0,
cohort name 6,cohortid6,,CAT3,1,clean
cohort name 6,cohortid6,,CAT3,1,classic
6 changes: 3 additions & 3 deletions course/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function test_create_categories() {
$category2->name = 'Root Test Category 2';
$category2->idnumber = 'rootcattest2';
$category2->desc = 'Description for root test category 1';
$category2->theme = 'bootstrapbase';
$category2->theme = 'classic';
$categories = array(
array('name' => $category1->name, 'parent' => 0),
array('name' => $category2->name, 'parent' => 0, 'idnumber' => $category2->idnumber,
Expand Down Expand Up @@ -451,7 +451,7 @@ public function test_create_courses() {
$course2['enablecompletion'] = 1;
$course2['completionnotify'] = 1;
$course2['lang'] = 'en';
$course2['forcetheme'] = 'bootstrapbase';
$course2['forcetheme'] = 'classic';
$course2['courseformatoptions'][] = array('name' => 'automaticenddate', 'value' => 0);
$course3['fullname'] = 'Test course 3';
$course3['shortname'] = 'Testcourse3';
Expand Down Expand Up @@ -1438,7 +1438,7 @@ public function test_update_courses() {
$course2['defaultgroupingid'] = 0;
$course2['enablecompletion'] = 1;
$course2['lang'] = 'en';
$course2['forcetheme'] = 'bootstrapbase';
$course2['forcetheme'] = 'classic';

$course3['id'] = $originalcourse3->id;
$updatedcustomfieldvalue = ['shortname' => 'test', 'value' => 'Updated test value'];
Expand Down
9 changes: 5 additions & 4 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1654,9 +1654,10 @@ public static function is_deleted_standard_plugin($type, $name) {
'repository' => array('alfresco'),
'tinymce' => array('dragmath'),
'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport', 'assignmentupgrade'),
'theme' => array('afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'boxxie', 'brick', 'canvas',
'formal_white', 'formfactor', 'fusion', 'leatherbound', 'magazine', 'mymobile', 'nimble', 'nonzero',
'overlay', 'serenity', 'sky_high', 'splash', 'standard', 'standardold'),
'theme' => array('bootstrapbase', 'clean', 'more', 'afterburner', 'anomaly', 'arialist', 'base',
'binarius', 'boxxie', 'brick', 'canvas', 'formal_white', 'formfactor', 'fusion', 'leatherbound',
'magazine', 'mymobile', 'nimble', 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash',
'standard', 'standardold'),
'webservice' => array('amf'),
);

Expand Down Expand Up @@ -1905,7 +1906,7 @@ public static function standard_plugins_list($type) {
),

'theme' => array(
'boost', 'classic', 'bootstrapbase', 'clean', 'more'
'boost', 'classic'
),

'tool' => array(
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/plugininfo/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class theme extends base {
public function is_uninstall_allowed() {
global $CFG;

if ($this->name === 'bootstrapbase') {
if ($this->name === 'boost') {
// All of these are protected for now.
return false;
}
Expand Down
6 changes: 1 addition & 5 deletions lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,7 @@ private function __construct($config) {
$this->name = $config->name;
$this->dir = $config->dir;

if ($this->name != 'bootstrapbase') {
$baseconfig = theme_config::find_theme_config('bootstrapbase', $this->settings);
} else {
$baseconfig = $config;
}
$baseconfig = $config;

$configurable = array(
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'usefallback',
Expand Down
10 changes: 5 additions & 5 deletions lib/tests/admintree_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@ public function test_admin_setting_configexecutable() {
global $CFG;
$this->resetAfterTest();

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

// Check for an invalid path.
$result = $executable->output_html($CFG->dirroot . '/lib/tests/other/file_does_not_exist');
$this->assertRegexp('/class="patherror"/', $result);
$this->assertRegexp('/class="text-danger"/', $result);

// Check for a directory.
$result = $executable->output_html($CFG->dirroot);
$this->assertRegexp('/class="patherror"/', $result);
$this->assertRegexp('/class="text-danger"/', $result);

// Check for a file which is not executable.
$result = $executable->output_html($CFG->dirroot . '/filter/tex/readme_moodle.txt');
$this->assertRegexp('/class="patherror"/', $result);
$this->assertRegexp('/class="text-danger"/', $result);

// Check for an executable file.
if ($CFG->ostype == 'WINDOWS') {
Expand All @@ -177,7 +177,7 @@ public function test_admin_setting_configexecutable() {
$filetocheck = 'mimetex.darwin';
}
$result = $executable->output_html($CFG->dirroot . '/filter/tex/' . $filetocheck);
$this->assertRegexp('/class="pathok"/', $result);
$this->assertRegexp('/class="text-success"/', $result);

// Check for no file specified.
$result = $executable->output_html('');
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/blocklib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public function test_create_all_block_instances() {

$PAGE->reset_theme_and_output();
// Change to a theme with undeletable blocks.
$CFG->theme = 'clean';
$CFG->theme = 'classic';

list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname),
$context, 'page-type');
Expand Down
13 changes: 5 additions & 8 deletions lib/tests/formslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,23 +558,23 @@ public function test_multiple_modgrade_fields() {
global $CFG;
$this->resetAfterTest(true);

$CFG->theme = 'clean';
$CFG->theme = 'classic';
$form = new formslib_multiple_modgrade_form();
ob_start();
$form->display();
$html = ob_get_clean();

$this->assertTag(array('id' => 'fgroup_id_grade1'), $html);
$this->assertTag(array('id' => 'fitem_fgroup_id_grade1'), $html);
$this->assertTag(array('id' => 'id_grade1_modgrade_type'), $html);
$this->assertTag(array('id' => 'id_grade1_modgrade_point'), $html);
$this->assertTag(array('id' => 'id_grade1_modgrade_scale'), $html);

$this->assertTag(array('id' => 'fgroup_id_grade2'), $html);
$this->assertTag(array('id' => 'fitem_fgroup_id_grade2'), $html);
$this->assertTag(array('id' => 'id_grade2_modgrade_type'), $html);
$this->assertTag(array('id' => 'id_grade2_modgrade_point'), $html);
$this->assertTag(array('id' => 'id_grade2_modgrade_scale'), $html);

$this->assertTag(array('id' => 'fgroup_id_grade_3'), $html);
$this->assertTag(array('id' => 'fitem_fgroup_id_grade_3'), $html);
$this->assertTag(array('id' => 'id_grade_3_modgrade_type'), $html);
$this->assertTag(array('id' => 'id_grade_3_modgrade_point'), $html);
$this->assertTag(array('id' => 'id_grade_3_modgrade_scale'), $html);
Expand All @@ -586,7 +586,7 @@ public function test_multiple_modgrade_fields() {
public function test_persistantrreeze_element() {
global $CFG;
$this->resetAfterTest(true);
$CFG->theme = 'clean';
$CFG->theme = 'classic';

$form = new formslib_persistantrreeze_element();
ob_start();
Expand All @@ -595,15 +595,12 @@ public function test_persistantrreeze_element() {

// Test advcheckbox id's.
$this->assertTag(array('id' => 'id_advcheckboxpersistant'), $html);
$this->assertTag(array('id' => 'id_advcheckboxpersistant_persistant'), $html);
$this->assertTag(array('id' => 'id_advcheckboxnotpersistant'), $html);
$this->assertNotTag(array('id' => 'id_advcheckboxnotpersistant_persistant'), $html);
$this->assertTag(array('id' => 'id_advcheckboxfrozen'), $html);
$this->assertTag(array('id' => 'id_advcheckboxfrozen_persistant'), $html);

// Check text element id's.
$this->assertTag(array('id' => 'id_textpersistant'), $html);
$this->assertTag(array('id' => 'id_textpersistant_persistant'), $html);
$this->assertTag(array('id' => 'id_textnotpersistant'), $html);
$this->assertNotTag(array('id' => 'id_textnotpersistant_persistant'), $html);
$this->assertTag(array('id' => 'id_textfrozen'), $html);
Expand Down
Loading

0 comments on commit e00f1c6

Please sign in to comment.