2014-05-09 21:08:13 +02:00
|
|
|
<?php
|
|
|
|
class TogglePostVisibilityJobTest extends AbstractTest
|
|
|
|
{
|
|
|
|
public function testHiding()
|
|
|
|
{
|
|
|
|
$this->grantAccess('hidePost');
|
2014-05-13 21:08:07 +02:00
|
|
|
$this->login($this->userMocker->mockSingle());
|
|
|
|
$post = $this->postMocker->mockSingle();
|
2014-05-09 21:08:13 +02:00
|
|
|
|
|
|
|
$this->assert->isFalse($post->isHidden());
|
|
|
|
|
|
|
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
|
|
|
{
|
|
|
|
return Api::run(
|
|
|
|
new TogglePostVisibilityJob(),
|
|
|
|
[
|
2014-05-12 00:13:18 +02:00
|
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
|
|
JobArgs::ARG_NEW_STATE => 0,
|
2014-05-09 21:08:13 +02:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->isTrue($post->isHidden());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testShowing()
|
|
|
|
{
|
|
|
|
$this->grantAccess('hidePost');
|
2014-05-13 21:08:07 +02:00
|
|
|
$this->login($this->userMocker->mockSingle());
|
|
|
|
$post = $this->postMocker->mockSingle();
|
2014-05-09 21:08:13 +02:00
|
|
|
|
|
|
|
$this->assert->isFalse($post->isHidden());
|
|
|
|
|
|
|
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
|
|
|
{
|
|
|
|
return Api::run(
|
|
|
|
new TogglePostVisibilityJob(),
|
|
|
|
[
|
2014-05-12 00:13:18 +02:00
|
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
|
|
JobArgs::ARG_NEW_STATE => 0,
|
2014-05-09 21:08:13 +02:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->isTrue($post->isHidden());
|
|
|
|
|
|
|
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
|
|
|
{
|
|
|
|
return Api::run(
|
|
|
|
new TogglePostVisibilityJob(),
|
|
|
|
[
|
2014-05-12 00:13:18 +02:00
|
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
|
|
JobArgs::ARG_NEW_STATE => 1,
|
2014-05-09 21:08:13 +02:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->isFalse($post->isHidden());
|
|
|
|
}
|
|
|
|
}
|