szurubooru/tests/JobTests/ToggleUserBanJobTest.php
2014-05-13 21:10:37 +02:00

57 lines
1.2 KiB
PHP

<?php
class ToggleUserBanJobTest extends AbstractTest
{
public function testBanning()
{
$this->grantAccess('banUser');
$user = $this->userMocker->mockSingle();
$this->login($user);
$this->assert->isFalse($user->isBanned());
$user = $this->assert->doesNotThrow(function() use ($user)
{
return Api::run(
new ToggleUserBanJob(),
[
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_STATE => 1,
]);
});
$this->assert->isTrue($user->isBanned());
}
public function testUnbanning()
{
$this->grantAccess('banUser');
$user = $this->userMocker->mockSingle();
$this->login($user);
$this->assert->isFalse($user->isBanned());
$user = $this->assert->doesNotThrow(function() use ($user)
{
return Api::run(
new ToggleUserBanJob(),
[
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_STATE => 1,
]);
});
$this->assert->isTrue($user->isBanned());
$user = $this->assert->doesNotThrow(function() use ($user)
{
return Api::run(
new ToggleUserBanJob(),
[
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_STATE => 0,
]);
});
$this->assert->isFalse($user->isBanned());
}
}