Skip to content

Commit

Permalink
Bug #5, fix phpcs & phpunit tests - Travis-CI [iet:5979684]
Browse files Browse the repository at this point in the history
* Need `section_is_on_course_home_page` options override
  • Loading branch information
nfreear committed Jun 15, 2016
1 parent 38628a4 commit aa80043
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"composer teardown",
"phpunit"
],
"unit": "vendor/bin/phpunit",
"gunzip": [
"file tests/fixtures/backup-moodle2-course-2-lorem2016--nu.mbz",
"# cp -n tests/fixtures/backup-moodle2-course-2-lorem2016--nu.mbz tests/fixtures/backup-moodle2--nu.mbz.gz",
Expand Down
2 changes: 1 addition & 1 deletion lib/Generator/AbbrHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function setAbbreviations($abbr_array, $quote = false)
foreach ($abbr_array as $abbr => $definition) {
$abbr = $quote ? preg_quote($abbr) : $abbr;
$definition = htmlentities($definition);
self::$abbr[] = '/([>\s])' . $abbr . '([,;\.\s<])/';
self::$abbr[] = '/([>\s])' . $abbr . '([,;\?\.\s<])/';
self::$definitions[] = "$1<abbr title='$definition'>$abbr</abbr>$2";
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Generator/StaticPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ protected function assignSection($section, $section_html)
if (isset($this->options[ 'sideblock_section_id' ])
&& $this->options[ 'sideblock_section_id' ] === $section->id) {
$this->sideblock_html = array_merge($this->sideblock_html, $section_html);
}
elseif ($section->is_on_course_home_page) {

} elseif ($section->is_on_course_home_page || $this->options[ 'section_is_on_course_home_page' ]) {
$this->index_html = array_merge($this->index_html, $section_html);
} else {
// Section on a sub-page, or similar!
Expand Down
12 changes: 11 additions & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ class ParserTest extends TestCaseExtended
'title' => 'Is APPLAuD for me?',
];
protected static $generator_options = [
'section_is_on_course_home_page' => true,
'simple_activity_link' => [ ],
'preg_replace_html' => [ ],
'font_icon_map' => [ ],
'treat_as_page' => [ ],
'abbreviations' => [ ],
];
protected static $verbose = false;
protected static $verbose = true; //false;

public function setup()
{
// Arrange
printf("Setup moodle-backup-parser. %s\n", '');
$this->parser = new Parser();
if (self::$verbose) {
//$this->parser->setVerbose();
}
}

public function testInput()
Expand Down Expand Up @@ -97,14 +102,19 @@ public function testStaticPages()
{
// Arrange
$generator = new StaticPages();
if (self::$verbose) {
$generator->setVerbose();
}

$this->parser->parse(TEST_INPUT_DIR);
$activities = $this->parser->getActivities();
$sections = $this->parser->getSections();
$metadata = $this->parser->getMetaData();
$uri_refs = $this->parser->getURIReferences();

$generator->setOptions(self::$generator_options);
$generator->setMetaData($metadata);
$generator->setURIReferences($uri_refs);
$result = $generator->putContents(TEST_OUTPUT_DIR, $activities, $sections);

printf("Handled activities: %s\n", count($activities));
Expand Down

0 comments on commit aa80043

Please sign in to comment.