From d8808df091e0cba22705d82e35013fb1795dbb4f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 12 May 2014 19:39:58 +0200 Subject: [PATCH] Fixed canEditAnything method in EditUserJob --- src/Api/Jobs/UserJobs/EditUserJob.php | 2 +- tests/JobTests/EditUserJobTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Api/Jobs/UserJobs/EditUserJob.php b/src/Api/Jobs/UserJobs/EditUserJob.php index bdc8727b..ed494e49 100644 --- a/src/Api/Jobs/UserJobs/EditUserJob.php +++ b/src/Api/Jobs/UserJobs/EditUserJob.php @@ -23,7 +23,7 @@ class EditUserJob extends AbstractJob { try { - $subJob->user = $user; + $subJob->setArgument(JobArgs::ARG_USER_ENTITY, $user); Api::checkPrivileges($subJob); return true; } diff --git a/tests/JobTests/EditUserJobTest.php b/tests/JobTests/EditUserJobTest.php index 55fb8985..1caba0c9 100644 --- a/tests/JobTests/EditUserJobTest.php +++ b/tests/JobTests/EditUserJobTest.php @@ -36,4 +36,17 @@ class EditUserJobTest extends AbstractTest $lines = array_filter(explode("\n", $x)); $this->assert->areEqual(2, count($lines)); } + + public function testCanEditSomething() + { + $this->grantAccess('changeUserName.own'); + $user = $this->mockUser(); + $user = $this->assert->isTrue((new EditUserJob())->canEditAnything($user)); + } + + public function testCannotEditAnything() + { + $user = $this->mockUser(); + $user = $this->assert->isFalse((new EditUserJob())->canEditAnything($user)); + } }