szurubooru/tests/JobTests/TogglePostVisibilityJobTest.php

58 lines
1.3 KiB
PHP
Raw Normal View History

2014-05-09 21:08:13 +02:00
<?php
class TogglePostVisibilityJobTest extends AbstractTest
{
public function testHiding()
{
$this->grantAccess('hidePost');
$this->login($this->mockUser());
$post = $this->mockPost(Auth::getCurrentUser());
$this->assert->isFalse($post->isHidden());
$post = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 0,
]);
});
$this->assert->isTrue($post->isHidden());
}
public function testShowing()
{
$this->grantAccess('hidePost');
$this->login($this->mockUser());
$post = $this->mockPost(Auth::getCurrentUser());
$this->assert->isFalse($post->isHidden());
$post = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 0,
]);
});
$this->assert->isTrue($post->isHidden());
$post = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 1,
]);
});
$this->assert->isFalse($post->isHidden());
}
}