diff --git a/classes/cohortmembersync.php b/classes/cohortmembersync.php index c804a43..0d006fc 100644 --- a/classes/cohortmembersync.php +++ b/classes/cohortmembersync.php @@ -226,7 +226,7 @@ protected function process_file() { } // Check correct formatting of operation field. - if ($fields[0] !== "add" and $fields[0] !== "del") { + if ($fields[0] !== "add" && $fields[0] !== "del") { $this->warnings[] = "Unknown operation in field 1 - ignoring line $line"; continue; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 4b95c7c..51fe0a5 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace tool_cohortsync\privacy; -defined('MOODLE_INTERNAL') || die(); /** * Provider for tool_cohortsync. diff --git a/db/access.php b/db/access.php index a815825..a625fca 100644 --- a/db/access.php +++ b/db/access.php @@ -23,5 +23,3 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - diff --git a/tests/cohortmembersync_test.php b/tests/cohortmembersync_test.php index ec182a3..423938d 100644 --- a/tests/cohortmembersync_test.php +++ b/tests/cohortmembersync_test.php @@ -22,8 +22,7 @@ * @author Issam Taboubi * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use tool_cohortsync\cohortmembersync; - +namespace tool_cohortsync; defined('MOODLE_INTERNAL') || die(); @@ -39,7 +38,7 @@ * @author Issam Taboubi * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class tool_cohortmembersync_testcase extends advanced_testcase { +class cohortmembersync_test extends \advanced_testcase { /** @var progress_trace trace */ protected $trace = null; @@ -88,8 +87,8 @@ public function setUp(): void { $this->cat1 = $this->getDataGenerator()->create_category(array('name' => 'CAT1')); $this->cat2 = $this->getDataGenerator()->create_category(array('name' => 'CAT2')); - $this->contextcat1 = context_coursecat::instance($this->cat1->id); - $this->contextcat2 = context_coursecat::instance($this->cat2->id); + $this->contextcat1 = \context_coursecat::instance($this->cat1->id); + $this->contextcat2 = \context_coursecat::instance($this->cat2->id); $this->cohort1 = $this->getDataGenerator()->create_cohort(array( 'name' => 'Cohort1', diff --git a/tests/cohortsync_test.php b/tests/cohortsync_test.php index 715166b..5c2abe5 100644 --- a/tests/cohortsync_test.php +++ b/tests/cohortsync_test.php @@ -22,8 +22,7 @@ * @author Issam Taboubi * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use tool_cohortsync\cohortsync; - +namespace tool_cohortsync; defined('MOODLE_INTERNAL') || die(); @@ -39,7 +38,7 @@ * @author Issam Taboubi * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class tool_cohortsync_testcase extends advanced_testcase { +class cohortsync_test extends \advanced_testcase { /** @var progress_trace trace */ protected $trace = null; @@ -99,8 +98,8 @@ public function test_cohortsync_with_column_category_as_name() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -138,8 +137,8 @@ public function test_cohortsync_with_column_category_as_id() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -176,8 +175,8 @@ public function test_cohortsync_with_column_category_as_idnumber() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -193,8 +192,8 @@ public function test_cohortsync_with_column_contextid() { $cat1 = $this->getDataGenerator()->create_category(array('name' => 'CAT1')); $cat2 = $this->getDataGenerator()->create_category(array('name' => 'CAT2')); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $cohorts = array(); $cohorts[] = array('cohort name 1', 'cohortid1', 'first description', 1, $contextcat1->id); @@ -252,8 +251,8 @@ public function test_cohortsync_with_column_category_id() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -290,8 +289,8 @@ public function test_cohortsync_with_column_category_idnumber() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -328,8 +327,8 @@ public function test_cohortsync_with_column_category_path() { $this->assertEquals('cohortid2', $cohort2->idnumber); $this->assertEquals('cohortid3', $cohort3->idnumber); - $contextcat1 = context_coursecat::instance($cat1->id); - $contextcat2 = context_coursecat::instance($cat2->id); + $contextcat1 = \context_coursecat::instance($cat1->id); + $contextcat2 = \context_coursecat::instance($cat2->id); $this->assertEquals($contextcat1->id, $cohort1->contextid); $this->assertEquals($contextcat2->id, $cohort2->contextid); @@ -343,7 +342,7 @@ public function test_cohortsync_with_defaultcontext() { global $DB; $defaultcat = $this->getDataGenerator()->create_category(array('name' => 'DEFAULTCAT')); - $contextdefault = context_coursecat::instance($defaultcat->id); + $contextdefault = \context_coursecat::instance($defaultcat->id); $cohorts = array(); $cohorts[] = array('cohort name 1', 'cohortid1', 'first description', 1); @@ -385,7 +384,7 @@ public function test_cohortsync_no_defaultcontext() { $this->assertEquals('cohortid1', $cohort1->idnumber); - $contextsystem = context_system::instance(); + $contextsystem = \context_system::instance(); $this->assertEquals($contextsystem->id, $cohort1->contextid); } @@ -488,7 +487,7 @@ public function test_cohortsync_warnings_when_notfoundcategory() { $cohort1 = $DB->get_record('cohort', array('idnumber' => 'cohortid1')); $this->assertEquals('cohortid1', $cohort1->idnumber); - $contextsystem = context_system::instance(); + $contextsystem = \context_system::instance(); $this->assertEquals($contextsystem->id, $cohort1->contextid); }