Permalink
Browse files

Merge branch 'MDL-62056-master' of git://github.com/sarjona/moodle

  • Loading branch information...
dmonllao authored and junpataleta committed May 9, 2018
2 parents 06ede94 + fd7174d commit 337673949b963692767643da80e405df49294c20
@@ -155,12 +155,13 @@ public function export_for_template(renderer_base $output) {
$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);
@@ -112,7 +112,7 @@ public function test_export_own_agreements() {
// 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 @@ public function test_export_own_agreements() {
// 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 @@ public function test_export_own_agreements() {
$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 @@ public function test_export_agreements_on_behalf() {
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 @@ public function test_export_agreements_on_behalf() {
$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,15 +200,15 @@ public function test_export_agreements_on_behalf() {
// 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);
$this->assertEquals($admin->id, $dataadmin['policyagreement-'.$policy2->get('id')]->usermodified);
$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);

0 comments on commit 3376739

Please sign in to comment.