Changed job arguments convention back

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.
This commit is contained in:
Marcin Kurczewski 2014-05-12 00:13:18 +02:00
parent 8aa499a0b9
commit 4ba83e6834
66 changed files with 381 additions and 392 deletions

View file

@ -5,25 +5,6 @@ abstract class AbstractJob
const CONTEXT_BATCH_EDIT = 2;
const CONTEXT_BATCH_ADD = 3;
const COMMENT_ID = 'comment-id';
const LOG_ID = 'log-id';
const POST_ENTITY = 'post';
const POST_ID = 'post-id';
const POST_NAME = 'post-name';
const TAG_NAME = 'tag-name';
const TAG_NAMES = 'tags';
const USER_ENTITY = 'user';
const USER_ID = 'user-id';
const USER_NAME = 'user-name';
const PAGE_NUMBER = 'page-number';
const TEXT = 'text';
const QUERY = 'query';
const STATE = 'state';
protected $arguments = [];
protected $context = self::CONTEXT_NORMAL;

View file

@ -5,13 +5,13 @@ abstract class AbstractPostJob extends AbstractJob
public function prepare()
{
if ($this->hasArgument(self::POST_ENTITY))
if ($this->hasArgument(JobArgs::ARG_POST_ENTITY))
{
$this->post = $this->getArgument(self::POST_ENTITY);
$this->post = $this->getArgument(JobArgs::ARG_POST_ENTITY);
}
else
{
$postId = $this->getArgument(self::POST_ID);
$postId = $this->getArgument(JobArgs::ARG_POST_ID);
$this->post = PostModel::getByIdOrName($postId);
}
}

View file

@ -5,13 +5,13 @@ abstract class AbstractUserJob extends AbstractJob
public function prepare()
{
if ($this->hasArgument(self::USER_ENTITY))
if ($this->hasArgument(JobArgs::ARG_USER_ENTITY))
{
$this->user = $this->getArgument(self::USER_ENTITY);
$this->user = $this->getArgument(JobArgs::ARG_USER_ENTITY);
}
else
{
$userName = $this->getArgument(self::USER_NAME);
$userName = $this->getArgument(JobArgs::ARG_USER_NAME);
$this->user = UserModel::getByNameOrEmail($userName);
}
}

47
src/Api/JobArgs.php Normal file
View file

@ -0,0 +1,47 @@
<?php
class JobArgs
{
const ARG_ANONYMOUS = 'anonymous';
const ARG_PAGE_NUMBER = 'page-number';
const ARG_QUERY = 'query';
const ARG_TOKEN = 'token';
const ARG_USER_ENTITY = 'user';
const ARG_USER_ID = 'user-id';
const ARG_USER_NAME = 'user-name';
const ARG_POST_ENTITY = 'post';
const ARG_POST_ID = 'post-id';
const ARG_POST_NAME = 'post-name';
const ARG_TAG_NAME = 'tag-name';
const ARG_TAG_NAMES = 'tag-names';
const ARG_COMMENT_ID = 'comment-id';
const ARG_LOG_ID = 'log-id';
const ARG_THUMB_WIDTH = 'thumb-width';
const ARG_THUMB_HEIGHT = 'thumb-height';
const ARG_NEW_TEXT = 'new-text';
const ARG_NEW_STATE = 'new-state';
const ARG_NEW_POST_CONTENT = 'new-post-content';
const ARG_NEW_POST_CONTENT_URL = 'new-post-content-url';
const ARG_NEW_RELATED_POST_IDS = 'new-related-post-ids';
const ARG_NEW_SAFETY = 'new-safety';
const ARG_NEW_SOURCE = 'new-source';
const ARG_NEW_THUMB_CONTENT = 'new-thumb-content';
const ARG_NEW_TAG_NAMES = 'new-tag-names';
const ARG_NEW_POST_SCORE = 'new-post-score';
const ARG_SOURCE_TAG_NAME = 'source-tag-name';
const ARG_TARGET_TAG_NAME = 'target-tag-name';
const ARG_NEW_ACCESS_RANK = 'new-access-rank';
const ARG_NEW_EMAIL = 'new-email';
const ARG_NEW_USER_NAME = 'new-user-name';
const ARG_NEW_PASSWORD = 'new-password';
}

View file

@ -1,13 +1,11 @@
<?php
class ActivateUserEmailJob extends AbstractJob
{
const TOKEN = 'token';
public function execute()
{
if (!$this->hasArgument(self::TOKEN))
if (!$this->hasArgument(JobArgs::ARG_TOKEN))
{
$user = UserModel::getByNameOrEmail($this->getArgument(self::USER_NAME));
$user = UserModel::getByNameOrEmail($this->getArgument(JobArgs::ARG_USER_NAME));
if (empty($user->getUnconfirmedEmail()))
{
@ -23,7 +21,7 @@ class ActivateUserEmailJob extends AbstractJob
}
else
{
$tokenText = $this->getArgument(self::TOKEN);
$tokenText = $this->getArgument(JobArgs::ARG_TOKEN);
$token = TokenModel::getByToken($tokenText);
TokenModel::checkValidity($token);

View file

@ -4,8 +4,8 @@ class AddCommentJob extends AbstractJob
public function execute()
{
$user = Auth::getCurrentUser();
$post = PostModel::getById($this->getArgument(self::POST_ID));
$text = $this->getArgument(self::TEXT);
$post = PostModel::getById($this->getArgument(JobArgs::ARG_POST_ID));
$text = $this->getArgument(JobArgs::ARG_NEW_TEXT);
$comment = CommentModel::spawn();
$comment->setCommenter($user);

View file

@ -1,21 +1,19 @@
<?php
class AddPostJob extends AbstractJob
{
const ANONYMOUS = 'anonymous';
public function execute()
{
$post = PostModel::spawn();
$anonymous = $this->hasArgument(self::ANONYMOUS)
and $this->getArgument(self::ANONYMOUS);
$anonymous = $this->hasArgument(JobArgs::ARG_ANONYMOUS)
and $this->getArgument(JobArgs::ARG_ANONYMOUS);
if (Auth::isLoggedIn() and !$anonymous)
$post->setUploader(Auth::getCurrentUser());
PostModel::forgeId($post);
$arguments = $this->getArguments();
$arguments[EditPostJob::POST_ENTITY] = $post;
$arguments[JobArgs::ARG_POST_ENTITY] = $post;
Logger::bufferChanges();
try

View file

@ -20,7 +20,7 @@ class AddUserJob extends AbstractJob
}
$arguments = $this->getArguments();
$arguments[EditUserJob::USER_ENTITY] = $user;
$arguments[JobArgs::ARG_USER_ENTITY] = $user;
Logger::bufferChanges();
try

View file

@ -5,7 +5,7 @@ class DeleteCommentJob extends AbstractJob
public function prepare()
{
$this->comment = CommentModel::getById($this->getArgument(self::COMMENT_ID));
$this->comment = CommentModel::getById($this->getArgument(JobArgs::ARG_COMMENT_ID));
}
public function execute()

View file

@ -5,7 +5,7 @@ class EditCommentJob extends AbstractJob
public function prepare()
{
$this->comment = CommentModel::getById($this->getArgument(self::COMMENT_ID));
$this->comment = CommentModel::getById($this->getArgument(JobArgs::ARG_COMMENT_ID));
}
public function execute()
@ -13,7 +13,7 @@ class EditCommentJob extends AbstractJob
$comment = $this->comment;
$comment->setCreationTime(time());
$comment->setText($this->getArgument(self::TEXT));
$comment->setText($this->getArgument(JobArgs::ARG_NEW_TEXT));
CommentModel::save($comment);
Logger::log('{user} edited comment in {post}', [

View file

@ -1,27 +1,24 @@
<?php
class EditPostContentJob extends AbstractPostJob
{
const POST_CONTENT = 'post-content';
const POST_CONTENT_URL = 'post-content-url';
public function isSatisfied()
{
return $this->hasArgument(self::POST_CONTENT)
or $this->hasArgument(self::POST_CONTENT_URL);
return $this->hasArgument(JobArgs::ARG_NEW_POST_CONTENT)
or $this->hasArgument(JobArgs::ARG_NEW_POST_CONTENT_URL);
}
public function execute()
{
$post = $this->post;
if ($this->hasArgument(self::POST_CONTENT_URL))
if ($this->hasArgument(JobArgs::ARG_NEW_POST_CONTENT_URL))
{
$url = $this->getArgument(self::POST_CONTENT_URL);
$url = $this->getArgument(JobArgs::ARG_NEW_POST_CONTENT_URL);
$post->setContentFromUrl($url);
}
else
{
$file = $this->getArgument(self::POST_CONTENT);
$file = $this->getArgument(JobArgs::ARG_NEW_POST_CONTENT);
$post->setContentFromPath($file->filePath, $file->fileName);
}

View file

@ -24,7 +24,7 @@ class EditPostJob extends AbstractPostJob
: self::CONTEXT_BATCH_EDIT);
$args = $this->getArguments();
$args[self::POST_ENTITY] = $post;
$args[JobArgs::ARG_POST_ENTITY] = $post;
try
{
Api::run($subJob, $args);

View file

@ -1,17 +1,15 @@
<?php
class EditPostRelationsJob extends AbstractPostJob
{
const RELATED_POST_IDS = 'related-post-ids';
public function isSatisfied()
{
return $this->hasArgument(self::RELATED_POST_IDS);
return $this->hasArgument(JobArgs::ARG_NEW_RELATED_POST_IDS);
}
public function execute()
{
$post = $this->post;
$relations = $this->getArgument(self::RELATED_POST_IDS);
$relations = $this->getArgument(JobArgs::ARG_NEW_RELATED_POST_IDS);
$oldRelatedIds = array_map(function($post) { return $post->getId(); }, $post->getRelations());
$post->setRelationsFromText($relations);

View file

@ -1,17 +1,15 @@
<?php
class EditPostSafetyJob extends AbstractPostJob
{
const SAFETY = 'safety';
public function isSatisfied()
{
return $this->hasArgument(self::SAFETY);
return $this->hasArgument(JobArgs::ARG_NEW_SAFETY);
}
public function execute()
{
$post = $this->post;
$newSafety = new PostSafety($this->getArgument(self::SAFETY));
$newSafety = new PostSafety($this->getArgument(JobArgs::ARG_NEW_SAFETY));
$oldSafety = $post->getSafety();
$post->setSafety($newSafety);

View file

@ -1,17 +1,15 @@
<?php
class EditPostSourceJob extends AbstractPostJob
{
const SOURCE = 'source';
public function isSatisfied()
{
return $this->hasArgument(self::SOURCE);
return $this->hasArgument(JobArgs::ARG_NEW_SOURCE);
}
public function execute()
{
$post = $this->post;
$newSource = $this->getArgument(self::SOURCE);
$newSource = $this->getArgument(JobArgs::ARG_NEW_SOURCE);
$oldSource = $post->getSource();
$post->setSource($newSource);

View file

@ -3,13 +3,13 @@ class EditPostTagsJob extends AbstractPostJob
{
public function isSatisfied()
{
return $this->hasArgument(self::TAG_NAMES);
return $this->hasArgument(JobArgs::ARG_NEW_TAG_NAMES);
}
public function execute()
{
$post = $this->post;
$tagNames = $this->getArgument(self::TAG_NAMES);
$tagNames = $this->getArgument(JobArgs::ARG_NEW_TAG_NAMES);
if (!is_array($tagNames))
throw new SimpleException('Expected array');

View file

@ -1,17 +1,15 @@
<?php
class EditPostThumbJob extends AbstractPostJob
{
const THUMB_CONTENT = 'thumb-content';
public function isSatisfied()
{
return $this->hasArgument(self::THUMB_CONTENT);
return $this->hasArgument(JobArgs::ARG_NEW_THUMB_CONTENT);
}
public function execute()
{
$post = $this->post;
$file = $this->getArgument(self::THUMB_CONTENT);
$file = $this->getArgument(JobArgs::ARG_NEW_THUMB_CONTENT);
$post->setCustomThumbnailFromPath($file->filePath);

View file

@ -1,17 +1,15 @@
<?php
class EditUserAccessRankJob extends AbstractUserJob
{
const NEW_ACCESS_RANK = 'new-access-rank';
public function isSatisfied()
{
return $this->hasArgument(self::NEW_ACCESS_RANK);
return $this->hasArgument(JobArgs::ARG_NEW_ACCESS_RANK);
}
public function execute()
{
$user = $this->user;
$newAccessRank = new AccessRank($this->getArgument(self::NEW_ACCESS_RANK));
$newAccessRank = new AccessRank($this->getArgument(JobArgs::ARG_NEW_ACCESS_RANK));
$oldAccessRank = $user->getAccessRank();
if ($oldAccessRank == $newAccessRank)

View file

@ -1,21 +1,19 @@
<?php
class EditUserEmailJob extends AbstractUserJob
{
const NEW_EMAIL = 'new-email';
public function isSatisfied()
{
return $this->hasArgument(self::NEW_EMAIL);
return $this->hasArgument(JobArgs::ARG_NEW_EMAIL);
}
public function execute()
{
if (getConfig()->registration->needEmailForRegistering)
if (!$this->hasArgument(self::NEW_EMAIL) or empty($this->getArgument(self::NEW_EMAIL)))
if (!$this->hasArgument(JobArgs::ARG_NEW_EMAIL) or empty($this->getArgument(JobArgs::ARG_NEW_EMAIL)))
throw new SimpleException('E-mail address is required - you will be sent confirmation e-mail.');
$user = $this->user;
$newEmail = $this->getArgument(self::NEW_EMAIL);
$newEmail = $this->getArgument(JobArgs::ARG_NEW_EMAIL);
$oldEmail = $user->getConfirmedEmail();
if ($oldEmail == $newEmail)

View file

@ -45,7 +45,7 @@ class EditUserJob extends AbstractUserJob
: self::CONTEXT_BATCH_EDIT);
$args = $this->getArguments();
$args[self::USER_ENTITY] = $user;
$args[JobArgs::ARG_USER_ENTITY] = $user;
try
{
Api::run($subJob, $args);

View file

@ -1,17 +1,15 @@
<?php
class EditUserNameJob extends AbstractUserJob
{
const NEW_USER_NAME = 'new-user-name';
public function isSatisfied()
{
return $this->hasArgument(self::NEW_USER_NAME);
return $this->hasArgument(JobArgs::ARG_NEW_USER_NAME);
}
public function execute()
{
$user = $this->user;
$newName = $this->getArgument(self::NEW_USER_NAME);
$newName = $this->getArgument(JobArgs::ARG_NEW_USER_NAME);
$oldName = $user->getName();
if ($oldName == $newName)

View file

@ -1,17 +1,15 @@
<?php
class EditUserPasswordJob extends AbstractUserJob
{
const NEW_PASSWORD = 'new-password';
public function isSatisfied()
{
return $this->hasArgument(self::NEW_PASSWORD);
return $this->hasArgument(JobArgs::ARG_NEW_PASSWORD);
}
public function execute()
{
$user = $this->user;
$newPassword = $this->getArgument(self::NEW_PASSWORD);
$newPassword = $this->getArgument(JobArgs::ARG_NEW_PASSWORD);
$oldPasswordHash = $user->getPasswordHash();
$user->setPassword($newPassword);

View file

@ -1,8 +1,6 @@
<?php
class FeaturePostJob extends AbstractPostJob
{
const ANONYMOUS = 'anonymous';
public function execute()
{
$post = $this->post;
@ -11,7 +9,7 @@ class FeaturePostJob extends AbstractPostJob
PropertyModel::set(PropertyModel::FeaturedPostUnixTime, time());
PropertyModel::set(PropertyModel::FeaturedPostUserName,
($this->hasArgument(self::ANONYMOUS) and $this->getArgument(self::ANONYMOUS))
($this->hasArgument(JobArgs::ARG_ANONYMOUS) and $this->getArgument(JobArgs::ARG_ANONYMOUS))
? null
: Auth::getCurrentUser()->getName());

View file

@ -4,9 +4,9 @@ class GetLogJob extends AbstractPageJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$name = $this->getArgument(self::LOG_ID);
$query = $this->getArgument(self::QUERY);
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$name = $this->getArgument(JobArgs::ARG_LOG_ID);
$query = $this->getArgument(JobArgs::ARG_QUERY);
//parse input
$page = max(1, intval($page));

View file

@ -5,7 +5,7 @@ class GetPostContentJob extends AbstractJob
public function prepare()
{
$this->post = PostModel::getByName($this->getArgument(self::POST_NAME));
$this->post = PostModel::getByName($this->getArgument(JobArgs::ARG_POST_NAME));
}
public function execute()

View file

@ -1,14 +1,11 @@
<?php
class GetPostThumbJob extends AbstractJob
{
const WIDTH = 'width';
const HEIGHT = 'height';
public function execute()
{
$name = $this->getArgument(self::POST_NAME);
$width = $this->hasArgument(self::WIDTH) ? $this->getArgument(self::WIDTH) : null;
$height = $this->hasArgument(self::HEIGHT) ? $this->getArgument(self::HEIGHT) : null;
$name = $this->getArgument(JobArgs::ARG_POST_NAME);
$width = $this->hasArgument(JobArgs::ARG_THUMB_WIDTH) ? $this->getArgument(JobArgs::ARG_THUMB_WIDTH) : null;
$height = $this->hasArgument(JobArgs::ARG_THUMB_HEIGHT) ? $this->getArgument(JobArgs::ARG_THUMB_HEIGHT) : null;
$path = PostModel::getThumbCustomPath($name, $width, $height);
if (!file_exists($path))

View file

@ -4,7 +4,7 @@ class ListCommentsJob extends AbstractPageJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$query = 'comment_min:1 order:comment_date,desc';
$posts = PostSearchService::getEntities($query, $pageSize, $page);

View file

@ -4,8 +4,8 @@ class ListPostsJob extends AbstractPageJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$query = $this->getArgument(self::QUERY);
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$query = $this->getArgument(JobArgs::ARG_QUERY);
$posts = PostSearchService::getEntities($query, $pageSize, $page);
$postCount = PostSearchService::getEntityCount($query);

View file

@ -4,9 +4,9 @@ class ListRelatedTagsJob extends ListTagsJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$tag = $this->getArgument(self::TAG_NAME);
$otherTags = $this->hasArgument(self::TAG_NAMES) ? $this->getArgument(self::TAG_NAMES) : [];
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$tag = $this->getArgument(JobArgs::ARG_TAG_NAME);
$otherTags = $this->hasArgument(JobArgs::ARG_TAG_NAMES) ? $this->getArgument(JobArgs::ARG_TAG_NAMES) : [];
$tags = TagSearchService::getRelatedTags($tag);
$tagCount = count($tags);

View file

@ -4,8 +4,8 @@ class ListTagsJob extends AbstractPageJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$query = $this->getArgument(self::QUERY);
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$query = $this->getArgument(JobArgs::ARG_QUERY);
$tags = TagSearchService::getEntities($query, $pageSize, $page);
$tagCount = TagSearchService::getEntityCount($query);

View file

@ -4,8 +4,8 @@ class ListUsersJob extends AbstractPageJob
public function execute()
{
$pageSize = $this->getPageSize();
$page = $this->getArgument(self::PAGE_NUMBER);
$filter = $this->getArgument(self::QUERY);
$page = $this->getArgument(JobArgs::ARG_PAGE_NUMBER);
$filter = $this->getArgument(JobArgs::ARG_QUERY);
$users = UserSearchService::getEntities($filter, $pageSize, $page);
$userCount = UserSearchService::getEntityCount($filter);

View file

@ -1,13 +1,10 @@
<?php
class MergeTagsJob extends AbstractJob
{
const SOURCE_TAG_NAME = 'source-tag-name';
const TARGET_TAG_NAME = 'target-tag-name';
public function execute()
{
$sourceTag = $this->getArgument(self::SOURCE_TAG_NAME);
$targetTag = $this->getArgument(self::TARGET_TAG_NAME);
$sourceTag = $this->getArgument(JobArgs::ARG_SOURCE_TAG_NAME);
$targetTag = $this->getArgument(JobArgs::ARG_TARGET_TAG_NAME);
TagModel::removeUnused();
TagModel::merge($sourceTag, $targetTag);

View file

@ -1,14 +1,11 @@
<?php
class PasswordResetJob extends AbstractJob
{
const TOKEN = 'token';
const NEW_PASSWORD = 'new-password';
public function execute()
{
if (!$this->hasArgument(self::TOKEN))
if (!$this->hasArgument(JobArgs::ARG_TOKEN))
{
$user = UserModel::getByNameOrEmail($this->getArgument(self::USER_NAME));
$user = UserModel::getByNameOrEmail($this->getArgument(JobArgs::ARG_USER_NAME));
if (empty($user->getConfirmedEmail()))
throw new SimpleException('This user has no e-mail confirmed; password reset cannot proceed');
@ -19,7 +16,7 @@ class PasswordResetJob extends AbstractJob
}
else
{
$tokenText = $this->getArgument(self::TOKEN);
$tokenText = $this->getArgument(JobArgs::ARG_TOKEN);
$token = TokenModel::getByToken($tokenText);
TokenModel::checkValidity($token);

View file

@ -4,17 +4,17 @@ class PreviewCommentJob extends AbstractJob
public function execute()
{
$user = Auth::getCurrentUser();
$text = $this->getArgument(self::TEXT);
$text = $this->getArgument(JobArgs::ARG_NEW_TEXT);
if ($this->hasArgument(self::POST_ID))
if ($this->hasArgument(JobArgs::ARG_POST_ID))
{
$post = PostModel::getById($this->getArgument(self::POST_ID));
$post = PostModel::getById($this->getArgument(JobArgs::ARG_POST_ID));
$comment = CommentModel::spawn();
$comment->setPost($post);
}
else
{
$comment = CommentModel::getById($this->getArgument(self::COMMENT_ID));
$comment = CommentModel::getById($this->getArgument(JobArgs::ARG_COMMENT_ID));
}
$comment->setCommenter($user);

View file

@ -1,13 +1,10 @@
<?php
class RenameTagsJob extends AbstractJob
{
const SOURCE_TAG_NAME = 'source-tag-name';
const TARGET_TAG_NAME = 'target-tag-name';
public function execute()
{
$sourceTag = $this->getArgument(self::SOURCE_TAG_NAME);
$targetTag = $this->getArgument(self::TARGET_TAG_NAME);
$sourceTag = $this->getArgument(JobArgs::ARG_SOURCE_TAG_NAME);
$targetTag = $this->getArgument(JobArgs::ARG_TARGET_TAG_NAME);
TagModel::removeUnused();
TagModel::rename($sourceTag, $targetTag);

View file

@ -1,12 +1,10 @@
<?php
class ScorePostJob extends AbstractPostJob
{
const SCORE = 'score';
public function execute()
{
$post = $this->post;
$score = intval($this->getArgument(self::SCORE));
$score = intval($this->getArgument(JobArgs::ARG_NEW_POST_SCORE));
UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);

View file

@ -4,7 +4,7 @@ class TogglePostFavoriteJob extends AbstractPostJob
public function execute()
{
$post = $this->post;
$favorite = boolval($this->getArgument(self::STATE));
$favorite = boolval($this->getArgument(JobArgs::ARG_NEW_STATE));
if ($favorite)
{

View file

@ -3,8 +3,8 @@ class TogglePostTagJob extends AbstractPostJob
{
public function execute()
{
$tagName = $this->getArgument(self::TAG_NAME);
$enable = boolval($this->getArgument(self::STATE));
$tagName = $this->getArgument(JobArgs::ARG_TAG_NAME);
$enable = boolval($this->getArgument(JobArgs::ARG_NEW_STATE));
$post = $this->post;
$tags = $post->getTags();

View file

@ -4,7 +4,7 @@ class TogglePostVisibilityJob extends AbstractPostJob
public function execute()
{
$post = $this->post;
$visible = boolval($this->getArgument(self::STATE));
$visible = boolval($this->getArgument(JobArgs::ARG_NEW_STATE));
$post->setHidden(!$visible);
PostModel::save($post);

View file

@ -4,7 +4,7 @@ class ToggleUserBanJob extends AbstractUserJob
public function execute()
{
$user = $this->user;
$banned = boolval($this->getArgument(self::STATE));
$banned = boolval($this->getArgument(JobArgs::ARG_NEW_STATE));
if ($banned)
$user->ban();

View file

@ -6,7 +6,7 @@ class CommentController
$ret = Api::run(
new ListCommentsJob(),
[
ListCommentsJob::PAGE_NUMBER => $page,
JobArgs::ARG_PAGE_NUMBER => $page,
]);
$context = getContext();
@ -21,8 +21,8 @@ class CommentController
$comment = Api::run(
new PreviewCommentJob(),
[
PreviewCommentJob::POST_ID => InputHelper::get('post-id'),
PreviewCommentJob::TEXT => InputHelper::get('text')
JobArgs::ARG_POST_ID => InputHelper::get('post-id'),
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
getContext()->transport->textPreview = $comment->getTextMarkdown();
@ -31,8 +31,8 @@ class CommentController
Api::run(
new AddCommentJob(),
[
AddCommentJob::POST_ID => InputHelper::get('post-id'),
AddCommentJob::TEXT => InputHelper::get('text')
JobArgs::ARG_POST_ID => InputHelper::get('post-id'),
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
}
@ -48,8 +48,8 @@ class CommentController
$comment = Api::run(
new PreviewCommentJob(),
[
PreviewCommentJob::COMMENT_ID => $id,
PreviewCommentJob::TEXT => InputHelper::get('text')
JobArgs::ARG_COMMENT_ID => $id,
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
getContext()->transport->textPreview = $comment->getTextMarkdown();
@ -58,8 +58,8 @@ class CommentController
Api::run(
new EditCommentJob(),
[
EditCommentJob::COMMENT_ID => $id,
EditCommentJob::TEXT => InputHelper::get('text')
JobArgs::ARG_COMMENT_ID => $id,
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
}
@ -68,7 +68,7 @@ class CommentController
$comment = Api::run(
new DeleteCommentJob(),
[
DeleteCommentJob::COMMENT_ID => $id,
JobArgs::ARG_COMMENT_ID => $id,
]);
}
}

View file

@ -30,9 +30,9 @@ class LogController
$ret = Api::run(
new GetLogJob(),
[
GetLogJob::PAGE_NUMBER => $page,
GetLogJob::LOG_ID => $name,
GetLogJob::QUERY => $filter,
JobArgs::ARG_PAGE_NUMBER => $page,
JobArgs::ARG_LOG_ID => $name,
JobArgs::ARG_QUERY => $filter,
]);
//stylize important lines

View file

@ -42,8 +42,8 @@ class PostController
$ret = Api::run(
new ListPostsJob(),
[
ListPostsJob::PAGE_NUMBER => $page,
ListPostsJob::QUERY => $query
JobArgs::ARG_PAGE_NUMBER => $page,
JobArgs::ARG_QUERY => $query
]);
$context->transport->posts = $ret->entities;
@ -74,9 +74,9 @@ class PostController
Api::run(
new TogglePostTagJob(),
[
TogglePostTagJob::POST_ID => $id,
TogglePostTagJob::TAG_NAME => $tag,
TogglePostTagJob::STATE => $enable,
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_TAG_NAME => $tag,
JobArgs::ARG_NEW_STATE => $enable,
]);
}
@ -88,22 +88,22 @@ class PostController
{
$jobArgs =
[
AddPostJob::ANONYMOUS => InputHelper::get('anonymous'),
EditPostSafetyJob::SAFETY => InputHelper::get('safety'),
EditPostTagsJob::TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
EditPostSourceJob::SOURCE => InputHelper::get('source'),
JobArgs::ARG_ANONYMOUS => InputHelper::get('anonymous'),
JobArgs::ARG_NEW_SAFETY => InputHelper::get('safety'),
JobArgs::ARG_NEW_TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
JobArgs::ARG_NEW_SOURCE => InputHelper::get('source'),
];
if (!empty(InputHelper::get('url')))
{
$jobArgs[EditPostContentJob::POST_CONTENT_URL] = InputHelper::get('url');
$jobArgs[JobArgs::ARG_NEW_POST_CONTENT_URL] = InputHelper::get('url');
}
elseif (!empty($_FILES['file']['name']))
{
$file = $_FILES['file'];
TransferHelper::handleUploadErrors($file);
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
$jobArgs[JobArgs::ARG_NEW_POST_CONTENT] = new ApiFileInput(
$file['tmp_name'],
$file['name']);
}
@ -114,7 +114,7 @@ class PostController
public function editView($id)
{
$post = Api::run(new GetPostJob(), [
GetPostJob::POST_ID => $id]);
JobArgs::ARG_POST_ID => $id]);
$context = getContext()->transport->post = $post;
}
@ -129,23 +129,23 @@ class PostController
$jobArgs =
[
EditPostJob::POST_ID => $id,
EditPostSafetyJob::SAFETY => InputHelper::get('safety'),
EditPostTagsJob::TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
EditPostSourceJob::SOURCE => InputHelper::get('source'),
EditPostRelationsJob::RELATED_POST_IDS => InputHelper::get('relations'),
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_SAFETY => InputHelper::get('safety'),
JobArgs::ARG_NEW_TAG_NAMES => $this->splitTags(InputHelper::get('tags')),
JobArgs::ARG_NEW_SOURCE => InputHelper::get('source'),
JobArgs::ARG_NEW_RELATED_POST_IDS => InputHelper::get('relations'),
];
if (!empty(InputHelper::get('url')))
{
$jobArgs[EditPostContentJob::POST_CONTENT_URL] = InputHelper::get('url');
$jobArgs[JobArgs::ARG_NEW_POST_CONTENT_URL] = InputHelper::get('url');
}
elseif (!empty($_FILES['file']['name']))
{
$file = $_FILES['file'];
TransferHelper::handleUploadErrors($file);
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
$jobArgs[JobArgs::ARG_NEW_POST_CONTENT] = new ApiFileInput(
$file['tmp_name'],
$file['name']);
}
@ -155,7 +155,7 @@ class PostController
$file = $_FILES['thumb'];
TransferHelper::handleUploadErrors($file);
$jobArgs[EditPostThumbJob::THUMB_CONTENT] = new ApiFileInput(
$jobArgs[JobArgs::ARG_NEW_THUMB_CONTENT] = new ApiFileInput(
$file['tmp_name'],
$file['name']);
}
@ -165,54 +165,54 @@ class PostController
public function flagAction($id)
{
Api::run(new FlagPostJob(), [FlagPostJob::POST_ID => $id]);
Api::run(new FlagPostJob(), [JobArgs::ARG_POST_ID => $id]);
}
public function hideAction($id)
{
Api::run(new TogglePostVisibilityJob(), [
TogglePostVisibilityJob::POST_ID => $id,
TogglePostVisibilityJob::STATE => false]);
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_STATE => false]);
}
public function unhideAction($id)
{
Api::run(new TogglePostVisibilityJob(), [
TogglePostVisibilityJob::POST_ID => $id,
TogglePostVisibilityJob::STATE => true]);
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_STATE => true]);
}
public function deleteAction($id)
{
Api::run(new DeletePostJob(), [
DeletePostJob::POST_ID => $id]);
JobArgs::ARG_POST_ID => $id]);
}
public function addFavoriteAction($id)
{
Api::run(new TogglePostFavoriteJob(), [
TogglePostFavoriteJob::POST_ID => $id,
TogglePostFavoriteJob::STATE => true]);
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_STATE => true]);
}
public function removeFavoriteAction($id)
{
Api::run(new TogglePostFavoriteJob(), [
TogglePostFavoriteJob::POST_ID => $id,
TogglePostFavoriteJob::STATE => false]);
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_STATE => false]);
}
public function scoreAction($id, $score)
{
Api::run(new ScorePostJob(), [
ScorePostJob::POST_ID => $id,
ScorePostJob::SCORE => $score]);
JobArgs::ARG_POST_ID => $id,
JobArgs::ARG_NEW_POST_SCORE => $score]);
}
public function featureAction($id)
{
Api::run(new FeaturePostJob(), [
FeaturePostJob::POST_ID => $id]);
JobArgs::ARG_POST_ID => $id]);
}
public function genericView($id)
@ -221,7 +221,7 @@ class PostController
$context->viewName = 'post-view';
$post = Api::run(new GetPostJob(), [
GetPostJob::POST_ID => $id]);
JobArgs::ARG_POST_ID => $id]);
try
{
@ -255,7 +255,7 @@ class PostController
public function fileView($name)
{
$ret = Api::run(new GetPostContentJob(), [GetPostContentJob::POST_NAME => $name]);
$ret = Api::run(new GetPostContentJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = getContext();
$context->transport->cacheDaysToLive = 14;
@ -270,9 +270,9 @@ class PostController
public function thumbView($name, $width = null, $height = null)
{
$ret = Api::run(new GetPostThumbJob(), [
GetPostThumbJob::POST_NAME => $name,
GetPostThumbJob::WIDTH => $width,
GetPostThumbJob::HEIGHT => $height]);
JobArgs::ARG_POST_NAME => $name,
JobArgs::ARG_THUMB_WIDTH => $width,
JobArgs::ARG_THUMB_HEIGHT => $height]);
$context = getContext();
$context->transport->cacheDaysToLive = 365;

View file

@ -6,8 +6,8 @@ class TagController
$ret = Api::run(
new ListTagsJob(),
[
ListTagsJob::PAGE_NUMBER => $page,
ListTagsJob::QUERY => $filter,
JobArgs::ARG_PAGE_NUMBER => $page,
JobArgs::ARG_QUERY => $filter,
]);
$context = getContext();
@ -26,8 +26,8 @@ class TagController
$ret = Api::run(
(new ListTagsJob)->setPageSize(15),
[
ListTagsJob::QUERY => $filter,
ListTagsJob::PAGE_NUMBER => 1,
JobArgs::ARG_QUERY => $filter,
JobArgs::ARG_PAGE_NUMBER => 1,
]);
$context = getContext();
@ -50,9 +50,9 @@ class TagController
$ret = Api::run(
(new ListRelatedTagsJob),
[
ListRelatedTagsJob::TAG_NAME => $tag,
ListRelatedTagsJob::TAG_NAMES => $otherTags,
ListRelatedTagsJob::PAGE_NUMBER => 1
JobArgs::ARG_TAG_NAME => $tag,
JobArgs::ARG_TAG_NAMES => $otherTags,
JobArgs::ARG_PAGE_NUMBER => 1
]);
$context = getContext();
@ -82,8 +82,8 @@ class TagController
Api::run(
new MergeTagsJob(),
[
MergeTagsJob::SOURCE_TAG_NAME => InputHelper::get('source-tag'),
MergeTagsJob::TARGET_TAG_NAME => InputHelper::get('target-tag'),
JobArgs::ARG_SOURCE_TAG_NAME => InputHelper::get('source-tag'),
JobArgs::ARG_TARGET_TAG_NAME => InputHelper::get('target-tag'),
]);
Messenger::message('Tags merged successfully.');
@ -104,8 +104,8 @@ class TagController
Api::run(
new RenameTagsJob(),
[
RenameTagsJob::SOURCE_TAG_NAME => InputHelper::get('source-tag'),
RenameTagsJob::TARGET_TAG_NAME => InputHelper::get('target-tag'),
JobArgs::ARG_SOURCE_TAG_NAME => InputHelper::get('source-tag'),
JobArgs::ARG_TARGET_TAG_NAME => InputHelper::get('target-tag'),
]);
Messenger::message('Tag renamed successfully.');

View file

@ -6,8 +6,8 @@ class UserController
$ret = Api::run(
new ListUsersJob(),
[
ListUsersJob::PAGE_NUMBER => $page,
ListUsersJob::QUERY => $filter,
JobArgs::ARG_PAGE_NUMBER => $page,
JobArgs::ARG_QUERY => $filter,
]);
$context = getContext();
@ -22,7 +22,7 @@ class UserController
$user = Api::run(
new GetUserJob(),
[
GetUserJob::USER_NAME => $name,
JobArgs::ARG_USER_NAME => $name,
]);
$flagged = in_array(TextHelper::reprUser($user), SessionHelper::get('flagged', []));
@ -59,8 +59,8 @@ class UserController
$ret = Api::run(
new ListPostsJob(),
[
ListPostsJob::PAGE_NUMBER => $page,
ListPostsJob::QUERY => $query
JobArgs::ARG_PAGE_NUMBER => $page,
JobArgs::ARG_QUERY => $query
]);
$context->transport->posts = $ret->entities;
@ -107,11 +107,11 @@ class UserController
$args =
[
EditUserNameJob::USER_NAME => $name,
EditUserNameJob::NEW_USER_NAME => InputHelper::get('name'),
EditUserPasswordJob::NEW_PASSWORD => InputHelper::get('password1'),
EditUserEmailJob::NEW_EMAIL => InputHelper::get('email'),
EditUserAccessRankJob::NEW_ACCESS_RANK => InputHelper::get('access-rank'),
JobArgs::ARG_USER_NAME => $name,
JobArgs::ARG_NEW_USER_NAME => InputHelper::get('name'),
JobArgs::ARG_NEW_PASSWORD => InputHelper::get('password1'),
JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'),
JobArgs::ARG_NEW_ACCESS_RANK => InputHelper::get('access-rank'),
];
$args = array_filter($args);
@ -133,7 +133,7 @@ class UserController
$this->requirePasswordConfirmation();
Api::run(new DeleteUserJob(), [
DeleteUserJob::USER_NAME => $name]);
JobArgs::ARG_USER_NAME => $name]);
$user = UserModel::tryGetById(Auth::getCurrentUser()->getId());
if (!$user)
@ -145,27 +145,27 @@ class UserController
public function flagAction($name)
{
Api::run(new FlagUserJob(), [FlagUserJob::USER_NAME => $name]);
Api::run(new FlagUserJob(), [JobArgs::ARG_USER_NAME => $name]);
}
public function banAction($name)
{
Api::run(new ToggleUserBanJob(), [
ToggleUserBanJob::USER_NAME => $name,
ToggleUserBanJob::STATE => true]);
JobArgs::ARG_USER_NAME => $name,
JobArgs::ARG_NEW_STATE => true]);
}
public function unbanAction($name)
{
Api::run(new ToggleUserBanJob(), [
ToggleUserBanJob::USER_NAME => $name,
ToggleUserBanJob::STATE => false]);
JobArgs::ARG_USER_NAME => $name,
JobArgs::ARG_NEW_STATE => false]);
}
public function acceptRegistrationAction($name)
{
Api::run(new AcceptUserRegistrationJob(), [
AcceptUserRegistrationJob::USER_NAME => $name]);
JobArgs::ARG_USER_NAME => $name]);
}
public function toggleSafetyAction($safety)
@ -208,9 +208,9 @@ class UserController
$user = Api::run(new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => InputHelper::get('name'),
EditUserPasswordJob::NEW_PASSWORD => InputHelper::get('password1'),
EditUserEmailJob::NEW_EMAIL => InputHelper::get('email'),
JobArgs::ARG_NEW_USER_NAME => InputHelper::get('name'),
JobArgs::ARG_NEW_PASSWORD => InputHelper::get('password1'),
JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'),
]);
if (!getConfig()->registration->needEmailForRegistering and !getConfig()->registration->staffActivation)
@ -247,13 +247,13 @@ class UserController
if (empty($tokenText))
{
Api::run(new ActivateUserEmailJob(), [ ActivateUserEmailJob::USER_NAME => $name ]);
Api::run(new ActivateUserEmailJob(), [ JobArgs::ARG_USER_NAME => $name ]);
Messenger::message('Activation e-mail resent.');
}
else
{
$user = Api::run(new ActivateUserEmailJob(), [ ActivateUserEmailJob::TOKEN => $tokenText ]);
$user = Api::run(new ActivateUserEmailJob(), [ JobArgs::ARG_TOKEN => $tokenText ]);
$message = 'Activation completed successfully.';
if (getConfig()->registration->staffActivation)
@ -281,13 +281,13 @@ class UserController
if (empty($tokenText))
{
Api::run(new PasswordResetJob(), [ PasswordResetJob::USER_NAME => $name ]);
Api::run(new PasswordResetJob(), [ JobArgs::ARG_USER_NAME => $name ]);
Messenger::message('E-mail sent. Follow instructions to reset password.');
}
else
{
$ret = Api::run(new PasswordResetJob(), [ PasswordResetJob::TOKEN => $tokenText ]);
$ret = Api::run(new PasswordResetJob(), [ JobArgs::ARG_TOKEN => $tokenText ]);
Messenger::message(sprintf(
'Password reset successful. Your new password is **%s**.',

View file

@ -67,7 +67,7 @@ class ApiAuthTest extends AbstractFullApiTest
return Api::run(
new DeleteCommentJob(),
[
DeleteCommentJob::COMMENT_ID => $comment->getId(),
JobArgs::ARG_COMMENT_ID => $comment->getId(),
]);
}, 'Not logged in');
}

View file

@ -97,8 +97,8 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
return Api::run(
new AddCommentJob(),
[
AddCommentJob::POST_ID => $post->getId(),
AddCommentJob::TEXT => 'alohaaa',
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TEXT => 'alohaaa',
]);
}, 'Need e-mail');
}

View file

@ -78,12 +78,12 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$otherPost = $this->mockPost($this->mockUser());
$expectedPrivilege->secondary = 'all';
$job->setArgument(AbstractJob::POST_ID, $otherPost->getId());
$job->setArgument(JobArgs::ARG_POST_ID, $otherPost->getId());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
$expectedPrivilege->secondary = 'own';
$job->setArgument(AbstractJob::POST_ID, $ownPost->getId());
$job->setArgument(JobArgs::ARG_POST_ID, $ownPost->getId());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
}
@ -105,8 +105,8 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$post->setHidden(true);
PostModel::save($post);
$job->setArgument(AbstractJob::POST_ID, $post->getId());
$job->setArgument(AbstractJob::POST_NAME, $post->getName());
$job->setArgument(JobArgs::ARG_POST_ID, $post->getId());
$job->setArgument(JobArgs::ARG_POST_NAME, $post->getName());
$job->prepare();
$this->assert->areEquivalent([
new Privilege(Privilege::ViewPost, 'hidden'),
@ -147,12 +147,12 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testedJobs []= $job;
$expectedPrivilege->secondary = 'own';
$job->setArgument(AbstractJob::USER_NAME, $ownUser->getName());
$job->setArgument(JobArgs::ARG_USER_NAME, $ownUser->getName());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
$expectedPrivilege->secondary = 'all';
$job->setArgument(AbstractJob::USER_NAME, $otherUser->getName());
$job->setArgument(JobArgs::ARG_USER_NAME, $otherUser->getName());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
}
@ -173,12 +173,12 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testedJobs []= $job;
$expectedPrivilege->secondary = 'own';
$job->setArgument(AbstractJob::COMMENT_ID, $ownComment->getId());
$job->setArgument(JobArgs::ARG_COMMENT_ID, $ownComment->getId());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
$expectedPrivilege->secondary = 'all';
$job->setArgument(AbstractJob::COMMENT_ID, $otherComment->getId());
$job->setArgument(JobArgs::ARG_COMMENT_ID, $otherComment->getId());
$job->prepare();
$this->assert->areEquivalent($expectedPrivilege, $job->requiresPrivilege());
}
@ -192,8 +192,8 @@ class ApiPrivilegeTest extends AbstractFullApiTest
return Api::run(
new AddCommentJob(),
[
AddCommentJob::POST_ID => $post->getId(),
AddCommentJob::TEXT => 'alohaaa',
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TEXT => 'alohaaa',
]);
}, 'Insufficient privileges');
}

View file

@ -17,7 +17,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::USER_NAME => $user->getName(),
JobArgs::ARG_USER_NAME => $user->getName(),
]);
});
@ -50,7 +50,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::USER_NAME => $user->getName(),
JobArgs::ARG_USER_NAME => $user->getName(),
]);
});
@ -61,7 +61,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::TOKEN => $tokenText,
JobArgs::ARG_TOKEN => $tokenText,
]);
});
@ -88,7 +88,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::USER_NAME => $user->getName(),
JobArgs::ARG_USER_NAME => $user->getName(),
]);
$tokenText = Mailer::getMailsSent()[0]->tokens['token'];
@ -96,7 +96,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::TOKEN => $tokenText,
JobArgs::ARG_TOKEN => $tokenText,
]);
$this->assert->throws(function() use ($tokenText)
@ -104,7 +104,7 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::TOKEN => $tokenText,
JobArgs::ARG_TOKEN => $tokenText,
]);
}, 'This token was already used');
}
@ -124,13 +124,13 @@ class ActivateUserEmailJobTest extends AbstractTest
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::USER_NAME => $user1->getName(),
JobArgs::ARG_USER_NAME => $user1->getName(),
]);
Api::run(
new ActivateUserEmailJob(),
[
ActivateUserEmailJob::USER_NAME => $user2->getName(),
JobArgs::ARG_USER_NAME => $user2->getName(),
]);
$tokens1 = Mailer::getMailsSent()[0]->tokens;

View file

@ -88,8 +88,8 @@ class AddCommentJobTest extends AbstractTest
Api::run(
new AddCommentJob(),
[
AddCommentJob::POST_ID => 100,
AddCommentJob::TEXT => 'alohaa',
JobArgs::ARG_POST_ID => 100,
JobArgs::ARG_NEW_TEXT => 'alohaa',
]);
}, 'Invalid post ID');
}
@ -102,8 +102,8 @@ class AddCommentJobTest extends AbstractTest
return Api::run(
new AddCommentJob(),
[
AddCommentJob::POST_ID => $post->getId(),
AddCommentJob::TEXT => $text,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TEXT => $text,
]);
}

View file

@ -18,10 +18,10 @@ class AddPostJobTest extends AbstractTest
return Api::run(
new AddPostJob(),
[
EditPostSafetyJob::SAFETY => PostSafety::Safe,
EditPostSourceJob::SOURCE => '',
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
EditPostTagsJob::TAG_NAMES => ['kamen', 'raider'],
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
JobArgs::ARG_NEW_SOURCE => '',
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_NEW_TAG_NAMES => ['kamen', 'raider'],
]);
});
@ -46,9 +46,9 @@ class AddPostJobTest extends AbstractTest
return Api::run(
new AddPostJob(),
[
AddPostJob::ANONYMOUS => true,
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
EditPostTagsJob::TAG_NAMES => ['kamen', 'raider'],
JobArgs::ARG_ANONYMOUS => true,
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_NEW_TAG_NAMES => ['kamen', 'raider'],
]);
});
@ -73,9 +73,9 @@ class AddPostJobTest extends AbstractTest
Api::run(
new AddPostJob(),
[
EditPostSafetyJob::SAFETY => PostSafety::Safe,
EditPostSourceJob::SOURCE => '',
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
JobArgs::ARG_NEW_SOURCE => '',
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
]);
}, 'Insufficient privilege');
}
@ -94,9 +94,9 @@ class AddPostJobTest extends AbstractTest
Api::run(
new AddPostJob(),
[
EditPostSafetyJob::SAFETY => 666,
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
EditPostTagsJob::TAG_NAMES => ['kamen', 'raider'],
JobArgs::ARG_NEW_SAFETY => 666,
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_NEW_TAG_NAMES => ['kamen', 'raider'],
]);
}, 'Invalid safety type');
}
@ -114,7 +114,7 @@ class AddPostJobTest extends AbstractTest
Api::run(
new AddPostJob(),
[
EditPostTagsJob::TAG_NAMES => ['kamen', 'raider'],
JobArgs::ARG_TAG_NAMES => ['kamen', 'raider'],
]);
}, 'No post type detected');
}
@ -132,7 +132,7 @@ class AddPostJobTest extends AbstractTest
Api::run(
new AddPostJob(),
[
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
]);
}, 'No tags set');
}

View file

@ -10,8 +10,8 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
]);
});
@ -26,8 +26,8 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy2',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_USER_NAME => 'dummy2',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
]);
});
@ -44,8 +44,8 @@ class AddUserJobTest extends AbstractTest
Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
]);
}, 'Password must have at least');
}
@ -63,9 +63,9 @@ class AddUserJobTest extends AbstractTest
Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
}, 'Password must have at least');
@ -82,8 +82,8 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => $pass,
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => $pass,
]);
});
@ -109,8 +109,8 @@ class AddUserJobTest extends AbstractTest
Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
]);
});
@ -119,8 +119,8 @@ class AddUserJobTest extends AbstractTest
Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
]);
}, 'User with');
}
@ -134,9 +134,9 @@ class AddUserJobTest extends AbstractTest
Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserAccessRankJob::NEW_ACCESS_RANK => 'power-user',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_ACCESS_RANK => 'power-user',
]);
}, 'Insufficient privileges');
}
@ -155,9 +155,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
});
@ -170,9 +170,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy2',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla2@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy2',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla2@whitestar.gov',
]);
});
@ -197,9 +197,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
});
@ -211,9 +211,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy2',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla2@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy2',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla2@whitestar.gov',
]);
});
@ -237,9 +237,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
});
@ -251,9 +251,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy2',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla2@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy2',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla2@whitestar.gov',
]);
});
@ -276,9 +276,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
});
@ -287,9 +287,9 @@ class AddUserJobTest extends AbstractTest
return Api::run(
new AddUserJob(),
[
EditUserNameJob::NEW_USER_NAME => 'dummy2',
EditUserPasswordJob::NEW_PASSWORD => 'sekai',
EditUserEmailJob::NEW_EMAIL => 'godzilla@whitestar.gov',
JobArgs::ARG_NEW_USER_NAME => 'dummy2',
JobArgs::ARG_NEW_PASSWORD => 'sekai',
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
});

View file

@ -15,7 +15,7 @@ class DeleteCommentJobTest extends AbstractTest
Api::run(
new DeleteCommentJob(),
[
DeleteCommentJob::COMMENT_ID => $comment->getId(),
JobArgs::ARG_COMMENT_ID => $comment->getId(),
]);
});
@ -33,7 +33,7 @@ class DeleteCommentJobTest extends AbstractTest
Api::run(
new DeleteCommentJob(),
[
DeleteCommentJob::COMMENT_ID => 100,
JobArgs::ARG_COMMENT_ID => 100,
]);
}, 'Invalid comment ID');
}

View file

@ -70,8 +70,8 @@ class EditCommentJobTest extends AbstractTest
Api::run(
new EditCommentJob(),
[
EditCommentJob::COMMENT_ID => 100,
EditCommentJob::TEXT => 'alohaa',
JobArgs::ARG_COMMENT_ID => 100,
JobArgs::ARG_NEW_TEXT => 'alohaa',
]);
}, 'Invalid comment ID');
}
@ -84,8 +84,8 @@ class EditCommentJobTest extends AbstractTest
return Api::run(
new EditCommentJob(),
[
EditCommentJob::COMMENT_ID => $comment->getId(),
EditCommentJob::TEXT => $text,
JobArgs::ARG_COMMENT_ID => $comment->getId(),
JobArgs::ARG_NEW_TEXT => $text,
]);
}

View file

@ -87,8 +87,8 @@ class EditPostContentJobTest extends AbstractTest
$post = Api::run(
new EditPostContentJob(),
[
EditPostContentJob::POST_ID => $post->getId(),
EditPostContentJob::POST_CONTENT_URL => 'http://www.youtube.com/watch?v=qWq_jydCUw4', 'test.jpg',
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_CONTENT_URL => 'http://www.youtube.com/watch?v=qWq_jydCUw4', 'test.jpg',
]);
$this->assert->areEqual(PostType::Youtube, $post->getType()->toInteger());
$this->assert->areEqual('qWq_jydCUw4', $post->getFileHash());
@ -110,8 +110,8 @@ class EditPostContentJobTest extends AbstractTest
Api::run(
new EditPostContentJob(),
[
EditPostContentJob::POST_ID => 100,
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_POST_ID => 100,
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
]);
}, 'Invalid post ID');
}
@ -133,8 +133,8 @@ class EditPostContentJobTest extends AbstractTest
$post = Api::run(
new EditPostContentJob(),
[
EditPostContentJob::POST_ID => $post->getId(),
EditPostContentJob::POST_CONTENT_URL => $url,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_CONTENT_URL => $url,
]);
$this->assert->areEqual(
@ -152,8 +152,8 @@ class EditPostContentJobTest extends AbstractTest
$post = Api::run(
new EditPostContentJob(),
[
EditPostContentJob::POST_ID => $post->getId(),
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath($fileName), 'test.jpg'),
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath($fileName), 'test.jpg'),
]);
$this->assert->areEqual(

View file

@ -13,10 +13,10 @@ class EditPostJobTest extends AbstractTest
$args =
[
EditPostJob::POST_ID => $post->getId(),
EditPostSafetyJob::SAFETY => PostSafety::Sketchy,
EditPostSourceJob::SOURCE => 'some source huh',
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_SAFETY => PostSafety::Sketchy,
JobArgs::ARG_NEW_SOURCE => 'some source huh',
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
];
$this->assert->doesNotThrow(function() use ($args)
@ -36,10 +36,10 @@ class EditPostJobTest extends AbstractTest
$args =
[
EditPostJob::POST_ID => $post->getId(),
EditPostSafetyJob::SAFETY => PostSafety::Safe,
EditPostSourceJob::SOURCE => '',
EditPostContentJob::POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_SAFETY => PostSafety::Safe,
JobArgs::ARG_NEW_SOURCE => '',
JobArgs::ARG_NEW_POST_CONTENT => new ApiFileInput($this->getPath('image.jpg'), 'test.jpg'),
];
$this->assert->throws(function() use ($args)

View file

@ -45,8 +45,8 @@ class EditPostSourceJobTest extends AbstractTest
Api::run(
new EditPostSourceJob(),
[
EditPostSourceJob::POST_ID => 100,
EditPostSourceJob::SOURCE => 'alohaa',
JobArgs::ARG_POST_ID => 100,
JobArgs::ARG_NEW_SOURCE => 'alohaa',
]);
}, 'Invalid post ID');
}
@ -58,8 +58,8 @@ class EditPostSourceJobTest extends AbstractTest
return Api::run(
new EditPostSourceJob(),
[
EditPostSourceJob::POST_ID => $post->getId(),
EditPostSourceJob::SOURCE => $text
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_SOURCE => $text
]);
}

View file

@ -12,8 +12,8 @@ class EditPostTagsJobTest extends AbstractTest
return Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => $post->getId(),
EditPostTagsJob::TAG_NAMES => $newTagNames,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TAG_NAMES => $newTagNames,
]);
});
@ -38,8 +38,8 @@ class EditPostTagsJobTest extends AbstractTest
Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => $post->getId(),
EditPostTagsJob::TAG_NAMES => [],
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TAG_NAMES => [],
]);
}, 'No tags set');
}
@ -55,8 +55,8 @@ class EditPostTagsJobTest extends AbstractTest
Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => $post->getId(),
EditPostTagsJob::TAG_NAMES => $newTagNames,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TAG_NAMES => $newTagNames,
]);
}, 'Tag must have at least');
}
@ -72,8 +72,8 @@ class EditPostTagsJobTest extends AbstractTest
Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => $post->getId(),
EditPostTagsJob::TAG_NAMES => $newTagNames,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TAG_NAMES => $newTagNames,
]);
}, 'Tag must have at most');
}
@ -89,8 +89,8 @@ class EditPostTagsJobTest extends AbstractTest
Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => $post->getId(),
EditPostTagsJob::TAG_NAMES => $newTagNames,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TAG_NAMES => $newTagNames,
]);
}, 'Invalid tag');
}
@ -105,8 +105,8 @@ class EditPostTagsJobTest extends AbstractTest
Api::run(
new EditPostTagsJob(),
[
EditPostTagsJob::POST_ID => 100,
EditPostTagsJob::TAG_NAMES => $newTagNames,
JobArgs::ARG_POST_ID => 100,
JobArgs::ARG_NEW_TAG_NAMES => $newTagNames,
]);
}, 'Invalid post ID');
}

View file

@ -17,8 +17,8 @@ class EditUserEmailJobTest extends AbstractTest
return Api::run(
new EditUserEmailJob(),
[
EditUserEmailJob::USER_NAME => $user->getName(),
EditUserEmailJob::NEW_EMAIL => 'xena@other-side.gr',
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_EMAIL => 'xena@other-side.gr',
]);
});
@ -44,8 +44,8 @@ class EditUserEmailJobTest extends AbstractTest
return Api::run(
new EditUserEmailJob(),
[
EditUserEmailJob::USER_NAME => $user->getName(),
EditUserEmailJob::NEW_EMAIL => 'xena@other-side.gr',
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_EMAIL => 'xena@other-side.gr',
]);
});
@ -70,8 +70,8 @@ class EditUserEmailJobTest extends AbstractTest
Api::run(
new EditUserEmailJob(),
[
EditUserEmailJob::USER_NAME => $user->getName(),
EditUserEmailJob::NEW_EMAIL => 'hrmfbpdvpds@brtedf',
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_EMAIL => 'hrmfbpdvpds@brtedf',
]);
}, 'E-mail address appears to be invalid');

View file

@ -14,9 +14,9 @@ class EditUserJobTest extends AbstractTest
return Api::run(
new EditUserJob(),
[
EditUserJob::USER_NAME => $user->getName(),
EditUserNameJob::NEW_USER_NAME => $newName,
EditUserPasswordJob::NEW_PASSWORD => 'changed',
JobArgs::ARG_USER_NAME => $user->getName(),
JobArgs::ARG_NEW_USER_NAME => $newName,
JobArgs::ARG_NEW_PASSWORD => 'changed',
]);
});

View file

@ -15,7 +15,7 @@ class FeaturePostJobTest extends AbstractTest
Api::run(
new FeaturePostJob(),
[
FeaturePostJob::POST_ID => $post2->getId()
JobArgs::ARG_POST_ID => $post2->getId()
]);
});
@ -38,8 +38,8 @@ class FeaturePostJobTest extends AbstractTest
Api::run(
new FeaturePostJob(),
[
FeaturePostJob::POST_ID => $post2->getId(),
FeaturePostJob::ANONYMOUS => true,
JobArgs::ARG_POST_ID => $post2->getId(),
JobArgs::ARG_ANONYMOUS => true,
]);
});

View file

@ -64,7 +64,7 @@ class ListCommentJobTest extends AbstractTest
return Api::run(
new ListCommentsJob(),
[
ListCommentsJob::PAGE_NUMBER => $page,
JobArgs::ARG_PAGE_NUMBER => $page,
]);
}
}

View file

@ -67,8 +67,8 @@ class PreviewCommentJobTest extends AbstractTest
Api::run(
new PreviewCommentJob(),
[
PreviewCommentJob::POST_ID => $post->getId(),
PreviewCommentJob::TEXT => 'alohaaa',
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TEXT => 'alohaaa',
]);
});
}
@ -83,8 +83,8 @@ class PreviewCommentJobTest extends AbstractTest
Api::run(
new PreviewCommentJob(),
[
PreviewCommentJob::COMMENT_ID => $comment->getId(),
PreviewCommentJob::TEXT => 'alohaaa',
JobArgs::ARG_COMMENT_ID => $comment->getId(),
JobArgs::ARG_NEW_TEXT => 'alohaaa',
]);
});
}
@ -97,8 +97,8 @@ class PreviewCommentJobTest extends AbstractTest
return Api::run(
new PreviewCommentJob(),
[
PreviewCommentJob::POST_ID => $post->getId(),
PreviewCommentJob::TEXT => $text,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_TEXT => $text,
]);
}

View file

@ -14,8 +14,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => 1,
]);
});
@ -33,8 +33,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => -1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => -1,
]);
});
@ -52,8 +52,8 @@ class ScorePostJobTest extends AbstractTest
Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => 2,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => 2,
]);
}, 'Invalid score');
@ -71,8 +71,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => -1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => -1,
]);
});
@ -81,8 +81,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => 1,
]);
});
@ -100,8 +100,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => 1,
]);
});
@ -112,8 +112,8 @@ class ScorePostJobTest extends AbstractTest
return Api::run(
new ScorePostJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::SCORE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_POST_SCORE => 1,
]);
});

View file

@ -16,8 +16,8 @@ class TogglePostFavoriteJobTest extends AbstractTest
return Api::run(
new TogglePostFavoriteJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::STATE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 1,
]);
});
@ -43,8 +43,8 @@ class TogglePostFavoriteJobTest extends AbstractTest
return Api::run(
new TogglePostFavoriteJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::STATE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 1,
]);
});
@ -53,8 +53,8 @@ class TogglePostFavoriteJobTest extends AbstractTest
return Api::run(
new TogglePostFavoriteJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::STATE => 0,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 0,
]);
});
@ -81,8 +81,8 @@ class TogglePostFavoriteJobTest extends AbstractTest
return Api::run(
new TogglePostFavoriteJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::STATE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 1,
]);
});
@ -92,8 +92,8 @@ class TogglePostFavoriteJobTest extends AbstractTest
return Api::run(
new TogglePostFavoriteJob(),
[
ScorePostJob::POST_ID => $post->getId(),
ScorePostJob::STATE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 1,
]);
});

View file

@ -14,8 +14,8 @@ class TogglePostVisibilityJobTest extends AbstractTest
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 0,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 0,
]);
});
@ -35,8 +35,8 @@ class TogglePostVisibilityJobTest extends AbstractTest
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 0,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 0,
]);
});
@ -47,8 +47,8 @@ class TogglePostVisibilityJobTest extends AbstractTest
return Api::run(
new TogglePostVisibilityJob(),
[
TogglePostVisibilityJob::POST_ID => $post->getId(),
TogglePostVisibilityJob::STATE => 1,
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_STATE => 1,
]);
});