4ba83e6834
Restored JobArgs approach. Previous introduction of hierarchic argument definitions has backfired: it was confusing what class to take arguments from, the concept of sharing arguments between different jobs was unintelligible and one never knew where given argument was actually defined. This appraoch makes it easier to maintain the arguments list and simplifies the code a lot.
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?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(),
|
|
[
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
JobArgs::ARG_NEW_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(),
|
|
[
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
JobArgs::ARG_NEW_STATE => 0,
|
|
]);
|
|
});
|
|
|
|
$this->assert->isTrue($post->isHidden());
|
|
|
|
$post = $this->assert->doesNotThrow(function() use ($post)
|
|
{
|
|
return Api::run(
|
|
new TogglePostVisibilityJob(),
|
|
[
|
|
JobArgs::ARG_POST_ID => $post->getId(),
|
|
JobArgs::ARG_NEW_STATE => 1,
|
|
]);
|
|
});
|
|
|
|
$this->assert->isFalse($post->isHidden());
|
|
}
|
|
}
|