Skip to content

Commit 75e17db

Browse files
authored
Merge pull request #158 from catalyst/issue157
Issue #157: CI fixes
2 parents 8eba373 + a19a8c3 commit 75e17db

24 files changed

+152
-171
lines changed

classes/customfield/cmsuserlist_handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function get_instance_context(int $instanceid = 0): \context {
6666
*
6767
* @return bool
6868
*/
69-
public function uses_categories() : bool {
69+
public function uses_categories(): bool {
7070
return false;
7171
}
7272

classes/form/cms_types_form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function add_action_buttons($cancel = true, $submitlabel=null) {
155155
if ($cancel) {
156156
$buttonarray[] = &$mform->createElement('cancel');
157157
}
158-
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
158+
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
159159
$mform->closeHeaderBefore('buttonar');
160160
}
161161

classes/local/datasource/roles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function config_backup_define_structure(\backup_nested_element $parent) {
343343
$cmstype = $this->cms->get_type();
344344
$config = $cmstype->get_custom_data('roles_config');
345345
$source = is_null($config) ? [] : [
346-
['list' => implode(',', $config->list), 'duplicates' => $config->duplicates]
346+
['list' => implode(',', $config->list), 'duplicates' => $config->duplicates],
347347
];
348348
$roles->set_source_array($source);
349349
}

classes/local/datasource/userlist.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ public function instance_backup_define_structure(\backup_nested_element $parent)
525525

526526
$fields = new \backup_nested_element('userlistfields');
527527
if ($DB->get_manager()->field_exists('customfield_data', 'valuetrust')) {
528-
$field = new \backup_nested_element('userlistfield', ['id'], ['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
528+
$field = new \backup_nested_element('userlistfield', ['id'],
529+
['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
529530
} else {
530531
$field = new \backup_nested_element('userlistfield', ['id'], ['shortname', 'type', 'value', 'valueformat']);
531532
}
@@ -546,7 +547,7 @@ function ($arr) {
546547
},
547548
$fielddata
548549
)
549-
)
550+
),
550551
];
551552
$fieldsforbackup = array_merge($fieldsforbackup, $this->cfhandler->get_instance_data_for_backup($id));
552553
// Backup annotations. Check for function existence for the sake of backward compatibility.

classes/local/model/cms_types.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ protected static function define_properties(): array {
6868
],
6969
'description' => [
7070
'type' => PARAM_RAW,
71-
'default' => ''
71+
'default' => '',
7272
],
7373
'descriptionformat' => [
7474
'type' => PARAM_INT,
75-
'default' => 1
75+
'default' => 1,
7676
],
7777
'title_mustache' => [
7878
'type' => PARAM_TEXT,
79-
'default' => ''
79+
'default' => '',
8080
],
8181
'mustache' => [
8282
'type' => PARAM_RAW,
83-
'default' => '{{{debug}}}'
83+
'default' => '{{{debug}}}',
8484
],
8585
'datasources' => [
8686
'type' => PARAM_TEXT,
87-
'default' => ''
87+
'default' => '',
8888
],
8989
'customdata' => [
9090
'type' => PARAM_TEXT,

classes/search/activity.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
namespace mod_cms\search;
1818

19-
defined('MOODLE_INTERNAL') || die();
20-
2119
use mod_cms\local\model\cms;
2220
use mod_cms\local\renderer;
2321

index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
* @copyright 2023, Catalyst IT
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
25+
2526
require_once('../../config.php');
2627

2728
// TODO: This is a stub.
2829

2930
$id = required_param('id', PARAM_INT); // Course id.
3031

31-
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
32+
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
3233

3334
require_login($course);

lang/en/cms.php

Lines changed: 62 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -26,113 +26,89 @@
2626
defined('MOODLE_INTERNAL') || die();
2727

2828
$string['addnewtype'] = 'Add new content type';
29-
$string['chooser:show'] = 'Show in activity chooser';
29+
$string['cachedef_cms_content'] = 'CMS content';
30+
$string['cachedef_cms_content_fields'] = 'CMS fields datasource';
31+
$string['cachedef_cms_content_images'] = 'CMS images datasource';
32+
$string['cachedef_cms_content_roles'] = 'CMS roles datasource';
33+
$string['cachedef_cms_content_userlist'] = 'CMS userlist datasource';
34+
$string['cachedef_cms_name'] = 'CMS name';
3035
$string['chooser:hide'] = 'Hide in activity chooser';
36+
$string['chooser:show'] = 'Show in activity chooser';
37+
$string['cms:addinstance'] = 'Add a new custom content instance';
38+
$string['cms:seeall'] = 'Can see hidden CMS types in the activity chooser';
39+
$string['cms:view'] = 'View a new custom content instance';
40+
$string['cms_type:icon_desc'] = 'This icon will be displayed in the activity chooser menu.';
41+
$string['customfield_manage_heading'] = 'Manage custom fields for content type "{$a}"';
42+
$string['datasources'] = 'Datasources';
43+
$string['datasources_desc'] = 'This is a performance measure. Select datasources to be included in this type. Only selected datasources will be configurable,
44+
or editable at the instance level, or be called upon to provide data. Some datasources are always included and do not appear in
45+
this list.';
3146
$string['editcontenttype'] = 'Edit content type';
47+
$string['error:cant_delete_content_type'] = 'Cannot delete content type.';
48+
$string['error:class_missing'] = 'Datasource class \'{$a}\' does not exist.';
49+
$string['error:invalid'] = 'Invalid: {$a}';
50+
$string['error:must_be_base'] = 'Datasource class \'($a}\' must inherit from mod_cms\\datasource\\base.';
51+
$string['error:name_not_unique'] = 'Datasource class shortname \'($a}\' must be unique.';
52+
$string['error:no_config_hash'] = 'Module {$a} has no config hash.';
53+
$string['error:no_file_uploaded'] = 'No file uploaded';
54+
$string['error:no_instance_hash'] = 'Module {$a} has no instance hash.';
55+
$string['event:cms_type_created'] = 'Custom content type created';
56+
$string['event:cms_type_deleted'] = 'Custom content type deleted';
57+
$string['event:cms_type_updated'] = 'Custom content type updated';
58+
$string['event_cms_type_created_desc'] = 'The user with ID: {$a->userid} has created a custom content type with ID: {$a->typeid}';
59+
$string['event_cms_type_deleted_desc'] = 'The user with ID: {$a->userid} has deleted a custom content type with ID: {$a->typeid}';
60+
$string['event_cms_type_updated_desc'] = 'The user with ID: {$a->userid} has updated a custom content type with ID: {$a->typeid}';
3261
$string['export'] = 'Export';
33-
$string['import'] = 'Import';
62+
$string['fields:config:columns'] = 'Fields and categories';
63+
$string['fields:config:header'] = 'Custom field settings';
64+
$string['fields:custom_fields'] = 'Custom fields';
65+
$string['fields:sample_text'] = 'text';
66+
$string['fields:sample_time'] = 'Thursday, 15 June 2023, 12:00 AM';
3467
$string['idnumber'] = 'ID number';
35-
$string['idnumber_help'] = 'An identifier to uniquely label this CMS type. This will be used in backup and restoring. It must be unique within the system, and ideally, unique universally.';
3668
$string['idnumber_exists'] = 'Id number \'{$a}\' already exists in the system.';
69+
$string['idnumber_help'] = 'An identifier to uniquely label this CMS type. This will be used in backup and restoring. It must be unique within the system, and ideally, unique universally.';
70+
$string['images:config:header'] = 'Images settings';
71+
$string['images:images'] = 'Images';
72+
$string['import'] = 'Import';
73+
$string['import_cms_type'] = 'Import content type';
74+
$string['import_file'] = 'Import file';
75+
$string['instance:header'] = 'Activity fields';
76+
$string['instance:name'] = 'Name';
77+
$string['manage_types_return'] = 'Return to manage types';
3778
$string['managetypes'] = 'Manage content types';
3879
$string['maxgrade'] = 'Default max grade';
3980
$string['maxgrade_desc'] = 'The default max grade when creating a new custom content type instance.';
4081
$string['modulename'] = 'CMS';
4182
$string['modulenameplural'] = 'CMS';
42-
$string['newcontenttype'] = 'Add new content type';
43-
$string['pluginname'] = 'CMS';
44-
$string['settings'] = 'Custom content type settings';
45-
$string['table:name'] = 'Custom content type';
46-
$string['table:numinstances'] = 'Number of instances';
47-
$string['pluginadministration'] = 'Plugin administration';
48-
$string['preview_with_hint'] = 'Preview (click "{$a}" to update)';
49-
$string['customfield_manage_heading'] = 'Manage custom fields for content type "{$a}"';
50-
$string['manage_types_return'] = 'Return to manage types';
51-
$string['sample_value'] = 'Sample value';
52-
$string['some_name'] = 'Some name';
53-
$string['import_file'] = 'Import file';
54-
$string['import_cms_type'] = 'Import content type';
55-
$string['datasources'] = 'Datasources';
56-
$string['datasources_desc'] = 'This is a performance measure. Select datasources to be included in this type. Only selected datasources will be configurable,
57-
or editable at the instance level, or be called upon to provide data. Some datasources are always included and do not appear in
58-
this list.';
59-
$string['visibility_updated'] = 'Visibility updated';
60-
61-
// Cache defs.
62-
$string['cachedef_cms_content'] = 'CMS content';
63-
$string['cachedef_cms_content_fields'] = 'CMS fields datasource';
64-
$string['cachedef_cms_content_images'] = 'CMS images datasource';
65-
$string['cachedef_cms_content_roles'] = 'CMS roles datasource';
66-
$string['cachedef_cms_content_userlist'] = 'CMS userlist datasource';
67-
$string['cachedef_cms_name'] = 'CMS name';
68-
69-
// Template form section.
70-
$string['instance:header'] = 'Activity fields';
71-
$string['instance:name'] = 'Name';
7283
$string['mustache'] = 'Content';
7384
$string['mustache_help'] = 'The two fields above will form the content displayed in the activity. They both will need to be valid {$a}. Variables that are available for use in these templates are given below.';
7485
$string['mustache_template'] = 'mustache templates';
75-
$string['cms_type:icon_desc'] = 'This icon will be displayed in the activity chooser menu.';
76-
77-
// Event strings.
78-
$string['event:cms_type_created'] = 'Custom content type created';
79-
$string['event_cms_type_created_desc'] = 'The user with ID: {$a->userid} has created a custom content type with ID: {$a->typeid}';
80-
$string['event:cms_type_deleted'] = 'Custom content type deleted';
81-
$string['event_cms_type_deleted_desc'] = 'The user with ID: {$a->userid} has deleted a custom content type with ID: {$a->typeid}';
82-
$string['event:cms_type_updated'] = 'Custom content type updated';
83-
$string['event_cms_type_updated_desc'] = 'The user with ID: {$a->userid} has updated a custom content type with ID: {$a->typeid}';
84-
85-
// Capability strings.
86-
$string['cms:addinstance'] = 'Add a new custom content instance';
87-
$string['cms:view'] = 'View a new custom content instance';
88-
$string['cms:seeall'] = 'Can see hidden CMS types in the activity chooser';
89-
90-
// Privacy strings.
86+
$string['newcontenttype'] = 'Add new content type';
87+
$string['pluginadministration'] = 'Plugin administration';
88+
$string['pluginname'] = 'CMS';
89+
$string['preview_with_hint'] = 'Preview (click "{$a}" to update)';
9190
$string['privacy:metadata:cms'] = 'Custom content type instances';
9291
$string['privacy:metadata:cms:usermodified'] = 'User who modified the instances';
9392
$string['privacy:metadata:cms_types'] = 'Custom content types';
9493
$string['privacy:metadata:cms_types:usermodified'] = 'User who modified the custom content types';
95-
96-
// Error strings.
97-
$string['error:class_missing'] = 'Datasource class \'{$a}\' does not exist.';
98-
$string['error:must_be_base'] = 'Datasource class \'($a}\' must inherit from mod_cms\\datasource\\base.';
99-
$string['error:name_not_unique'] = 'Datasource class shortname \'($a}\' must be unique.';
100-
$string['error:no_file_uploaded'] = 'No file uploaded';
101-
$string['error:cant_delete_content_type'] = 'Cannot delete content type.';
102-
$string['error:invalid'] = 'Invalid: {$a}';
103-
$string['error:no_instance_hash'] = 'Module {$a} has no instance hash.';
104-
$string['error:no_config_hash'] = 'Module {$a} has no config hash.';
105-
106-
// Search strings.
94+
$string['roles:config:duplicates'] = 'Duplicates';
95+
$string['roles:config:duplicates:all'] = 'Show in all';
96+
$string['roles:config:duplicates:firstonly'] = 'Show in first';
97+
$string['roles:config:duplicates:nest'] = 'Show in first with roles';
98+
$string['roles:config:header'] = 'Role list settings';
99+
$string['roles:config:list'] = 'Roles included';
100+
$string['roles:displayname'] = 'Roles list';
101+
$string['roles:error:role_does_not_exist'] = 'Role "{$a}" does nor exist.';
102+
$string['sample_value'] = 'Sample value';
107103
$string['search:activity'] = 'CMS - activity information';
108-
109-
// Site datasource strings.
104+
$string['settings'] = 'Custom content type settings';
110105
$string['site:displayname'] = 'Site Info';
111-
112-
// Image datasource strings.
113-
$string['images:config:header'] = 'Images settings';
114-
$string['images:images'] = 'Images';
115-
116-
// Custom field datasource strings.
117-
$string['fields:custom_fields'] = 'Custom fields';
118-
$string['fields:config:columns'] = 'Fields and categories';
119-
$string['fields:config:header'] = 'Custom field settings';
120-
$string['fields:sample_text'] = 'text';
121-
$string['fields:sample_time'] = 'Thursday, 15 June 2023, 12:00 AM';
122-
123-
// User list datasource strings.
106+
$string['some_name'] = 'Some name';
107+
$string['table:name'] = 'Custom content type';
108+
$string['table:numinstances'] = 'Number of instances';
124109
$string['userlist:config:columns'] = 'User list columns';
125110
$string['userlist:config:header'] = 'User list settings';
126111
$string['userlist:displayname'] = 'User list';
127112
$string['userlist:listdata'] = 'List data';
128113
$string['userlist:pageheading'] = 'List definition for \'{$a}\'';
129-
130-
// Roles list datasource strings.
131-
$string['roles:displayname'] = 'Roles list';
132-
$string['roles:config:header'] = 'Role list settings';
133-
$string['roles:config:list'] = 'Roles included';
134-
$string['roles:config:duplicates'] = 'Duplicates';
135-
$string['roles:config:duplicates:all'] = 'Show in all';
136-
$string['roles:config:duplicates:firstonly'] = 'Show in first';
137-
$string['roles:config:duplicates:nest'] = 'Show in first with roles';
138-
$string['roles:error:role_does_not_exist'] = 'Role "{$a}" does nor exist.';
114+
$string['visibility_updated'] = 'Visibility updated';

tests/cms_instance_test.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @copyright 2023, Catalyst IT
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
34-
class cms_instance_test extends \advanced_testcase {
34+
final class cms_instance_test extends \advanced_testcase {
3535
use test_import1_trait;
3636

3737
/**
@@ -49,7 +49,7 @@ protected function setUp(): void {
4949
* @covers \mod_cms\local\lib::add_instance
5050
* @throws \coding_exception
5151
*/
52-
public function test_add_instance() {
52+
public function test_add_instance(): void {
5353
$cmstype = $this->import();
5454

5555
// Create a course.
@@ -80,7 +80,7 @@ public function test_add_instance() {
8080
* @covers \mod_cms\local\lib::add_instance
8181
* @throws \coding_exception
8282
*/
83-
public function test_update_instance() {
83+
public function test_update_instance(): void {
8484
$cmstype = $this->import();
8585

8686
// Create a course.
@@ -113,7 +113,7 @@ public function test_update_instance() {
113113
*
114114
* @covers \mod_cms\local\lib::delete_instance
115115
*/
116-
public function test_delete_instance() {
116+
public function test_delete_instance(): void {
117117
$cmstype = $this->import();
118118

119119
// Create a course.

tests/cms_types_test.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @copyright 2023, Catalyst IT
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
34-
class cms_types_test extends \advanced_testcase {
34+
final class cms_types_test extends \advanced_testcase {
3535
/** Test data for import/export. */
3636
public const IMPORT_DATAFILE = __DIR__ . '/fixtures/type_data.json';
3737

@@ -54,7 +54,7 @@ protected function setUp(): void {
5454
* @param string $mustache
5555
* @param bool $valid
5656
*/
57-
public function test_mustache_validity(string $field, string $mustache, bool $valid) {
57+
public function test_mustache_validity(string $field, string $mustache, bool $valid): void {
5858
$cmstype = new cms_types();
5959
$cmstype->set($field, $mustache);
6060

@@ -71,7 +71,7 @@ public function test_mustache_validity(string $field, string $mustache, bool $va
7171
*
7272
* @return array[]
7373
*/
74-
public function mustache_validity_datasource(): array {
74+
public static function mustache_validity_datasource(): array {
7575
return [
7676
['title_mustache', 'test', true],
7777
['title_mustache', '{{test}}', true],
@@ -92,7 +92,7 @@ public function mustache_validity_datasource(): array {
9292
* @param string|null $idnumber
9393
* @param bool $valid
9494
*/
95-
public function test_idnumber(?string $idnumber, bool $valid) {
95+
public function test_idnumber(?string $idnumber, bool $valid): void {
9696

9797
$cmstype = new cms_types();
9898
$cmstype->set('name', 'name');
@@ -115,7 +115,7 @@ public function test_idnumber(?string $idnumber, bool $valid) {
115115
*
116116
* @return array[]
117117
*/
118-
public function idnumber_validity_datasource(): array {
118+
public static function idnumber_validity_datasource(): array {
119119
return [
120120
[null, false],
121121
['', false],
@@ -133,7 +133,7 @@ public function idnumber_validity_datasource(): array {
133133
* @covers \mod_cms\local\model\cms_types::get_cache_key
134134
* @covers \mod_cms\local\model\cms_types::get_icon_metadata
135135
*/
136-
public function test_import() {
136+
public function test_import(): void {
137137
$importdata = json_decode(file_get_contents(self::IMPORT_DATAFILE));
138138
$cmstype = new cms_types();
139139
$cmstype->set_from_import($importdata);

0 commit comments

Comments
 (0)