Skip to content

Commit

Permalink
code checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ewallah committed Sep 22, 2018
1 parent dc9531c commit 52176dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
10 changes: 5 additions & 5 deletions format.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@
} else {
// Render using the masonry js.
$PAGE->requires->js_init_call('M.masonry.init',
array(array(
[[
'node' => '#coursemasonry',
'itemSelector' => '.section.main',
'columnWidth' => 1,
'isRTL' => right_to_left(),
'gutterWidth' => 0
)),
]],
false,
array(
[
'name' => 'course_format_masonry',
'fullpath' => '/course/format/masonry/format.js',
'requires' => array('base', 'node', 'transition', 'event', 'io-base', 'moodle-core-io', 'moodle-core-dock')
)
'requires' => ['base', 'node', 'transition', 'event', 'io-base', 'moodle-core-io', 'moodle-core-dock']
]
);
$renderer = $PAGE->get_renderer('format_masonry');
}
Expand Down
29 changes: 24 additions & 5 deletions tests/format_masonry_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function test_default_course_enddate() {
* Test renderer.
*/
public function test_renderer() {
global $CFG, $USER;
global $CFG, $PAGE, $USER;
$this->resetAfterTest(true);
require_once($CFG->dirroot . '/course/format/masonry/renderer.php');
$this->setAdminUser();
Expand All @@ -213,23 +213,44 @@ public function test_renderer() {
$page->set_course($course);
$page->set_pagelayout('standard');
$page->set_pagetype('course-view');
$page->set_url('/enrol/index.php?id=' . $course->id);
$page->set_url('/course/view.php?id=' . $course->id);
$page->requires->js_init_call('M.masonry.init', [[
'node' => '#coursemasonry', 'itemSelector' => '.section.main', 'columnWidth' => 1, 'isRTL' => right_to_left()]],
false,
['name' => 'course_format_masonry','fullpath' => '/course/format/masonry/format.js',
'requires' => ['base', 'node', 'transition', 'event', 'io-base', 'moodle-core-io', 'moodle-core-dock']]);
$renderer = new \format_masonry_renderer($page, null);
ob_start();
$renderer->print_single_section_page($course, null, null, null, null, 1);
$out1 = ob_get_contents();
$renderer->print_multiple_section_page($course, null, null, null, null, null);
$out2 = ob_get_contents();
ob_end_clean();
$this->assertContains('Topic 1', $out1);
$this->assertContains('Topic 1', $out2);
$modinfo = get_fast_modinfo($course);
$section = $modinfo->get_section_info(1);
$this->assertContains('Topic 1', $renderer->section_title($section, $course));
$section = $modinfo->get_section_info(2);
$this->assertContains('Topic 2', $renderer->section_title_without_link($section, $course));
set_section_visible($course->id, 2, 0);
$USER->editing = true;
$PAGE->set_context(context_course::instance($course->id));
$PAGE->set_pagelayout('standard');
$PAGE->set_pagetype('course-view');
$PAGE->set_url('/course/view.php?id=' . $course->id);
$PAGE->requires->js('/course/format/topics/format.js');
$renderer = $PAGE->get_renderer('format_topics');
ob_start();
$renderer->print_single_section_page($course, null, null, null, null, 2);
$renderer->print_single_section_page($course, null, null, null, null, 0);
$out1 = ob_get_contents();
$renderer->print_multiple_section_page($course, null, null, null, null, null);
$out2 = ob_get_contents();
ob_end_clean();
$this->assertContains(' Add an activity', $out1);
$this->assertContains('Topic 1', $out2);
$course->marker = 2;
course_set_marker($course->id, 2);
}

/**
Expand Down Expand Up @@ -268,14 +289,12 @@ public function test_other() {
$data->bordercolor = '#FFF';
$data->backcolor = '#000';
$format->update_course_format_options($data, $course);

$form = new \MoodleQuickForm_colorpicker();
$form->sethiddenlabel('icon');
$this->assertContains('loading', $form->tohtml());
$form->_generateid();
$form->gethelpbutton();
$form->getelementtemplatetype();
$form->verify(null);

}
}

0 comments on commit 52176dc

Please sign in to comment.