Merge branch 'MDL-62056-master' of git://github.com/sarjona/moodle
authorDavid Monllao <davidm@moodle.com>
Wed, 9 May 2018 13:20:46 +0000 (15:20 +0200)
committerJun Pataleta <jun@moodle.com>
Thu, 10 May 2018 01:17:28 +0000 (09:17 +0800)
admin/tool/policy/classes/output/page_viewdoc.php
admin/tool/policy/tests/privacy_provider_test.php

index b16a4e7..95613a7 100644 (file)
@@ -155,12 +155,13 @@ class page_viewdoc implements renderable, templatable {
         $data = (object) [
             'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false),
             'returnurl' => $this->returnurl ? (new moodle_url($this->returnurl))->out(false) : null,
-            'editurl' => ($this->manage && $this->policy->status != policy_version::STATUS_ARCHIVED) ?
-                (new moodle_url('/admin/tool/policy/editpolicydoc.php',
-                ['policyid' => $this->policy->policyid, 'versionid' => $this->policy->id]))->out(false) : null,
             'numpolicy' => $this->numpolicy ? : null,
             'totalpolicies' => $this->totalpolicies ? : null,
         ];
+        if ($this->manage && $this->policy->status != policy_version::STATUS_ARCHIVED) {
+            $paramsurl = ['policyid' => $this->policy->policyid, 'versionid' => $this->policy->id];
+            $data->editurl = (new moodle_url('/admin/tool/policy/editpolicydoc.php', $paramsurl))->out(false);
+        }
 
         $data->policy = clone($this->policy);
 
index ce0d0a6..d392cc1 100644 (file)
@@ -112,7 +112,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
         // Create policies and agree to them as admin.
         $this->setAdminUser();
         $admin = fullclone($USER);
-        $admincontext = context_user::instance($admin->id);
+        $admincontext = \context_user::instance($admin->id);
         $CFG->sitepolicyhandler = 'tool_policy';
         $policy1 = $this->add_policy();
         api::make_current($policy1->get('id'));
@@ -122,7 +122,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
 
         // Agree to the policies for oneself.
         $this->setUser($this->user);
-        $usercontext = context_user::instance($this->user->id);
+        $usercontext = \context_user::instance($this->user->id);
         api::accept_policies([$policy1->get('id'), $policy2->get('id')]);
 
         // Request export for this user.
@@ -139,7 +139,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
 
         $writer = writer::with_context($usercontext);
         $datauser = $writer->get_related_data([get_string('userpoliciesagreements', 'tool_policy'), $this->user->id]);
-        $this->assertEquals(2, count($datauser));
+        $this->assertCount(2, (array) $datauser);
         $this->assertEquals($policy1->get('name'), $datauser['policyagreement-'.$policy1->get('id')]->name);
         $this->assertEquals($this->user->id, $datauser['policyagreement-'.$policy1->get('id')]->usermodified);
         $this->assertEquals($policy2->get('name'), $datauser['policyagreement-'.$policy2->get('id')]->name);
@@ -159,8 +159,8 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
         api::make_current($policy2->get('id'));
 
         // Agree to the policies for oneself and for another user.
-        $usercontext = context_user::instance($this->user->id);
-        $admincontext = context_user::instance($USER->id);
+        $usercontext = \context_user::instance($this->user->id);
+        $admincontext = \context_user::instance($USER->id);
         api::accept_policies([$policy1->get('id'), $policy2->get('id')]);
         api::accept_policies([$policy1->get('id'), $policy2->get('id')], $this->user->id, 'Mynote');
 
@@ -181,7 +181,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
 
         $writer = writer::with_context($usercontext);
         $datauser = $writer->get_related_data([get_string('userpoliciesagreements', 'tool_policy'), $this->user->id]);
-        $this->assertEquals(2, count($datauser));
+        $this->assertCount(2, (array) $datauser);
         $this->assertEquals($policy1->get('name'), $datauser['policyagreement-'.$policy1->get('id')]->name);
         $this->assertEquals($admin->id, $datauser['policyagreement-'.$policy1->get('id')]->usermodified);
         $this->assertEquals('Mynote', $datauser['policyagreement-'.$policy1->get('id')]->note);
@@ -200,7 +200,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
         // Admin can see all four agreements.
         $writer = writer::with_context($admincontext);
         $dataadmin = $writer->get_related_data([get_string('userpoliciesagreements', 'tool_policy'), $admin->id]);
-        $this->assertEquals(2, count($dataadmin));
+        $this->assertCount(2, (array) $dataadmin);
         $this->assertEquals($policy1->get('name'), $dataadmin['policyagreement-'.$policy1->get('id')]->name);
         $this->assertEquals($admin->id, $dataadmin['policyagreement-'.$policy1->get('id')]->usermodified);
         $this->assertEquals($policy2->get('name'), $dataadmin['policyagreement-'.$policy2->get('id')]->name);
@@ -208,7 +208,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
 
         $writer = writer::with_context($usercontext);
         $datauser = $writer->get_related_data([get_string('userpoliciesagreements', 'tool_policy'), $this->user->id]);
-        $this->assertEquals(2, count($datauser));
+        $this->assertCount(2, (array) $datauser);
         $this->assertEquals($policy1->get('name'), $datauser['policyagreement-'.$policy1->get('id')]->name);
         $this->assertEquals($admin->id, $datauser['policyagreement-'.$policy1->get('id')]->usermodified);
         $this->assertEquals('Mynote', $datauser['policyagreement-'.$policy1->get('id')]->note);