public function test_book_printed() { // There is no proper API to call to test the event, so what we are // doing here is simply making sure that the events returns the right information. $course = $this->getDataGenerator()->create_course(); $book = $this->getDataGenerator()->create_module('book', array('course' => $course->id)); $context = context_module::instance($book->cmid); $event = \booktool_print\event\book_printed::create_from_book($book, $context); // Triggering and capturing the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $this->assertCount(1, $events); $event = reset($events); // Checking that the event contains the expected values. $this->assertInstanceOf('\\booktool_print\\event\\book_printed', $event); $this->assertEquals(context_module::instance($book->cmid), $event->get_context()); $this->assertEquals($book->id, $event->objectid); $expected = array($course->id, 'book', 'print', 'tool/print/index.php?id=' . $book->cmid, $book->id, $book->cmid); $this->assertEventLegacyLogData($expected, $event); $this->assertEventContextNotUsed($event); }
if (!$chapter->subchapter) { $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); echo $OUTPUT->heading($currtitle); } else { $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context); $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context); echo $OUTPUT->heading($currtitle); echo $OUTPUT->heading($currsubtitle, 3); } } $chaptertext = file_rewrite_pluginfile_urls($chapter->content, 'pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id); echo format_text($chaptertext, $chapter->contentformat, array('noclean' => true, 'context' => $context)); echo '</div>'; echo '</body> </html>'; } else { \booktool_print\event\book_printed::create_from_book($book, $context)->trigger(); $allchapters = $DB->get_records('book_chapters', array('bookid' => $book->id), 'pagenum'); $book->intro = file_rewrite_pluginfile_urls($book->intro, 'pluginfile.php', $context->id, 'mod_book', 'intro', null); // page header ?> <!DOCTYPE HTML> <html> <head> <title><?php echo format_string($book->name, true, array('context' => $context)); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="<?php echo s(format_string($book->name, true, array('noclean' => true, 'context' => $context))); ?>