first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,39 @@
@block @block_html @core_block
Feature: Adding and configuring Text blocks
In order to have custom blocks on a page
As admin
I need to be able to create, configure and change Text blocks
@javascript
Scenario: Configuring the Text block with Javascript on
Given I log in as "admin"
And I am on site homepage
When I turn editing mode on
And I add the "Text" block to the default region with:
| Text block title | |
| Content | Static text without a header |
Then I should not see "(new text block)"
And I configure the "block_html" block
And I set the field "Text block title" to "The Text block header"
And I set the field "Content" to "Static text with a header"
And I press "Save changes"
And "block_html" "block" should exist
And "The Text block header" "block" should exist
And I should see "Static text with a header" in the "The Text block header" "block"
Scenario: Configuring the Text block with Javascript off
Given I log in as "admin"
And I am on site homepage
When I turn editing mode on
And I add the "Text" block
And I configure the "(new text block)" block
And I set the field "Content" to "Static text without a header"
And I press "Save changes"
Then I should not see "(new text block)"
And I configure the "block_html" block
And I set the field "Text block title" to "The Text block header"
And I set the field "Content" to "Static text with a header"
And I press "Save changes"
And "block_html" "block" should exist
And "The Text block header" "block" should exist
And I should see "Static text with a header" in the "The Text block header" "block"
@@ -0,0 +1,35 @@
@block @block_html
Feature: Text blocks in a course
In order to have one or multiple Text blocks in a course
As a teacher
I need to be able to create and change such blocks
Scenario: Adding Text block in a course
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Terry1 | Teacher1 | teacher@example.com |
| student1 | Sam1 | Student1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Text" block
And I configure the "(new text block)" block
And I set the field "Content" to "First block content"
And I set the field "Text block title" to "First block header"
And I press "Save changes"
And I add the "Text" block
And I configure the "(new text block)" block
And I set the field "Content" to "Second block content"
And I set the field "Text block title" to "Second block header"
And I press "Save changes"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I should see "First block content" in the "First block header" "block"
And I should see "Second block content" in the "Second block header" "block"
@@ -0,0 +1,42 @@
@block @block_html
Feature: Adding and configuring multiple Text blocks
In order to have one or multiple Text blocks on a page
As admin
I need to be able to create, configure and change Text blocks
Background:
Given I log in as "admin"
And I am on site homepage
When I turn editing mode on
And I add the "Text" block
Scenario: Other users can not see Text block that has not been configured
Then "(new text block)" "block" should exist
And I log out
And "(new text block)" "block" should not exist
And "block_html" "block" should not exist
Scenario: Other users can see Text block that has been configured even when it has no header
And I configure the "(new text block)" block
And I set the field "Content" to "Static text without a header"
And I press "Save changes"
Then I should not see "(new text block)"
And I log out
And I am on homepage
And "block_html" "block" should exist
And I should see "Static text without a header" in the "block_html" "block"
And I should not see "(new text block)"
Scenario: Adding multiple instances of Text block on a page
And I configure the "block_html" block
And I set the field "Text block title" to "The Text block header"
And I set the field "Content" to "Static text with a header"
And I press "Save changes"
And I add the "Text" block
And I configure the "(new text block)" block
And I set the field "Text block title" to "The second Text block header"
And I set the field "Content" to "Second block contents"
And I press "Save changes"
And I log out
Then I should see "Static text with a header" in the "The Text block header" "block"
And I should see "Second block contents" in the "The second Text block header" "block"
+96
View File
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace block_html;
/**
* Unit test for block_html class.
*
* @package block_html
* @copyright 2022 Open LMS (https://www.openlms.net/)
* @author Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @coversDefaultClass \block_html
*/
class block_html_test extends \advanced_testcase {
/**
* Tests instance files copying.
* @covers ::instance_copy
*/
public function test_instance_copy(): void {
global $USER;
$this->resetAfterTest();
$this->setAdminUser();
$fs = get_file_storage();
$course = $this->getDataGenerator()->create_course();
$block1 = $this->create_block($course);
$itemid = file_get_unused_draft_itemid();
$fs = get_file_storage();
$usercontext = \context_user::instance($USER->id);
$fs->create_file_from_string(['component' => 'user', 'filearea' => 'draft',
'contextid' => $usercontext->id, 'itemid' => $itemid, 'filepath' => '/',
'filename' => 'file.txt'], 'File content');
$data = (object)['title' => 'Block title', 'text' => ['text' => 'Block text',
'itemid' => $itemid, 'format' => FORMAT_HTML]];
$block1->instance_config_save($data);
$this->assertTrue($fs->file_exists($block1->context->id, 'block_html', 'content', 0, '/', 'file.txt'));
$block2 = $this->create_block($course);
$this->assertFalse($fs->file_exists($block2->context->id, 'block_html', 'content', 0, '/', 'file.txt'));
$this->setUser(null);
$block2->instance_copy($block1->instance->id);
$this->assertTrue($fs->file_exists($block2->context->id, 'block_html', 'content', 0, '/', 'file.txt'));
}
/**
* Constructs a page object for the test course.
*
* @param \stdClass $course Moodle course object
* @return \moodle_page Page object representing course view
*/
protected static function construct_page($course): \moodle_page {
$context = \context_course::instance($course->id);
$page = new \moodle_page();
$page->set_context($context);
$page->set_course($course);
$page->set_pagelayout('standard');
$page->set_pagetype('course-view');
$page->blocks->load_blocks();
return $page;
}
/**
* Creates an HTML block on a course.
*
* @param \stdClass $course Course object
* @return \block_html Block instance object
*/
protected function create_block($course): \block_html {
$page = self::construct_page($course);
$page->blocks->add_block_at_end_of_default_region('html');
// Load the block.
$page = self::construct_page($course);
$page->blocks->load_blocks();
$blocks = $page->blocks->get_blocks_for_region($page->blocks->get_default_region());
$block = end($blocks);
return $block;
}
}
+440
View File
@@ -0,0 +1,440 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the block_html implementation of the privacy API.
*
* @package block_html
* @category test
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_html\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\request\writer;
use core_privacy\local\request\approved_contextlist;
use core_privacy\local\request\approved_userlist;
use block_html\privacy\provider;
/**
* Unit tests for the block_html implementation of the privacy API.
*
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider_test extends \core_privacy\tests\provider_testcase {
/**
* Get the list of standard format options for comparison.
*
* @return \stdClass
*/
protected function get_format_options() {
return (object) [
'overflowdiv' => true,
'noclean' => true,
];
}
/**
* Creates an HTML block on a user.
*
* @param string $title
* @param string $body
* @param string $format
* @return \block_instance
*/
protected function create_user_block($title, $body, $format) {
global $USER;
$configdata = (object) [
'title' => $title,
'text' => [
'itemid' => 19,
'text' => $body,
'format' => $format,
],
];
$this->create_block($this->construct_user_page($USER));
$block = $this->get_last_block_on_page($this->construct_user_page($USER));
$block = block_instance('html', $block->instance);
$block->instance_config_save((object) $configdata);
return $block;
}
/**
* Creates an HTML block on a course.
*
* @param \stdClass $course
* @param string $title
* @param string $body
* @param string $format
* @return \block_instance
*/
protected function create_course_block($course, $title, $body, $format) {
global $USER;
$configdata = (object) [
'title' => $title,
'text' => [
'itemid' => 19,
'text' => $body,
'format' => $format,
],
];
$this->create_block($this->construct_course_page($course));
$block = $this->get_last_block_on_page($this->construct_course_page($course));
$block = block_instance('html', $block->instance);
$block->instance_config_save((object) $configdata);
return $block;
}
/**
* Creates an HTML block on a page.
*
* @param \page $page Page
*/
protected function create_block($page) {
$page->blocks->add_block_at_end_of_default_region('html');
}
/**
* Get the last block on the page.
*
* @param \page $page Page
* @return \block_html Block instance object
*/
protected function get_last_block_on_page($page) {
$blocks = $page->blocks->get_blocks_for_region($page->blocks->get_default_region());
$block = end($blocks);
return $block;
}
/**
* Constructs a Page object for the User Dashboard.
*
* @param \stdClass $user User to create Dashboard for.
* @return \moodle_page
*/
protected function construct_user_page(\stdClass $user) {
$page = new \moodle_page();
$page->set_context(\context_user::instance($user->id));
$page->set_pagelayout('mydashboard');
$page->set_pagetype('my-index');
$page->blocks->load_blocks();
return $page;
}
/**
* Constructs a Page object for the User Dashboard.
*
* @param \stdClass $course Course to create Dashboard for.
* @return \moodle_page
*/
protected function construct_course_page(\stdClass $course) {
$page = new \moodle_page();
$page->set_context(\context_course::instance($course->id));
$page->set_pagelayout('standard');
$page->set_pagetype('course-view');
$page->set_course($course);
$page->blocks->load_blocks();
return $page;
}
/**
* Test that a block on the dashboard is exported.
*/
public function test_user_block(): void {
$this->resetAfterTest();
$title = 'Example title';
$content = 'Example content';
$format = FORMAT_PLAIN;
// Test setup.
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
$block = $this->create_user_block($title, $content, $format);
$context = \context_block::instance($block->instance->id);
// Get the contexts.
$contextlist = provider::get_contexts_for_userid($user->id);
// Only the user context should be returned.
$this->assertCount(1, $contextlist);
$this->assertEquals($context, $contextlist->current());
// Export the data.
$this->export_context_data_for_user($user->id, $context, 'block_html');
/** @var \core_privacy\tests\request\content_writer $writer */
$writer = \core_privacy\local\request\writer::with_context($context);
$this->assertTrue($writer->has_any_data());
// Check the data.
$data = $writer->get_data([]);
$this->assertInstanceOf('stdClass', $data);
$this->assertEquals($title, $data->title);
$this->assertEquals(format_text($content, $format, $this->get_format_options()), $data->content);
// Delete the context.
provider::delete_data_for_all_users_in_context($context);
// Re-fetch the contexts - it should no longer be returned.
$contextlist = provider::get_contexts_for_userid($user->id);
$this->assertCount(0, $contextlist);
}
/**
* Test that a block on the dashboard which is not configured is _not_ exported.
*/
public function test_user_block_unconfigured(): void {
global $DB;
$this->resetAfterTest();
$title = 'Example title';
$content = 'Example content';
$format = FORMAT_PLAIN;
// Test setup.
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
$block = $this->create_user_block($title, $content, $format);
$block->instance->configdata = '';
$DB->update_record('block_instances', $block->instance);
$block = block_instance('html', $block->instance);
$context = \context_block::instance($block->instance->id);
// Get the contexts.
$contextlist = provider::get_contexts_for_userid($user->id);
// Only the user context should be returned.
$this->assertCount(1, $contextlist);
$this->assertEquals($context, $contextlist->current());
// Export the data.
$this->export_context_data_for_user($user->id, $context, 'block_html');
/** @var \core_privacy\tests\request\content_writer $writer */
$writer = \core_privacy\local\request\writer::with_context($context);
$this->assertFalse($writer->has_any_data());
}
/**
* Test that a block on the dashboard is exported.
*/
public function test_user_multiple_blocks_exported(): void {
$this->resetAfterTest();
$title = 'Example title';
$content = 'Example content';
$format = FORMAT_PLAIN;
// Test setup.
$blocks = [];
$contexts = [];
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
$block = $this->create_user_block($title, $content, $format);
$context = \context_block::instance($block->instance->id);
$contexts[$context->id] = $context;
$block = $this->create_user_block($title, $content, $format);
$context = \context_block::instance($block->instance->id);
$contexts[$context->id] = $context;
// Get the contexts.
$contextlist = provider::get_contexts_for_userid($user->id);
// There are now two blocks on the user context.
$this->assertCount(2, $contextlist);
foreach ($contextlist as $context) {
$this->assertTrue(isset($contexts[$context->id]));
}
// Turn them into an approved_contextlist.
$approvedlist = new approved_contextlist($user, 'block_html', $contextlist->get_contextids());
// Delete using delete_data_for_user.
provider::delete_data_for_user($approvedlist);
// Re-fetch the contexts - it should no longer be returned.
$contextlist = provider::get_contexts_for_userid($user->id);
$this->assertCount(0, $contextlist);
}
/**
* Test that a block on the dashboard is not exported.
*/
public function test_course_blocks_not_exported(): void {
$this->resetAfterTest();
$title = 'Example title';
$content = 'Example content';
$format = FORMAT_PLAIN;
// Test setup.
$user = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course();
$this->setUser($user);
$block = $this->create_course_block($course, $title, $content, $format);
$context = \context_block::instance($block->instance->id);
// Get the contexts.
$contextlist = provider::get_contexts_for_userid($user->id);
// No blocks should be returned.
$this->assertCount(0, $contextlist);
}
/**
* Test that a block on the dashboard is exported.
*/
public function test_mixed_multiple_blocks_exported(): void {
$this->resetAfterTest();
$title = 'Example title';
$content = 'Example content';
$format = FORMAT_PLAIN;
// Test setup.
$contexts = [];
$user = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course();
$this->setUser($user);
$block = $this->create_course_block($course, $title, $content, $format);
$context = \context_block::instance($block->instance->id);
$block = $this->create_user_block($title, $content, $format);
$context = \context_block::instance($block->instance->id);
$contexts[$context->id] = $context;
$block = $this->create_user_block($title, $content, $format);
$context = \context_block::instance($block->instance->id);
$contexts[$context->id] = $context;
// Get the contexts.
$contextlist = provider::get_contexts_for_userid($user->id);
// There are now two blocks on the user context.
$this->assertCount(2, $contextlist);
foreach ($contextlist as $context) {
$this->assertTrue(isset($contexts[$context->id]));
}
}
/**
* Test that only users with a user context HTML block are fetched.
*/
public function test_get_users_in_context(): void {
$this->resetAfterTest();
$component = 'block_html';
$title = 'Block title';
$content = 'Block content';
$blockformat = FORMAT_PLAIN;
// Create a user with a user context HTML block.
$user1 = $this->getDataGenerator()->create_user();
$this->setUser($user1);
$userblock = $this->create_user_block($title, $content, $blockformat);
$usercontext = \context_block::instance($userblock->instance->id);
// Create a user with a course context HTML block.
$user2 = $this->getDataGenerator()->create_user();
$this->setUser($user2);
$course = $this->getDataGenerator()->create_course();
$courseblock = $this->create_course_block($course, $title, $content, $blockformat);
$coursecontext = \context_block::instance($courseblock->instance->id);
// Ensure only the user with a user context HTML block is returned.
$userlist = new \core_privacy\local\request\userlist($usercontext, $component);
\block_html\privacy\provider::get_users_in_context($userlist);
$this->assertCount(1, $userlist);
$expected = [$user1->id];
$actual = $userlist->get_userids();
$this->assertEquals($expected, $actual);
// Ensure passing the course context returns no users.
$userlist = new \core_privacy\local\request\userlist($coursecontext, $component);
\mod_forum\privacy\provider::get_users_in_context($userlist);
$this->assertEmpty($userlist);
}
/**
* Test that data for users in approved userlist is deleted.
*/
public function test_delete_data_for_users(): void {
$this->resetAfterTest();
$component = 'block_html';
$title = 'Block title';
$content = 'Block content';
$blockformat = FORMAT_PLAIN;
// Create 2 user swith a user context HTML blocks.
$user1 = $this->getDataGenerator()->create_user();
$this->setUser($user1);
$block1 = $this->create_user_block($title, $content, $blockformat);
$context1 = \context_block::instance($block1->instance->id);
$user2 = $this->getDataGenerator()->create_user();
$this->setUser($user2);
$block2 = $this->create_user_block($title, $content, $blockformat);
$context2 = \context_block::instance($block2->instance->id);
// Create and populate the userlists.
$userlist1 = new \core_privacy\local\request\userlist($context1, $component);
\block_html\privacy\provider::get_users_in_context($userlist1);
$userlist2 = new \core_privacy\local\request\userlist($context2, $component);
\block_html\privacy\provider::get_users_in_context($userlist2);
// Ensure both members are included.
$this->assertCount(1, $userlist1);
$this->assertCount(1, $userlist2);
// Convert $userlist1 into an approved_contextlist.
$approvedlist = new approved_userlist($context1, 'block_html', $userlist1->get_userids());
// Delete using delete_data_for_user.
provider::delete_data_for_users($approvedlist);
// Re-fetch users in the contexts - only the first one should now be empty.
$userlist1 = new \core_privacy\local\request\userlist($context1, $component);
\block_html\privacy\provider::get_users_in_context($userlist1);
$this->assertCount(0, $userlist1);
$userlist2 = new \core_privacy\local\request\userlist($context2, $component);
\block_html\privacy\provider::get_users_in_context($userlist2);
$this->assertCount(1, $userlist2);
}
}
+189
View File
@@ -0,0 +1,189 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit test for search indexing.
*
* @package block_html
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_html;
defined('MOODLE_INTERNAL') || die();
/**
* Unit test for search indexing.
*
* @package block_html
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class search_content_test extends \advanced_testcase {
/**
* Creates an HTML block on a course.
*
* @param \stdClass $course Course object
* @return \block_html Block instance object
*/
protected function create_block($course) {
$page = self::construct_page($course);
$page->blocks->add_block_at_end_of_default_region('html');
// Load the block.
$page = self::construct_page($course);
$page->blocks->load_blocks();
$blocks = $page->blocks->get_blocks_for_region($page->blocks->get_default_region());
$block = end($blocks);
return $block;
}
/**
* Constructs a page object for the test course.
*
* @param \stdClass $course Moodle course object
* @return \moodle_page Page object representing course view
*/
protected static function construct_page($course) {
$context = \context_course::instance($course->id);
$page = new \moodle_page();
$page->set_context($context);
$page->set_course($course);
$page->set_pagelayout('standard');
$page->set_pagetype('course-view');
$page->blocks->load_blocks();
return $page;
}
/**
* Tests all functionality in the search area.
*/
public function test_search_area(): void {
global $CFG, $USER, $DB;
require_once($CFG->dirroot . '/search/tests/fixtures/testable_core_search.php');
$this->resetAfterTest();
$this->setAdminUser();
// Create course and add HTML block.
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$before = time();
$block = $this->create_block($course);
// Change block settings to add some text and a file.
$itemid = file_get_unused_draft_itemid();
$fs = get_file_storage();
$usercontext = \context_user::instance($USER->id);
$fs->create_file_from_string(['component' => 'user', 'filearea' => 'draft',
'contextid' => $usercontext->id, 'itemid' => $itemid, 'filepath' => '/',
'filename' => 'file.txt'], 'File content');
$data = (object)['title' => 'Block title', 'text' => ['text' => 'Block text',
'itemid' => $itemid, 'format' => FORMAT_HTML]];
$block->instance_config_save($data);
$after = time();
// Set up fake search engine so we can create documents.
\testable_core_search::instance();
// Do indexing query.
$area = new \block_html\search\content();
$this->assertEquals('html', $area->get_block_name());
$rs = $area->get_recordset_by_timestamp();
$count = 0;
foreach ($rs as $record) {
$count++;
$this->assertEquals($course->id, $record->courseid);
// Check context is correct.
$blockcontext = \context::instance_by_id($record->contextid);
$this->assertInstanceOf('\context_block', $blockcontext);
$coursecontext = $blockcontext->get_parent_context();
$this->assertEquals($course->id, $coursecontext->instanceid);
// Check created and modified times are correct.
$this->assertTrue($record->timecreated >= $before && $record->timecreated <= $after);
$this->assertTrue($record->timemodified >= $before && $record->timemodified <= $after);
// Get config data.
$data = unserialize(base64_decode($record->configdata));
$this->assertEquals('Block title', $data->title);
$this->assertEquals('Block text', $data->text);
$this->assertEquals(FORMAT_HTML, $data->format);
// Check the get_document function 'new' flag.
$doc = $area->get_document($record, ['lastindexedtime' => 1]);
$this->assertTrue($doc->get_is_new());
$doc = $area->get_document($record, ['lastindexedtime' => time() + 1]);
$this->assertFalse($doc->get_is_new());
// Check the attach_files function results in correct list of associated files.
$this->assertCount(0, $doc->get_files());
$area->attach_files($doc);
$files = $doc->get_files();
// The directory entry should NOT be provided for indexing.
$this->assertCount(1, $files);
foreach ($files as $file) {
$this->assertEquals('file.txt', $file->get_filename());
$this->assertEquals('File content', $file->get_content());
}
// Check the document fields are all as expected.
$this->assertEquals('Block title', $doc->get('title'));
$this->assertEquals('Block text', $doc->get('content'));
$this->assertEquals($blockcontext->id, $doc->get('contextid'));
$this->assertEquals(\core_search\manager::TYPE_TEXT, $doc->get('type'));
$this->assertEquals($course->id, $doc->get('courseid'));
$this->assertEquals($record->timemodified, $doc->get('modified'));
$this->assertEquals(\core_search\manager::NO_OWNER_ID, $doc->get('owneruserid'));
// Also check getting the doc url and context url.
$url = new \moodle_url('/course/view.php', ['id' => $course->id], 'inst' . $record->id);
$this->assertTrue($url->compare($area->get_doc_url($doc)));
$this->assertTrue($url->compare($area->get_context_url($doc)));
}
$rs->close();
// Should only be one HTML block systemwide.
$this->assertEquals(1, $count);
// If we run the query starting from 1 second after now, there should be no results.
$rs = $area->get_recordset_by_timestamp($after + 1);
$count = 0;
foreach ($rs as $record) {
$count++;
}
$rs->close();
$this->assertEquals(0, $count);
// Create another block, but this time leave it empty (no data set). Hack the time though.
$block = $this->create_block($course);
$DB->set_field('block_instances', 'timemodified',
$after + 10, ['id' => $block->instance->id]);
$rs = $area->get_recordset_by_timestamp($after + 10);
$count = 0;
foreach ($rs as $record) {
// Because there is no configdata we don't index it.
$count++;
}
$rs->close();
$this->assertEquals(0, $count);
}
}