Skip to content

Commit

Permalink
fix : code style / continuous integration
Browse files Browse the repository at this point in the history
  • Loading branch information
marcghaly committed Dec 19, 2023
1 parent 7b69053 commit 16a8d97
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
4 changes: 2 additions & 2 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public static function get_notices_parameters() {
}

/**
* Gets a list of notices. local/sitenotice/tests/sitenotice_test.php
* Gets a list of notices.
* local/sitenotice/tests/sitenotice_test.php
*
* @return array
*/
Expand Down
6 changes: 3 additions & 3 deletions classes/table/acknowledged_notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class acknowledged_notice extends table_sql implements renderable {
*
* @param string $uniqueid id of the table.
* @param \moodle_url $url base url.
* @param int $noticeid notice id.
* @param array $filters filter.
* @param string $download download file format.
* @param int $page current page.
* @param int $perpage number of record per page.
* @param int $noticeid notice id.
*/
public function __construct($uniqueid, \moodle_url $url, $filters = [],
$download = '', $page = 0, $perpage = 20, $noticeid) {
public function __construct($uniqueid, \moodle_url $url, $noticeid, $filters = [],
$download = '', $page = 0, $perpage = 20) {
parent::__construct($uniqueid);

$this->set_attribute('class', 'local_sitenotice acknowledged_notices');
Expand Down
6 changes: 3 additions & 3 deletions classes/table/dismissed_notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class dismissed_notice extends table_sql implements renderable {
*
* @param string $uniqueid id of the table.
* @param \moodle_url $url base url.
* @param int $noticeid notice id.
* @param array $filters filter.
* @param string $download download file format.
* @param int $page current page.
* @param int $perpage number of record per page.
* @param int $noticeid notice id.
*/
public function __construct($uniqueid, \moodle_url $url, $filters = [], $download = '',
$page = 0, $perpage = 20, $noticeid) {
public function __construct($uniqueid, \moodle_url $url, $noticeid, $filters = [], $download = '',
$page = 0, $perpage = 20) {
parent::__construct($uniqueid);

$this->set_attribute('class', 'local_sitenotice dismissed_notices');
Expand Down
4 changes: 2 additions & 2 deletions report/acknowledged_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
$filter = new report_filter($thispage, \local_sitenotice\table\acknowledged_notice::TABLE_ALIAS);
list($filtersql, $params) = $filter->get_sql_filter();

$table = new acknowledged_notice('acknowledged_notice_table', $thispage, ['filtersql' => $filtersql, 'params' => $params],
$download, $page, 20, $notice->id);
$table = new acknowledged_notice('acknowledged_notice_table', $thispage, $notice->id, ['filtersql' => $filtersql, 'params' => $params],
$download, $page, 20);

if ($table->is_downloading()) {
\core\session\manager::write_close();
Expand Down
4 changes: 2 additions & 2 deletions report/dismissed_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
$filter = new report_filter($thispage, dismissed_notice::TABLE_ALIAS);
list($filtersql, $params) = $filter->get_sql_filter();

$table = new dismissed_notice('dismissed_notice_table', $thispage, ['filtersql' => $filtersql, 'params' => $params],
$download, $page, 20, $notice->id);
$table = new dismissed_notice('dismissed_notice_table', $thispage, $notice->id, ['filtersql' => $filtersql, 'params' => $params],
$download, $page, 20);
if ($table->is_downloading()) {
\core\session\manager::write_close();
echo $output->render($table);
Expand Down
8 changes: 8 additions & 0 deletions tests/helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class helper_test extends \advanced_testcase {

/**
* Test a list of cohorts is built properly.
*
* @covers ::built_cohorts_options
*/
public function test_built_cohort_options() {
$this->resetAfterTest(true);
Expand All @@ -48,6 +50,8 @@ public function test_built_cohort_options() {

/**
* Test that we can have full HTML in a notice content.
*
* @covers ::get_all_notices
*/
public function test_can_have_html_in_notice_content() {
$this->resetAfterTest();
Expand Down Expand Up @@ -75,6 +79,8 @@ public function test_can_have_html_in_notice_content() {

/**
* Test time interval format.
*
* @covers ::format_interval_time
*/
public function test_format_interval_time() {
// The interval is 1 day(s) 2 hour(s) 3 minute(s) 4 second(s).
Expand All @@ -86,6 +92,8 @@ public function test_format_interval_time() {

/**
* Test cohorts options.
*
* @covers ::built_cohorts_options
*/
public function test_cohort_options() {
$this->resetAfterTest();
Expand Down
24 changes: 21 additions & 3 deletions tests/sitenotice_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function setUp(): void {
/**
* Test notice creation.
*
* @covers ::create_new_notice
* @dataProvider create_notices_provider
* @param array $formdata Array of form data to create notices
* @param bool $allowdeletion Whether or not to allow deletion of notices
Expand Down Expand Up @@ -84,6 +85,7 @@ public function test_create_notices(array $formdata, bool $allowdeletion, bool $
/**
* Test set reset notice.
*
* @covers ::reset_notices
* @dataProvider generic_provider()
* @param array $formdata Array of form data to create notices
*/
Expand Down Expand Up @@ -117,6 +119,7 @@ public function test_reset_notices(array $formdata) {
/**
* Test enable/disable notice.
*
* @covers ::test_enable_notices
* @dataProvider generic_provider()
* @param array $formdata Array of form data to create notices
*/
Expand Down Expand Up @@ -153,6 +156,7 @@ public function test_enable_notices(array $formdata) {
/**
* Test user notice interaction.
*
* @covers ::test_user_notice
* @dataProvider generic_provider()
* @param array $formdata Data to test on.
*/
Expand Down Expand Up @@ -226,6 +230,7 @@ public function test_user_notice($formdata) {
/**
* Test user link interaction
*
* @covers ::user_hlink_interact
* @dataProvider generic_provider()
* @param array $formdata Data to test on.
*/
Expand Down Expand Up @@ -259,14 +264,17 @@ public function test_user_hlink_interact($formdata) {

/**
* Test course completion option.
*
* @covers ::retrieve_user_notices
*/
public function test_user_required_completion() {
global $DB;
$this->setAdminUser();

$formdata = new \stdClass();
$formdata->title = "Course Notice 1";
$formdata->content = "Course Notice 1 <a href=\"www.examplecourse1.com\">Link Course 1</a> <a href=\"www.examplecourse2.com\">Link Course 2</a>";
$formdata->content = "Course Notice 1 <a href=\"www.examplecourse1.com\">Link Course 1</a>" .
" <a href=\"www.examplecourse2.com\">Link Course 2</a>";

// Create a course with completion enabled.
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
Expand Down Expand Up @@ -315,6 +323,8 @@ public function test_user_required_completion() {

/**
* Test user see required notice after dismissing it.
*
* @covers ::retrieve_user_notices
*/
public function test_retrieve_user_notices_when_dismissed_one_that_requires_acknowledgement() {
$this->resetAfterTest();
Expand Down Expand Up @@ -342,6 +352,8 @@ public function test_retrieve_user_notices_when_dismissed_one_that_requires_ackn

/**
* Test user see required notice after dismissing, and then acknowledged it.
*
* @covers ::retrieve_user_notices
*/
public function test_retrieve_user_notices_when_dismiss_and_then_acknowledged() {
$this->resetAfterTest();
Expand Down Expand Up @@ -379,6 +391,8 @@ public function test_retrieve_user_notices_when_dismiss_and_then_acknowledged()

/**
* Test user see required notice when forcelogout logout.
*
* @covers ::retrieve_user_notices
*/
public function test_retrieve_user_notices_when_force_logout() {
global $USER;
Expand Down Expand Up @@ -530,8 +544,12 @@ public function create_notices_provider(): array {
'titles' => ['Notice 1', 'Notice 2', 'Notice 3'],
'linkcounts' => [2, 2, 2],
'linktexts' => [['Link 1', 'Link 2'], ['Link 1', 'Link 4'], ['Link 1', 'Link 4']],
'linkurls' => [['www.example1.com', 'www.example2.com'], ['www.example1.com', 'www.example2.com'], ['www.example1.com', 'www.example2.com']]
]
'linkurls' => [
['www.example1.com', 'www.example2.com'],
['www.example1.com', 'www.example2.com'],
['www.example1.com', 'www.example2.com'],
],
],
],
'two basic notices and one notice with expiry in the past' => [
'formdata' => [
Expand Down

0 comments on commit 16a8d97

Please sign in to comment.