Skip to content

Commit

Permalink
V3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Dec 13, 2015
1 parent 15d5076 commit 832cc0d
Showing 1 changed file with 69 additions and 21 deletions.
90 changes: 69 additions & 21 deletions tests/courseformatrenderer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ protected function setUp() {
global $PAGE;
$this->outputus = $PAGE->get_renderer('format_topcoll');
// https://docs.moodle.org/dev/Writing_PHPUnit_tests.
$this->course = $this->getDataGenerator()->create_course(array('format' => 'topcoll', 'numsections' => 1), array('createsections' => true));
$this->course = $this->getDataGenerator()->create_course(array('format' => 'topcoll', 'numsections' => 1),
array('createsections' => true));

$this->courseformat = course_get_format($this->course);
format_topcoll_courseformatrenderer_testcase::set_property($this->outputus, 'courseformat', $this->courseformat);
Expand All @@ -100,15 +101,17 @@ protected function setUp() {
}

public function test_start_section_list() {
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'start_section_list', array());
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'start_section_list',
array());
$thevalue = '<ul class="ctopics">';

$this->assertEquals($thevalue, $theclass);
}

public function test_start_toggle_section_list() {
// With defaults unchanged.
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'start_toggle_section_list', array());
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'start_toggle_section_list',
array());
$thevalue = '<ul class="ctopics topics row-fluid">';

$this->assertEquals($thevalue, $theclass);
Expand All @@ -126,33 +129,41 @@ public function test_section_right_content() {
// With defaults unchanged.
$section = $this->courseformat->get_section(1);
$onsectionpage = false;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_right_content', array($section, $this->course, $onsectionpage));
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_right_content',
array($section, $this->course, $onsectionpage));
$thevalue = '<span class="cps_centre">Topic<br />1</span>';
$this->assertEquals($thevalue, $theclass);

$onsectionpage = true;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_right_content', array($section, $this->course, $onsectionpage));
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_right_content',
array($section, $this->course, $onsectionpage));
$thevalue = '<span class="cps_centre">Topic<br />1</span>';
$this->assertEquals($thevalue, $theclass);
}

public function test_section_left_content() {
$section = $this->courseformat->get_section(1);
$onsectionpage = false;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_left_content', array($section, $this->course, $onsectionpage));
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_left_content',
array($section, $this->course, $onsectionpage));
$thevalue = '<span class="cps_centre">1</span>';
$this->assertEquals($thevalue, $theclass);

$onsectionpage = true;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_left_content', array($section, $this->course, $onsectionpage));
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_left_content',
array($section, $this->course, $onsectionpage));
$thevalue = '<span class="cps_centre">1</span>';
$this->assertEquals($thevalue, $theclass);
}

public function test_section_summary() {
$section = $this->courseformat->get_section(1);
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_summary', array($section, $this->course, null));
$thevalue = '<li id="section-1" class="section main section-summary clearfix" role="region" aria-label="Section 1"><div class="left side"></div><div class="right side"></div><div class="content"><h3 class="section-title"><a href="http://www.example.com/moodle/course/view.php?id=171000#section-1" class="">Section 1</a></h3><div class="summarytext"></div></div></li>';
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_summary',
array($section, $this->course, null));
$thevalue = '<li id="section-1" class="section main section-summary clearfix" role="region" aria-label="';
$thevalue .= 'Section 1"><div class="left side"></div><div class="right side"></div><div class="content">';
$thevalue .= '<h3 class="section-title"><a href="http://www.example.com/moodle/course/view.php?id=';
$thevalue .= $this->course->id.'#section-1" class="">Section 1</a></h3><div class="summarytext"></div></div></li>';

$this->assertEquals($thevalue, $theclass);
}
Expand All @@ -162,49 +173,86 @@ public function test_section_header() {
$section->toggle = false;

$onsectionpage = false;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_header', array($section, $this->course, $onsectionpage));
$thevalue = '<li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1"><div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span class="cps_centre">Topic<br />1</span></div><div class="content"><div class="sectionhead toggle toggle-arrow" id="toggle-1"><a class="toggle_closed the_toggle tc-medium" href="http://www.example.com/moodle/course/view.php?id=171000"><h3 class="section-title">Section 1<span class="cttoggle"> - Toggle</span></h3></a></div><div class="sectionbody toggledsection" id="toggledsection-1">';
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_header',
array($section, $this->course, $onsectionpage));
$thevalue = '<li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1">';
$thevalue .= '<div class="left side"><span class="cps_centre">1</span></div><div class="right side">';
$thevalue .= '<span class="cps_centre">Topic<br />1</span></div><div class="content"><div class="sectionhead ';
$thevalue .= 'toggle toggle-arrow" id="toggle-1"><a class="toggle_closed the_toggle tc-medium" href="';
$thevalue .= 'http://www.example.com/moodle/course/view.php?id='.$this->course->id.'"><h3 class="section-title">Section 1';
$thevalue .= '<span class="cttoggle"> - Toggle</span></h3></a></div><div class="sectionbody toggledsection" ';
$thevalue .= 'id="toggledsection-1">';
$this->assertEquals($thevalue, $theclass);

$onsectionpage = true;
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_header', array($section, $this->course, $onsectionpage));
$thevalue = '<li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1"><div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span class="cps_centre">Topic<br />1</span></div><div class="content"><div class="summary"></div>';
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_header',
array($section, $this->course, $onsectionpage));
$thevalue = '<li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1">';
$thevalue .= '<div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span ';
$thevalue .= 'class="cps_centre">Topic<br />1</span></div><div class="content"><div class="summary"></div>';

$this->assertEquals($thevalue, $theclass);
}

public function test_stealth_section_header() {
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'stealth_section_header', array(1));
$thevalue = '<li id="section-1" class="section main clearfix orphaned hidden span12" role="region" aria-label="Section 1"><div class="left side"></div><div class="right side"><span class="cps_centre">Topic<br />1</span></div><div class="content"><h3 class="sectionname">Orphaned activities (section 1)</h3>';
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'stealth_section_header',
array(1));
$thevalue = '<li id="section-1" class="section main clearfix orphaned hidden span12" role="region" aria-label=';
$thevalue .= '"Section 1"><div class="left side"></div><div class="right side"><span class="cps_centre">Topic';
$thevalue .= '<br />1</span></div><div class="content"><h3 class="sectionname">Orphaned activities (section 1)</h3>';

$this->assertEquals($thevalue, $theclass);
}

public function test_section_hidden() {
$section = $this->courseformat->get_section(1);
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_hidden', array($section, null));
$thevalue = '<li id="section-1" class="section main clearfix hidden span12" role="region" aria-label="Section 1"><div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span class="cps_centre">Topic<br />1</span></div><div class="content sectionhidden"><h3 class="section-title">Not available</h3></div></li>';
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'section_hidden',
array($section, null));
$thevalue = '<li id="section-1" class="section main clearfix hidden span12" role="region" aria-label="Section 1">';
$thevalue .= '<div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span class="';
$thevalue .= 'cps_centre">Topic<br />1</span></div><div class="content sectionhidden"><h3 class="section-title">';
$thevalue .= 'Not available</h3></div></li>';

$this->assertEquals($thevalue, $theclass);
}

public function test_print_multiple_section_page() {
format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'print_multiple_section_page', array($this->course, null, null, null, null, null));
$theoutput = '<h2 class="accesshide">Section</h2><ul class="ctopics"></ul><ul class="ctopics topics row-fluid"><li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1"><div class="left side"><span class="cps_centre">1</span></div><div class="right side"><span class="cps_centre">Topic<br />1</span></div><div class="content"><div class="sectionhead toggle toggle-arrow" id="toggle-1"><a class="toggle_closed the_toggle tc-medium" href="http://www.example.com/moodle/course/view.php?id=171000"><h3 class="section-title">Section 1<span class="cttoggle"> - Toggle</span></h3></a></div><div class="sectionbody toggledsection" id="toggledsection-1"><ul class="section img-text"></ul></div></div></li></ul>';
format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'print_multiple_section_page',
array($this->course, null, null, null, null, null));
$theoutput = '<h2 class="accesshide">Section</h2><ul class="ctopics"></ul><ul class="ctopics topics row-fluid">';
$theoutput .= '<li id="section-1" class="section main clearfix span12" role="region" aria-label="Section 1">';
$theoutput .= '<div class="left side"><span class="cps_centre">1</span></div><div class="right side">';
$theoutput .= '<span class="cps_centre">Topic<br />1</span></div><div class="content"><div class="sectionhead ';
$theoutput .= 'toggle toggle-arrow" id="toggle-1"><a class="toggle_closed the_toggle tc-medium" href="';
$theoutput .= 'http://www.example.com/moodle/course/view.php?id='.$this->course->id.'"><h3 class="section-title">Secti';
$theoutput .= 'on 1<span class="cttoggle"> - Toggle</span></h3></a></div><div class="sectionbody toggledsection" ';
$theoutput .= 'id="toggledsection-1"><ul class="section img-text"></ul></div></div></li></ul>';

$this->expectOutputString($theoutput);
}

public function test_toggle_all() {
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'toggle_all', array());
$thevalue = '<li class="tcsection main clearfix" id="toggle-all"><div class="left side"><img width="1" height="1" class="spacer" alt="" src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="right side"><img width="1" height="1" class="spacer" alt="" src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="content"><div class="sectionbody toggle-arrow-hover toggle-arrow"><h4><a class="on tc-medium" href="#" id="toggles-all-opened">Open all</a><a class="off tc-medium" href="#" id="toggles-all-closed">Close all</a></h4></div></div></li>';
$thevalue = '<li class="tcsection main clearfix" id="toggle-all"><div class="left side"><img width="1" height="1" ';
$thevalue .= 'class="spacer" alt="" src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" />';
$thevalue .= '</div><div class="right side"><img width="1" height="1" class="spacer" alt="" src="';
$thevalue .= 'http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="content">';
$thevalue .= '<div class="sectionbody toggle-arrow-hover toggle-arrow"><h4><a class="on tc-medium" href="#" id="';
$thevalue .= 'toggles-all-opened">Open all</a><a class="off tc-medium" href="#" id="toggles-all-closed">Close all</a>';
$thevalue .= '</h4></div></div></li>';

$this->assertEquals($thevalue, $theclass);
}

public function test_display_instructions() {
$theclass = format_topcoll_courseformatrenderer_testcase::call_method($this->outputus, 'display_instructions', array());
$thevalue = '<li class="tcsection main clearfix" id="topcoll-display-instructions"><div class="left side"><img width="1" height="1" class="spacer" alt="" src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="right side"><img width="1" height="1" class="spacer" alt="" src="http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="content"><div class="sectionbody"><p class="topcoll-display-instructions">Instructions: Clicking on the section name will show / hide the section.</p></div></div></li>';
$thevalue = '<li class="tcsection main clearfix" id="topcoll-display-instructions"><div class="left side">';
$thevalue .= '<img width="1" height="1" class="spacer" alt="" src="';
$thevalue .= 'http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="right side">';
$thevalue .= '<img width="1" height="1" class="spacer" alt="" src="';
$thevalue .= 'http://www.example.com/moodle/theme/image.php/_s/clean/core/1/spacer" /></div><div class="content">';
$thevalue .= '<div class="sectionbody"><p class="topcoll-display-instructions">Instructions: Clicking on the section ';
$thevalue .= 'name will show / hide the section.</p></div></div></li>';

$this->assertEquals($thevalue, $theclass);
}
Expand Down

0 comments on commit 832cc0d

Please sign in to comment.