diff --git a/src/Api/AbstractJob.php b/src/Api/AbstractJob.php index 54f80828..bb6c6bae 100644 --- a/src/Api/AbstractJob.php +++ b/src/Api/AbstractJob.php @@ -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; diff --git a/src/Api/AbstractPostJob.php b/src/Api/AbstractPostJob.php index 80a1c131..4e3956cd 100644 --- a/src/Api/AbstractPostJob.php +++ b/src/Api/AbstractPostJob.php @@ -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); } } diff --git a/src/Api/AbstractUserJob.php b/src/Api/AbstractUserJob.php index a3b722be..47ffb547 100644 --- a/src/Api/AbstractUserJob.php +++ b/src/Api/AbstractUserJob.php @@ -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); } } diff --git a/src/Api/JobArgs.php b/src/Api/JobArgs.php new file mode 100644 index 00000000..50d94dc4 --- /dev/null +++ b/src/Api/JobArgs.php @@ -0,0 +1,47 @@ +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); diff --git a/src/Api/Jobs/AddCommentJob.php b/src/Api/Jobs/AddCommentJob.php index e6b742a3..8f8f98f8 100644 --- a/src/Api/Jobs/AddCommentJob.php +++ b/src/Api/Jobs/AddCommentJob.php @@ -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); diff --git a/src/Api/Jobs/AddPostJob.php b/src/Api/Jobs/AddPostJob.php index e6a5f90f..ffafd600 100644 --- a/src/Api/Jobs/AddPostJob.php +++ b/src/Api/Jobs/AddPostJob.php @@ -1,21 +1,19 @@ 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 diff --git a/src/Api/Jobs/AddUserJob.php b/src/Api/Jobs/AddUserJob.php index 53bee1e0..86f67a4b 100644 --- a/src/Api/Jobs/AddUserJob.php +++ b/src/Api/Jobs/AddUserJob.php @@ -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 diff --git a/src/Api/Jobs/DeleteCommentJob.php b/src/Api/Jobs/DeleteCommentJob.php index 47fb7c2b..7238d60e 100644 --- a/src/Api/Jobs/DeleteCommentJob.php +++ b/src/Api/Jobs/DeleteCommentJob.php @@ -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() diff --git a/src/Api/Jobs/EditCommentJob.php b/src/Api/Jobs/EditCommentJob.php index c9dd0b52..c868114f 100644 --- a/src/Api/Jobs/EditCommentJob.php +++ b/src/Api/Jobs/EditCommentJob.php @@ -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}', [ diff --git a/src/Api/Jobs/EditPostContentJob.php b/src/Api/Jobs/EditPostContentJob.php index 9aafe44f..0751753b 100644 --- a/src/Api/Jobs/EditPostContentJob.php +++ b/src/Api/Jobs/EditPostContentJob.php @@ -1,27 +1,24 @@ 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); } diff --git a/src/Api/Jobs/EditPostJob.php b/src/Api/Jobs/EditPostJob.php index 87f45abb..1f43c856 100644 --- a/src/Api/Jobs/EditPostJob.php +++ b/src/Api/Jobs/EditPostJob.php @@ -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); diff --git a/src/Api/Jobs/EditPostRelationsJob.php b/src/Api/Jobs/EditPostRelationsJob.php index 722acb92..315e496e 100644 --- a/src/Api/Jobs/EditPostRelationsJob.php +++ b/src/Api/Jobs/EditPostRelationsJob.php @@ -1,17 +1,15 @@ 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); diff --git a/src/Api/Jobs/EditPostSafetyJob.php b/src/Api/Jobs/EditPostSafetyJob.php index 5ef3a44c..c2bc3182 100644 --- a/src/Api/Jobs/EditPostSafetyJob.php +++ b/src/Api/Jobs/EditPostSafetyJob.php @@ -1,17 +1,15 @@ 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); diff --git a/src/Api/Jobs/EditPostSourceJob.php b/src/Api/Jobs/EditPostSourceJob.php index d9133b4c..23337302 100644 --- a/src/Api/Jobs/EditPostSourceJob.php +++ b/src/Api/Jobs/EditPostSourceJob.php @@ -1,17 +1,15 @@ 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); diff --git a/src/Api/Jobs/EditPostTagsJob.php b/src/Api/Jobs/EditPostTagsJob.php index 877e1ff6..8bc0164c 100644 --- a/src/Api/Jobs/EditPostTagsJob.php +++ b/src/Api/Jobs/EditPostTagsJob.php @@ -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'); diff --git a/src/Api/Jobs/EditPostThumbJob.php b/src/Api/Jobs/EditPostThumbJob.php index 1649e435..d6619002 100644 --- a/src/Api/Jobs/EditPostThumbJob.php +++ b/src/Api/Jobs/EditPostThumbJob.php @@ -1,17 +1,15 @@ 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); diff --git a/src/Api/Jobs/EditUserAccessRankJob.php b/src/Api/Jobs/EditUserAccessRankJob.php index 09d646c0..f8398236 100644 --- a/src/Api/Jobs/EditUserAccessRankJob.php +++ b/src/Api/Jobs/EditUserAccessRankJob.php @@ -1,17 +1,15 @@ 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) diff --git a/src/Api/Jobs/EditUserEmailJob.php b/src/Api/Jobs/EditUserEmailJob.php index f02d14a2..6eb64418 100644 --- a/src/Api/Jobs/EditUserEmailJob.php +++ b/src/Api/Jobs/EditUserEmailJob.php @@ -1,21 +1,19 @@ 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) diff --git a/src/Api/Jobs/EditUserJob.php b/src/Api/Jobs/EditUserJob.php index 70775e48..be08f19a 100644 --- a/src/Api/Jobs/EditUserJob.php +++ b/src/Api/Jobs/EditUserJob.php @@ -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); diff --git a/src/Api/Jobs/EditUserNameJob.php b/src/Api/Jobs/EditUserNameJob.php index 2bcf6eb4..85eee44f 100644 --- a/src/Api/Jobs/EditUserNameJob.php +++ b/src/Api/Jobs/EditUserNameJob.php @@ -1,17 +1,15 @@ 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) diff --git a/src/Api/Jobs/EditUserPasswordJob.php b/src/Api/Jobs/EditUserPasswordJob.php index c66fa27e..ecdc1626 100644 --- a/src/Api/Jobs/EditUserPasswordJob.php +++ b/src/Api/Jobs/EditUserPasswordJob.php @@ -1,17 +1,15 @@ 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); diff --git a/src/Api/Jobs/FeaturePostJob.php b/src/Api/Jobs/FeaturePostJob.php index 4698f631..41c957b8 100644 --- a/src/Api/Jobs/FeaturePostJob.php +++ b/src/Api/Jobs/FeaturePostJob.php @@ -1,8 +1,6 @@ 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()); diff --git a/src/Api/Jobs/GetLogJob.php b/src/Api/Jobs/GetLogJob.php index e033b4a7..2796193e 100644 --- a/src/Api/Jobs/GetLogJob.php +++ b/src/Api/Jobs/GetLogJob.php @@ -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)); diff --git a/src/Api/Jobs/GetPostContentJob.php b/src/Api/Jobs/GetPostContentJob.php index c5c3b6f2..a1b65fef 100644 --- a/src/Api/Jobs/GetPostContentJob.php +++ b/src/Api/Jobs/GetPostContentJob.php @@ -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() diff --git a/src/Api/Jobs/GetPostThumbJob.php b/src/Api/Jobs/GetPostThumbJob.php index 14a59e0a..0f550cb1 100644 --- a/src/Api/Jobs/GetPostThumbJob.php +++ b/src/Api/Jobs/GetPostThumbJob.php @@ -1,14 +1,11 @@ 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)) diff --git a/src/Api/Jobs/ListCommentsJob.php b/src/Api/Jobs/ListCommentsJob.php index 741c702d..f75c8447 100644 --- a/src/Api/Jobs/ListCommentsJob.php +++ b/src/Api/Jobs/ListCommentsJob.php @@ -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); diff --git a/src/Api/Jobs/ListPostsJob.php b/src/Api/Jobs/ListPostsJob.php index eaa584ae..e1104903 100644 --- a/src/Api/Jobs/ListPostsJob.php +++ b/src/Api/Jobs/ListPostsJob.php @@ -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); diff --git a/src/Api/Jobs/ListRelatedTagsJob.php b/src/Api/Jobs/ListRelatedTagsJob.php index 8ee5b77c..dd13b865 100644 --- a/src/Api/Jobs/ListRelatedTagsJob.php +++ b/src/Api/Jobs/ListRelatedTagsJob.php @@ -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); diff --git a/src/Api/Jobs/ListTagsJob.php b/src/Api/Jobs/ListTagsJob.php index 00175e2f..d6b7ccd4 100644 --- a/src/Api/Jobs/ListTagsJob.php +++ b/src/Api/Jobs/ListTagsJob.php @@ -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); diff --git a/src/Api/Jobs/ListUsersJob.php b/src/Api/Jobs/ListUsersJob.php index a1991058..e49e1128 100644 --- a/src/Api/Jobs/ListUsersJob.php +++ b/src/Api/Jobs/ListUsersJob.php @@ -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); diff --git a/src/Api/Jobs/MergeTagsJob.php b/src/Api/Jobs/MergeTagsJob.php index 8f1871b7..e9b2d35b 100644 --- a/src/Api/Jobs/MergeTagsJob.php +++ b/src/Api/Jobs/MergeTagsJob.php @@ -1,13 +1,10 @@ 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); diff --git a/src/Api/Jobs/PasswordResetJob.php b/src/Api/Jobs/PasswordResetJob.php index 785a431c..087ab6fb 100644 --- a/src/Api/Jobs/PasswordResetJob.php +++ b/src/Api/Jobs/PasswordResetJob.php @@ -1,14 +1,11 @@ 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); diff --git a/src/Api/Jobs/PreviewCommentJob.php b/src/Api/Jobs/PreviewCommentJob.php index e159e8b6..599c5199 100644 --- a/src/Api/Jobs/PreviewCommentJob.php +++ b/src/Api/Jobs/PreviewCommentJob.php @@ -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); diff --git a/src/Api/Jobs/RenameTagsJob.php b/src/Api/Jobs/RenameTagsJob.php index a8af9476..22796e67 100644 --- a/src/Api/Jobs/RenameTagsJob.php +++ b/src/Api/Jobs/RenameTagsJob.php @@ -1,13 +1,10 @@ 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); diff --git a/src/Api/Jobs/ScorePostJob.php b/src/Api/Jobs/ScorePostJob.php index edb8bef8..95fb1206 100644 --- a/src/Api/Jobs/ScorePostJob.php +++ b/src/Api/Jobs/ScorePostJob.php @@ -1,12 +1,10 @@ post; - $score = intval($this->getArgument(self::SCORE)); + $score = intval($this->getArgument(JobArgs::ARG_NEW_POST_SCORE)); UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score); diff --git a/src/Api/Jobs/TogglePostFavoriteJob.php b/src/Api/Jobs/TogglePostFavoriteJob.php index 03c7e46e..986a8c64 100644 --- a/src/Api/Jobs/TogglePostFavoriteJob.php +++ b/src/Api/Jobs/TogglePostFavoriteJob.php @@ -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) { diff --git a/src/Api/Jobs/TogglePostTagJob.php b/src/Api/Jobs/TogglePostTagJob.php index 9e851c63..364025dc 100644 --- a/src/Api/Jobs/TogglePostTagJob.php +++ b/src/Api/Jobs/TogglePostTagJob.php @@ -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(); diff --git a/src/Api/Jobs/TogglePostVisibilityJob.php b/src/Api/Jobs/TogglePostVisibilityJob.php index 2d0e3478..7cda94f1 100644 --- a/src/Api/Jobs/TogglePostVisibilityJob.php +++ b/src/Api/Jobs/TogglePostVisibilityJob.php @@ -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); diff --git a/src/Api/Jobs/ToggleUserBanJob.php b/src/Api/Jobs/ToggleUserBanJob.php index 59ef1167..ec1434c7 100644 --- a/src/Api/Jobs/ToggleUserBanJob.php +++ b/src/Api/Jobs/ToggleUserBanJob.php @@ -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(); diff --git a/src/Controllers/CommentController.php b/src/Controllers/CommentController.php index 9a0e9519..c45e3c35 100644 --- a/src/Controllers/CommentController.php +++ b/src/Controllers/CommentController.php @@ -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, ]); } } diff --git a/src/Controllers/LogController.php b/src/Controllers/LogController.php index 69b48fa6..2be7c838 100644 --- a/src/Controllers/LogController.php +++ b/src/Controllers/LogController.php @@ -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 diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index a860ad0c..934ac5eb 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -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; diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php index fead2b0f..e7d3635c 100644 --- a/src/Controllers/TagController.php +++ b/src/Controllers/TagController.php @@ -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.'); diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index d19a0d17..018f1d56 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -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**.', diff --git a/tests/Api/ApiAuthTest.php b/tests/Api/ApiAuthTest.php index 58ba77ff..5b810737 100644 --- a/tests/Api/ApiAuthTest.php +++ b/tests/Api/ApiAuthTest.php @@ -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'); } diff --git a/tests/Api/ApiEmailRequirementsTest.php b/tests/Api/ApiEmailRequirementsTest.php index 8b3cb0f6..f7429019 100644 --- a/tests/Api/ApiEmailRequirementsTest.php +++ b/tests/Api/ApiEmailRequirementsTest.php @@ -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'); } diff --git a/tests/Api/ApiPrivilegeTest.php b/tests/Api/ApiPrivilegeTest.php index 3e5f2c1b..09454ea0 100644 --- a/tests/Api/ApiPrivilegeTest.php +++ b/tests/Api/ApiPrivilegeTest.php @@ -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'); } diff --git a/tests/JobTests/ActivateUserEmailJobTest.php b/tests/JobTests/ActivateUserEmailJobTest.php index 94160e7a..3eceb5d1 100644 --- a/tests/JobTests/ActivateUserEmailJobTest.php +++ b/tests/JobTests/ActivateUserEmailJobTest.php @@ -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; diff --git a/tests/JobTests/AddCommentJobTest.php b/tests/JobTests/AddCommentJobTest.php index 8ee776a1..447e8c70 100644 --- a/tests/JobTests/AddCommentJobTest.php +++ b/tests/JobTests/AddCommentJobTest.php @@ -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, ]); } diff --git a/tests/JobTests/AddPostJobTest.php b/tests/JobTests/AddPostJobTest.php index 4d1a8311..ef2e8fa4 100644 --- a/tests/JobTests/AddPostJobTest.php +++ b/tests/JobTests/AddPostJobTest.php @@ -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'); } diff --git a/tests/JobTests/AddUserJobTest.php b/tests/JobTests/AddUserJobTest.php index ddc55492..6caf6b4f 100644 --- a/tests/JobTests/AddUserJobTest.php +++ b/tests/JobTests/AddUserJobTest.php @@ -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', ]); }); diff --git a/tests/JobTests/DeleteCommentJobTest.php b/tests/JobTests/DeleteCommentJobTest.php index b438475a..5724a9ef 100644 --- a/tests/JobTests/DeleteCommentJobTest.php +++ b/tests/JobTests/DeleteCommentJobTest.php @@ -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'); } diff --git a/tests/JobTests/EditCommentJobTest.php b/tests/JobTests/EditCommentJobTest.php index 492396f6..9616e6cd 100644 --- a/tests/JobTests/EditCommentJobTest.php +++ b/tests/JobTests/EditCommentJobTest.php @@ -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, ]); } diff --git a/tests/JobTests/EditPostContentJobTest.php b/tests/JobTests/EditPostContentJobTest.php index bb1234b4..4c3652af 100644 --- a/tests/JobTests/EditPostContentJobTest.php +++ b/tests/JobTests/EditPostContentJobTest.php @@ -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( diff --git a/tests/JobTests/EditPostJobTest.php b/tests/JobTests/EditPostJobTest.php index 25050e7d..4308a906 100644 --- a/tests/JobTests/EditPostJobTest.php +++ b/tests/JobTests/EditPostJobTest.php @@ -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) diff --git a/tests/JobTests/EditPostSourceJobTest.php b/tests/JobTests/EditPostSourceJobTest.php index f4f5556b..5e2c6526 100644 --- a/tests/JobTests/EditPostSourceJobTest.php +++ b/tests/JobTests/EditPostSourceJobTest.php @@ -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 ]); } diff --git a/tests/JobTests/EditPostTagsJobTest.php b/tests/JobTests/EditPostTagsJobTest.php index 4d38c6e1..9ecaea6b 100644 --- a/tests/JobTests/EditPostTagsJobTest.php +++ b/tests/JobTests/EditPostTagsJobTest.php @@ -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'); } diff --git a/tests/JobTests/EditUserEmailJobTest.php b/tests/JobTests/EditUserEmailJobTest.php index d0a66ad4..92ab7ba0 100644 --- a/tests/JobTests/EditUserEmailJobTest.php +++ b/tests/JobTests/EditUserEmailJobTest.php @@ -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'); diff --git a/tests/JobTests/EditUserJobTest.php b/tests/JobTests/EditUserJobTest.php index ed1f396f..55fb8985 100644 --- a/tests/JobTests/EditUserJobTest.php +++ b/tests/JobTests/EditUserJobTest.php @@ -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', ]); }); diff --git a/tests/JobTests/FeaturePostJobTest.php b/tests/JobTests/FeaturePostJobTest.php index e8d9c76d..a9d77c83 100644 --- a/tests/JobTests/FeaturePostJobTest.php +++ b/tests/JobTests/FeaturePostJobTest.php @@ -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, ]); }); diff --git a/tests/JobTests/ListCommentsJobTest.php b/tests/JobTests/ListCommentsJobTest.php index 9d59b8f1..1d3706af 100644 --- a/tests/JobTests/ListCommentsJobTest.php +++ b/tests/JobTests/ListCommentsJobTest.php @@ -64,7 +64,7 @@ class ListCommentJobTest extends AbstractTest return Api::run( new ListCommentsJob(), [ - ListCommentsJob::PAGE_NUMBER => $page, + JobArgs::ARG_PAGE_NUMBER => $page, ]); } } diff --git a/tests/JobTests/PreviewCommentJobTest.php b/tests/JobTests/PreviewCommentJobTest.php index 03a74f59..b77f786d 100644 --- a/tests/JobTests/PreviewCommentJobTest.php +++ b/tests/JobTests/PreviewCommentJobTest.php @@ -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, ]); } diff --git a/tests/JobTests/ScorePostJobTest.php b/tests/JobTests/ScorePostJobTest.php index 60543118..2a7415f3 100644 --- a/tests/JobTests/ScorePostJobTest.php +++ b/tests/JobTests/ScorePostJobTest.php @@ -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, ]); }); diff --git a/tests/JobTests/TogglePostFavoriteJobTest.php b/tests/JobTests/TogglePostFavoriteJobTest.php index 54a865f3..fccd90af 100644 --- a/tests/JobTests/TogglePostFavoriteJobTest.php +++ b/tests/JobTests/TogglePostFavoriteJobTest.php @@ -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, ]); }); diff --git a/tests/JobTests/TogglePostVisibilityJobTest.php b/tests/JobTests/TogglePostVisibilityJobTest.php index 9ce50e55..14f4bb2b 100644 --- a/tests/JobTests/TogglePostVisibilityJobTest.php +++ b/tests/JobTests/TogglePostVisibilityJobTest.php @@ -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, ]); });