Skip to content

Passing Behat and PHPUnit tests with Moodle 4.4 and PHP 8.2 #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions classes/output/big_search_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class big_search_form implements renderable, templatable {
public $user;
public $words;
public $tags;
public $forumid;
/** @var string The URL of the search form. */
public $actionurl;

Expand Down
2 changes: 2 additions & 0 deletions lang/en/hsuforum.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
$string['exportdiscussion'] = 'Export whole discussion to portfolio';
$string['forcessubscribe'] = 'This forum forces everyone to be subscribed';
$string['forum'] = 'Forum';
$string['from'] = 'From';
$string['gradingmethodpreview'] = 'Grading criteria';
$string['hsuforum:addinstance'] = 'Add a new forum';
$string['hsuforum:allowforcesubscribe'] = 'Allow force subscribe';
Expand Down Expand Up @@ -579,6 +580,7 @@
$string['timedposts'] = 'Timed posts';
$string['timedvisible'] = 'Timed status: Visible to all users';
$string['timestartenderror'] = 'Display end date cannot be earlier than the start date';
$string['to'] = 'To';
$string['trackforum'] = 'Track unread posts';
$string['trackreadposts_header'] = 'Forum tracking';
$string['unread'] = 'New';
Expand Down
1 change: 1 addition & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class hsuforum_portfolio_caller extends portfolio_module_caller_base {
private $discussion;
private $posts;
private $keyedfiles; // just using multifiles isn't enough if we're exporting a full thread
private $modcontext;

/**
* @return array
Expand Down
4 changes: 2 additions & 2 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@ protected function add_hsuforum_rating_settings() {
$mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'rating'));
$mform->hideIf('ratingtime', $assessedfieldname, 'eq', 0);

$mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
$mform->addElement('date_time_selector', 'assesstimestart', get_string('from', 'mod_hsuforum'));
$mform->hideIf('assesstimestart', $assessedfieldname, 'eq', 0);
$mform->hideIf('assesstimestart', 'ratingtime');

$mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
$mform->addElement('date_time_selector', 'assesstimefinish', get_string('to', 'mod_hsuforum'));
$mform->hideIf('assesstimefinish', $assessedfieldname, 'eq', 0);
$mform->hideIf('assesstimefinish', 'ratingtime');
}
Expand Down
5 changes: 3 additions & 2 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
$options = new stdClass();
$options->trusted = $post->messagetrust;
$modcontext = context_module::instance($cm->id);
$coursecontext = context_course::instance($course->id);
$options->context = $coursecontext;
$post->message = highlight($strippedsearch,
format_text(
file_rewrite_pluginfile_urls(
Expand All @@ -312,8 +314,7 @@
$post->id
),
$post->messageformat,
$options,
$course->id),
$options),
0, '<fgw9sdpq4>', '</fgw9sdpq4>');

foreach ($searchterms as $searchterm) {
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/accessibility_pin_button.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: When creating a new discussion the unpin option should exist as a butto
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/add_forum.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Add Open Forum activities and discussions
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down Expand Up @@ -59,7 +59,7 @@ Feature: Add Open Forum activities and discussions
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/advanced_editor_pass_data_to_new_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Users see their typed information in the advanced editor view when clic
| enabletimedposts | 1 | hsuforum |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/edit_post_student.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Students can edit or delete their Open Forum posts within a set time li
And I log out
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/edit_post_teacher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Teachers can edit or delete any Open Forum post
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand Down
8 changes: 4 additions & 4 deletions tests/behat/forum_subscriptions_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced forum lists all subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -39,7 +39,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced forum does not allow to edit the subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 2 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -55,7 +55,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced and hidden forum lists only teachers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 2 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -70,7 +70,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: An automatic forum lists all subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/grading_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: While creating a new activity, the grade settings should remain in the
| Grade category 1 | C1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/hsuforum_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand All @@ -47,7 +47,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
Given I log in as "admin"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"
And I click on "Add standard tags" "button"
And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3"
And I press "Continue"
And I log out
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/inline_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Teachers and students can add discussions inline
| enabletimedposts | 1 | hsuforum |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/maintain_start_end_date.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: In Open Forums users can change start and end date and the changes rema
And the following config values are set as admin:
| enabletimedposts | 1 | hsuforum |
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/posts_ordering_blog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Course blog forum |
| Description | Single discussion forum description |
| Forum type | Standard forum displayed in a blog-like format |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/posts_ordering_general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: New Open discussions and discussions with recently added replies are di
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Course general forum |
| Description | Single discussion forum description |
| Forum type | Standard forum for general use |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/rate_posts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Users can rate other users forum posts
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
| Aggregate type | Average of ratings |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/separate_group_single_group_discussions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ Feature: In Open Forums, posting to groups in a separate group discussion when r
| G2 | G2G1 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Multiple groups forum |
| Forum type | Standard forum for general use |
| Description | Standard forum description |
| Group mode | Separate groups |
| Grouping | G1 |
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Single groups forum |
| Forum type | Standard forum for general use |
| Description | Standard forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/split_forum_discussion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Open Forum discussions can be split
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Science 101" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Science 101" section "1" and I fill the form with:
| Forum name | Study discussions |
| Forum type | Standard forum for general use |
| Description | Forum to discuss your coursework. |
Expand Down
2 changes: 1 addition & 1 deletion tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function test_mod_hsuforum_get_forum_discussion_posts() {
'timemodified' => $timepost,
'mimetype' => 'image/jpeg',
'isexternalfile' => false,
'icon' => "f/image",
)
),
'totalscore' => $discussion1reply1->totalscore,
Expand Down Expand Up @@ -345,7 +346,6 @@ public function test_mod_hsuforum_get_forum_discussion_posts() {
$userpicture = new user_picture($user2);
$userpicture->size = 1; // Size f1.
$expectedposts['posts'][1]['userpictureurl'] = $userpicture->get_url($PAGE)->out(false);

// Unset the initial discussion post.
array_shift($posts['posts']);
$this->assertEquals($expectedposts, $posts);
Expand Down
2 changes: 1 addition & 1 deletion tests/portfolio_caller_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Tests behaviour of the hsuforum_portfolio_caller class.
*/
class mod_hsuforum_portfolio_caller_testcase extends advanced_testcase {
class portfolio_caller_test extends advanced_testcase {

/**
* Ensure that a file will be loaded in an instance of the caller when supplied valid and
Expand Down