public function test_add_comment()
 {
     global $DB;
     $user = get_admin();
     $wall1 = wall::instance_by_location(context_system::instance(), 'core', 'test', 1);
     $wall2 = wall::instance_by_location(context_system::instance(), 'core', 'test', 2);
     $id11 = $wall1->add_comment('Wall 1 - 1st comment', FORMAT_MOODLE, $user);
     $id12 = $wall1->add_comment('Wall 1 - 2nd comment', FORMAT_MOODLE, $user);
     $id21 = $wall2->add_comment('Wall 2 - 1st comment', FORMAT_MOODLE, $user);
     $id13 = $wall1->add_comment('Wall 1 - 3rd comment', FORMAT_MOODLE, $user);
     $id22 = $wall2->add_comment('Wall 2 - 2nd comment', FORMAT_MOODLE, $user);
     $this->assertEquals(1, $DB->get_field('local_libwall_comments', 'seqnum', array('id' => $id11), MUST_EXIST));
     $this->assertEquals(2, $DB->get_field('local_libwall_comments', 'seqnum', array('id' => $id12), MUST_EXIST));
     $this->assertEquals(1, $DB->get_field('local_libwall_comments', 'seqnum', array('id' => $id21), MUST_EXIST));
     $this->assertEquals(3, $DB->get_field('local_libwall_comments', 'seqnum', array('id' => $id13), MUST_EXIST));
     $this->assertEquals(2, $DB->get_field('local_libwall_comments', 'seqnum', array('id' => $id22), MUST_EXIST));
 }
示例#2
0
 * @package     local_libwall
 * @copyright   2015 David Mudrak <*****@*****.**>
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require __DIR__ . '/../../config.php';
require_login();
if (!is_siteadmin()) {
    die('Site admins allowed only');
}
$plugin = new stdClass();
include __DIR__ . '/version.php';
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/local/libwall/demo.php');
$wall0 = \local_libwall\wall::instance_by_location(context_system::instance(), 'local_libwall', 'demo', 0);
$wall0->load_comments();
$wall1 = \local_libwall\wall::instance_by_location(context_system::instance(), 'local_libwall', 'demo', 1);
$wall1->load_comments();
$output = $PAGE->get_renderer('local_libwall');
echo $output->header();
echo $output->heading('Comments wall demo / libwall ' . $plugin->release . ' (build: ' . $plugin->version . ')');
echo '<div class="row-fluid">';
echo '<div class="span4">';
echo $output->heading('Wall demo/0', 3);
echo $output->render($wall0);
echo '</div>';
echo '<div class="span4">';
echo $output->heading('Wall demo/0 again', 3);
echo $output->render($wall0);
echo '</div>';
echo '<div class="span4">';
echo $output->heading('Wall demo/1', 3);