From 48545f7cd30df221466ba4e0216138bddfd9a288 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Wed, 17 Jul 2024 15:55:06 +0100 Subject: [PATCH 1/7] replaced deprecated Behat command added local replacements for deprecated core strings 'from' and 'to' --- lang/en/hsuforum.php | 2 ++ mod_form.php | 4 ++-- tests/behat/accessibility_pin_button.feature | 2 +- tests/behat/add_forum.feature | 4 ++-- tests/behat/advanced_editor_pass_data_to_new_page.feature | 2 +- tests/behat/edit_post_student.feature | 2 +- tests/behat/edit_post_teacher.feature | 2 +- tests/behat/grading_settings.feature | 2 +- tests/behat/hsuforum_tags.feature | 2 +- tests/behat/inline_edit.feature | 2 +- tests/behat/maintain_start_end_date.feature | 2 +- tests/behat/posts_ordering_blog.feature | 2 +- tests/behat/posts_ordering_general.feature | 2 +- tests/behat/rate_posts.feature | 2 +- tests/behat/separate_group_single_group_discussions.feature | 4 ++-- tests/behat/split_forum_discussion.feature | 2 +- 16 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lang/en/hsuforum.php b/lang/en/hsuforum.php index eba01dd3..2301d11b 100644 --- a/lang/en/hsuforum.php +++ b/lang/en/hsuforum.php @@ -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'; @@ -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'; diff --git a/mod_form.php b/mod_form.php index ebdb4ad1..1a26ca47 100644 --- a/mod_form.php +++ b/mod_form.php @@ -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'); } diff --git a/tests/behat/accessibility_pin_button.feature b/tests/behat/accessibility_pin_button.feature index 0aba5f07..2090a8b3 100644 --- a/tests/behat/accessibility_pin_button.feature +++ b/tests/behat/accessibility_pin_button.feature @@ -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 | diff --git a/tests/behat/add_forum.feature b/tests/behat/add_forum.feature index cb4c75f4..8ce620d0 100644 --- a/tests/behat/add_forum.feature +++ b/tests/behat/add_forum.feature @@ -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 | @@ -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 | diff --git a/tests/behat/advanced_editor_pass_data_to_new_page.feature b/tests/behat/advanced_editor_pass_data_to_new_page.feature index 61a01041..3119a5a0 100644 --- a/tests/behat/advanced_editor_pass_data_to_new_page.feature +++ b/tests/behat/advanced_editor_pass_data_to_new_page.feature @@ -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 | diff --git a/tests/behat/edit_post_student.feature b/tests/behat/edit_post_student.feature index a7ed2125..ea031667 100644 --- a/tests/behat/edit_post_student.feature +++ b/tests/behat/edit_post_student.feature @@ -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 | diff --git a/tests/behat/edit_post_teacher.feature b/tests/behat/edit_post_teacher.feature index dedc60ad..37c85b41 100644 --- a/tests/behat/edit_post_teacher.feature +++ b/tests/behat/edit_post_teacher.feature @@ -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: diff --git a/tests/behat/grading_settings.feature b/tests/behat/grading_settings.feature index add22ae7..3e65b11e 100644 --- a/tests/behat/grading_settings.feature +++ b/tests/behat/grading_settings.feature @@ -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 | diff --git a/tests/behat/hsuforum_tags.feature b/tests/behat/hsuforum_tags.feature index 5744f2fc..7fd59d53 100644 --- a/tests/behat/hsuforum_tags.feature +++ b/tests/behat/hsuforum_tags.feature @@ -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: diff --git a/tests/behat/inline_edit.feature b/tests/behat/inline_edit.feature index e8de4003..7247034f 100644 --- a/tests/behat/inline_edit.feature +++ b/tests/behat/inline_edit.feature @@ -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 | diff --git a/tests/behat/maintain_start_end_date.feature b/tests/behat/maintain_start_end_date.feature index e9631fdd..75d30dbf 100644 --- a/tests/behat/maintain_start_end_date.feature +++ b/tests/behat/maintain_start_end_date.feature @@ -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: diff --git a/tests/behat/posts_ordering_blog.feature b/tests/behat/posts_ordering_blog.feature index ff6ff1b6..26a9f8eb 100644 --- a/tests/behat/posts_ordering_blog.feature +++ b/tests/behat/posts_ordering_blog.feature @@ -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 | diff --git a/tests/behat/posts_ordering_general.feature b/tests/behat/posts_ordering_general.feature index 48f56882..2013f81f 100644 --- a/tests/behat/posts_ordering_general.feature +++ b/tests/behat/posts_ordering_general.feature @@ -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 | diff --git a/tests/behat/rate_posts.feature b/tests/behat/rate_posts.feature index 07af4cbd..22d151a7 100644 --- a/tests/behat/rate_posts.feature +++ b/tests/behat/rate_posts.feature @@ -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 | diff --git a/tests/behat/separate_group_single_group_discussions.feature b/tests/behat/separate_group_single_group_discussions.feature index e3b1d8ec..c7515480 100644 --- a/tests/behat/separate_group_single_group_discussions.feature +++ b/tests/behat/separate_group_single_group_discussions.feature @@ -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 | diff --git a/tests/behat/split_forum_discussion.feature b/tests/behat/split_forum_discussion.feature index 33ddcc6e..511723b1 100644 --- a/tests/behat/split_forum_discussion.feature +++ b/tests/behat/split_forum_discussion.feature @@ -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 "Course 1" 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. | From a23075251dedfc1394d5cf1fa4ee85da3cfb0e14 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 09:07:56 +0100 Subject: [PATCH 2/7] fixed creation of dynamic property --- classes/output/big_search_form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/output/big_search_form.php b/classes/output/big_search_form.php index 33f559f9..0043aa4b 100644 --- a/classes/output/big_search_form.php +++ b/classes/output/big_search_form.php @@ -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; From 4f2f08e8ef136fb9e6de74b8bc161459df860ba8 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 09:08:50 +0100 Subject: [PATCH 3/7] fixed deprecated usage of format_text() --- search.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/search.php b/search.php index d91dbf1d..f4104922 100644 --- a/search.php +++ b/search.php @@ -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( @@ -312,8 +314,7 @@ $post->id ), $post->messageformat, - $options, - $course->id), + $options), 0, '', ''); foreach ($searchterms as $searchterm) { From 2e923e5c4f85ea1cc1f72dbdc4e222ef34009379 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 10:13:13 +0100 Subject: [PATCH 4/7] fixed another deprecated Behat command using correct course name in Behat statement --- tests/behat/forum_subscriptions_availability.feature | 8 ++++---- tests/behat/split_forum_discussion.feature | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/behat/forum_subscriptions_availability.feature b/tests/behat/forum_subscriptions_availability.feature index b8ad6382..eb092a3c 100644 --- a/tests/behat/forum_subscriptions_availability.feature +++ b/tests/behat/forum_subscriptions_availability.feature @@ -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 | @@ -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 | @@ -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 | @@ -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 | diff --git a/tests/behat/split_forum_discussion.feature b/tests/behat/split_forum_discussion.feature index 511723b1..905e4ca4 100644 --- a/tests/behat/split_forum_discussion.feature +++ b/tests/behat/split_forum_discussion.feature @@ -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 "hsuforum" activity to course "Course 1" 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. | From fdadbb8275738b182545761a579840d0a73cfb9f Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 10:46:51 +0100 Subject: [PATCH 5/7] fixed Bahat test - 'Add standard tags' is a button, not a link --- .github/workflows/moodle-ci.yml | 127 ++++++++++++++++++++++++++++++ tests/behat/hsuforum_tags.feature | 2 +- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/moodle-ci.yml diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml new file mode 100644 index 00000000..290742bf --- /dev/null +++ b/.github/workflows/moodle-ci.yml @@ -0,0 +1,127 @@ +name: Moodle Plugin CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-22.04 + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: 'postgres' + POSTGRES_HOST_AUTH_METHOD: 'trust' + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + + mariadb: + image: mariadb:10 + env: + MYSQL_USER: 'root' + MYSQL_ALLOW_EMPTY_PASSWORD: "true" + MYSQL_CHARACTER_SET_SERVER: "utf8mb4" + MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 + + strategy: + fail-fast: false + matrix: + include: + - php: '8.2' + moodle-branch: 'main' + database: 'mariadb' + - php: '8.2' + moodle-branch: 'main' + database: 'pgsql' + - php: '8.1' + moodle-branch: 'MOODLE_404_STABLE' + database: 'mariadb' + - php: '8.1' + moodle-branch: 'MOODLE_403_STABLE' + database: 'mariadb' + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + path: plugin + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ matrix.extensions }} + ini-values: max_input_vars=5000 + # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". + # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). + coverage: none + + - name: Initialise moodle-plugin-ci + run: | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 + echo $(cd ci/bin; pwd) >> $GITHUB_PATH + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH + sudo locale-gen en_AU.UTF-8 + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV + + - name: Install moodle-plugin-ci + run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 + env: + DB: ${{ matrix.database }} + MOODLE_BRANCH: ${{ matrix.moodle-branch }} + # Uncomment this to run Behat tests using the Moodle App. + # MOODLE_APP: 'true' + + - name: PHP Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci phplint + + - name: PHP Copy/Paste Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcpd + + - name: PHP Mess Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpmd + + - name: Moodle Code Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcs --max-warnings 0 + + - name: Moodle PHPDoc Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpdoc --max-warnings 0 + + - name: Validating + if: ${{ !cancelled() }} + run: moodle-plugin-ci validate + + - name: Check upgrade savepoints + if: ${{ !cancelled() }} + run: moodle-plugin-ci savepoints + + - name: Mustache Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci mustache + + - name: Grunt + if: ${{ !cancelled() }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpunit --fail-on-warning + + - name: Behat features + if: ${{ !cancelled() }} + run: moodle-plugin-ci behat --profile chrome + + - name: Mark cancelled jobs as failed. + if: ${{ cancelled() }} + run: exit 1 diff --git a/tests/behat/hsuforum_tags.feature b/tests/behat/hsuforum_tags.feature index 7fd59d53..faaffba4 100644 --- a/tests/behat/hsuforum_tags.feature +++ b/tests/behat/hsuforum_tags.feature @@ -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 From fa579b091f1a2508b44c19423b8d543de33b6d54 Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 11:45:21 +0100 Subject: [PATCH 6/7] fixed deprecated dynamic property in hsuforum_portfolio_caller class --- locallib.php | 1 + tests/portfolio_caller_test.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/locallib.php b/locallib.php index c5110f9c..6bc2e064 100644 --- a/locallib.php +++ b/locallib.php @@ -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 diff --git a/tests/portfolio_caller_test.php b/tests/portfolio_caller_test.php index f3eb52c1..93452383 100644 --- a/tests/portfolio_caller_test.php +++ b/tests/portfolio_caller_test.php @@ -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 From 273d5a9382b1baead13cfff5761a51187ef7009e Mon Sep 17 00:00:00 2001 From: Matthias Opitz Date: Thu, 18 Jul 2024 12:11:18 +0100 Subject: [PATCH 7/7] fixed PHPUnit issue - added missing icon to expected data --- .github/workflows/moodle-ci.yml | 127 -------------------------------- tests/externallib_test.php | 2 +- 2 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 .github/workflows/moodle-ci.yml diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml deleted file mode 100644 index 290742bf..00000000 --- a/.github/workflows/moodle-ci.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Moodle Plugin CI - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-22.04 - - services: - postgres: - image: postgres:13 - env: - POSTGRES_USER: 'postgres' - POSTGRES_HOST_AUTH_METHOD: 'trust' - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 - - mariadb: - image: mariadb:10 - env: - MYSQL_USER: 'root' - MYSQL_ALLOW_EMPTY_PASSWORD: "true" - MYSQL_CHARACTER_SET_SERVER: "utf8mb4" - MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 - - strategy: - fail-fast: false - matrix: - include: - - php: '8.2' - moodle-branch: 'main' - database: 'mariadb' - - php: '8.2' - moodle-branch: 'main' - database: 'pgsql' - - php: '8.1' - moodle-branch: 'MOODLE_404_STABLE' - database: 'mariadb' - - php: '8.1' - moodle-branch: 'MOODLE_403_STABLE' - database: 'mariadb' - - steps: - - name: Check out repository code - uses: actions/checkout@v4 - with: - path: plugin - - - name: Setup PHP ${{ matrix.php }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: ${{ matrix.extensions }} - ini-values: max_input_vars=5000 - # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". - # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). - coverage: none - - - name: Initialise moodle-plugin-ci - run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 - echo $(cd ci/bin; pwd) >> $GITHUB_PATH - echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH - sudo locale-gen en_AU.UTF-8 - echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV - - - name: Install moodle-plugin-ci - run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 - env: - DB: ${{ matrix.database }} - MOODLE_BRANCH: ${{ matrix.moodle-branch }} - # Uncomment this to run Behat tests using the Moodle App. - # MOODLE_APP: 'true' - - - name: PHP Lint - if: ${{ !cancelled() }} - run: moodle-plugin-ci phplint - - - name: PHP Copy/Paste Detector - continue-on-error: true # This step will show errors but will not fail - if: ${{ !cancelled() }} - run: moodle-plugin-ci phpcpd - - - name: PHP Mess Detector - continue-on-error: true # This step will show errors but will not fail - if: ${{ !cancelled() }} - run: moodle-plugin-ci phpmd - - - name: Moodle Code Checker - if: ${{ !cancelled() }} - run: moodle-plugin-ci phpcs --max-warnings 0 - - - name: Moodle PHPDoc Checker - if: ${{ !cancelled() }} - run: moodle-plugin-ci phpdoc --max-warnings 0 - - - name: Validating - if: ${{ !cancelled() }} - run: moodle-plugin-ci validate - - - name: Check upgrade savepoints - if: ${{ !cancelled() }} - run: moodle-plugin-ci savepoints - - - name: Mustache Lint - if: ${{ !cancelled() }} - run: moodle-plugin-ci mustache - - - name: Grunt - if: ${{ !cancelled() }} - run: moodle-plugin-ci grunt --max-lint-warnings 0 - - - name: PHPUnit tests - if: ${{ !cancelled() }} - run: moodle-plugin-ci phpunit --fail-on-warning - - - name: Behat features - if: ${{ !cancelled() }} - run: moodle-plugin-ci behat --profile chrome - - - name: Mark cancelled jobs as failed. - if: ${{ cancelled() }} - run: exit 1 diff --git a/tests/externallib_test.php b/tests/externallib_test.php index 9a6a76e3..b352ceff 100644 --- a/tests/externallib_test.php +++ b/tests/externallib_test.php @@ -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, @@ -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);