Fixed canEditAnything method in EditUserJob

This commit is contained in:
Marcin Kurczewski 2014-05-12 19:39:58 +02:00
parent 3cd07a38ca
commit d8808df091
2 changed files with 14 additions and 1 deletions

View file

@ -23,7 +23,7 @@ class EditUserJob extends AbstractJob
{ {
try try
{ {
$subJob->user = $user; $subJob->setArgument(JobArgs::ARG_USER_ENTITY, $user);
Api::checkPrivileges($subJob); Api::checkPrivileges($subJob);
return true; return true;
} }

View file

@ -36,4 +36,17 @@ class EditUserJobTest extends AbstractTest
$lines = array_filter(explode("\n", $x)); $lines = array_filter(explode("\n", $x));
$this->assert->areEqual(2, count($lines)); $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));
}
} }