Skip to content

Commit 0062bef

Browse files
author
Matthias Opitz
committed
Updates required for Moodle 4.2+
- using correct class names for test cases used by Moodle 4.2+ - using core_external subsystem as of Moodle 4.2 - using numericals to set savepoints - added moodle_ci.yml to trigger GitHub Actions
1 parent f6e5df7 commit 0062bef

19 files changed

+429
-245
lines changed

.github/workflows/moodle-ci.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Moodle Plugin CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
services:
10+
postgres:
11+
image: postgres:13
12+
env:
13+
POSTGRES_USER: 'postgres'
14+
POSTGRES_HOST_AUTH_METHOD: 'trust'
15+
ports:
16+
- 5432:5432
17+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
18+
mariadb:
19+
# https://tracker.moodle.org/browse/MDL-72131
20+
image: mariadb:10
21+
env:
22+
MYSQL_USER: 'root'
23+
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
24+
ports:
25+
- 3306:3306
26+
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- php: '8.1'
33+
moodle-branch: 'master'
34+
extensions: "mbstring, pgsql, mysqli"
35+
database: 'pgsql'
36+
- php: '8.0'
37+
moodle-branch: 'MOODLE_402_STABLE'
38+
extensions: "mbstring, pgsql, mysqli"
39+
database: 'mariadb'
40+
41+
steps:
42+
- name: Check out repository code
43+
uses: actions/checkout@v2
44+
with:
45+
path: plugin
46+
47+
- name: Setup PHP ${{ matrix.php }}
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: ${{ matrix.php }}
51+
extensions: ${{ matrix.extensions }}
52+
ini-values: max_input_vars=5000
53+
tools: phpunit
54+
coverage: none
55+
56+
- name: Initialise moodle-plugin-ci
57+
run: |
58+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
59+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
60+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
61+
sudo locale-gen en_AU.UTF-8
62+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
63+
64+
- name: Install Moodle
65+
run: |
66+
moodle-plugin-ci add-plugin --branch MOODLE_402_STABLE Microsoft/moodle-auth_oidc
67+
moodle-plugin-ci install -vvv --plugin ./plugin --db-host=127.0.0.1
68+
env:
69+
DB: ${{ matrix.database }}
70+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
71+
72+
- name: PHP Lint
73+
if: ${{ always() }}
74+
run: moodle-plugin-ci phplint
75+
76+
- name: PHP Copy/Paste Detector
77+
continue-on-error: true # This step will show errors but will not fail
78+
if: ${{ always() }}
79+
run: moodle-plugin-ci phpcpd
80+
81+
- name: PHP Mess Detector
82+
continue-on-error: true # This step will show errors but will not fail
83+
if: ${{ always() }}
84+
run: moodle-plugin-ci phpmd
85+
86+
- name: Moodle Code Checker
87+
if: ${{ false }}
88+
run: moodle-plugin-ci codechecker --max-warnings 0
89+
90+
- name: Moodle PHPDoc Checker
91+
continue-on-error: true # This step will show errors but will not fail
92+
if: ${{ always() }}
93+
run: moodle-plugin-ci phpdoc
94+
95+
- name: Validating
96+
if: ${{ always() }}
97+
run: moodle-plugin-ci validate
98+
99+
- name: Check upgrade savepoints
100+
if: ${{ always() }}
101+
run: moodle-plugin-ci savepoints
102+
103+
- name: Mustache Lint
104+
if: ${{ always() }}
105+
run: moodle-plugin-ci mustache
106+
107+
- name: Grunt
108+
if: ${{ false }}
109+
run: moodle-plugin-ci grunt --max-lint-warnings 0
110+
111+
- name: PHPUnit tests
112+
if: ${{ always() }}
113+
run: moodle-plugin-ci phpunit
114+
115+
- name: Behat features
116+
if: ${{ always() }}
117+
run: moodle-plugin-ci behat --profile chrome

classes/webservices/create_onenoteassignment.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
namespace local_o365\webservices;
2727

28+
use core_external\external_api;
29+
use core_external\external_function_parameters;
30+
use core_external\external_single_structure;
31+
use core_external\external_value;
32+
2833
defined('MOODLE_INTERNAL') || die();
2934

3035
global $CFG;
@@ -34,21 +39,21 @@
3439
/**
3540
* Create assignment API class.
3641
*/
37-
class create_onenoteassignment extends \external_api {
42+
class create_onenoteassignment extends external_api {
3843
/**
3944
* Returns description of method parameters.
4045
*
4146
* @return external_function_parameters The parameters object for this webservice method.
4247
*/
4348
public static function assignment_create_parameters() {
44-
return new \external_function_parameters([
45-
'data' => new \external_single_structure([
46-
'name' => new \external_value(PARAM_TEXT, 'name'),
47-
'course' => new \external_value(PARAM_INT, 'course id'),
48-
'intro' => new \external_value(PARAM_TEXT, 'intro', VALUE_DEFAULT, ''),
49-
'section' => new \external_value(PARAM_INT, 'section', VALUE_DEFAULT, 0),
50-
'visible' => new \external_value(PARAM_BOOL, 'visible', VALUE_DEFAULT, false),
51-
'duedate' => new \external_value(PARAM_INT, 'duedate', VALUE_DEFAULT, 0),
49+
return new external_function_parameters([
50+
'data' => new external_single_structure([
51+
'name' => new external_value(PARAM_TEXT, 'name'),
52+
'course' => new external_value(PARAM_INT, 'course id'),
53+
'intro' => new external_value(PARAM_TEXT, 'intro', VALUE_DEFAULT, ''),
54+
'section' => new external_value(PARAM_INT, 'section', VALUE_DEFAULT, 0),
55+
'visible' => new external_value(PARAM_BOOL, 'visible', VALUE_DEFAULT, false),
56+
'duedate' => new external_value(PARAM_INT, 'duedate', VALUE_DEFAULT, 0),
5257
])
5358
]);
5459
}

classes/webservices/delete_onenoteassignment.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
namespace local_o365\webservices;
2727

28+
use core_external\external_api;
29+
use core_external\external_function_parameters;
30+
use core_external\external_single_structure;
31+
use core_external\external_value;
32+
2833
defined('MOODLE_INTERNAL') || die();
2934

3035
global $CFG;
@@ -34,17 +39,17 @@
3439
/**
3540
* Delete assignment API class.
3641
*/
37-
class delete_onenoteassignment extends \external_api {
42+
class delete_onenoteassignment extends external_api {
3843
/**
3944
* Returns description of method parameters.
4045
*
4146
* @return external_function_parameters The parameters object for this webservice method.
4247
*/
4348
public static function assignment_delete_parameters() {
44-
return new \external_function_parameters([
45-
'data' => new \external_single_structure([
46-
'coursemodule' => new \external_value(PARAM_INT, 'course module id'),
47-
'course' => new \external_value(PARAM_INT, 'course id'),
49+
return new external_function_parameters([
50+
'data' => new external_single_structure([
51+
'coursemodule' => new external_value(PARAM_INT, 'course module id'),
52+
'course' => new external_value(PARAM_INT, 'course id'),
4853
])
4954
]);
5055
}
@@ -79,8 +84,8 @@ public static function assignment_delete($data) {
7984
*/
8085
public static function assignment_delete_returns() {
8186
$params = [
82-
'result' => new \external_value(PARAM_BOOL, 'success/failure'),
87+
'result' => new external_value(PARAM_BOOL, 'success/failure'),
8388
];
84-
return new \external_single_structure($params);
89+
return new external_single_structure($params);
8590
}
8691
}

0 commit comments

Comments
 (0)