Changed thumb to thumbnail for consistency

This commit is contained in:
Marcin Kurczewski 2014-05-20 19:20:07 +02:00
parent 65e909d053
commit e12308d3cc
29 changed files with 130 additions and 136 deletions

View file

@ -4,9 +4,9 @@ dbLocation = "./data/db.sqlite"
dbUser = "test"
dbPass = "test"
filesPath = "./data/files/"
thumbsPath = "./public_html/thumbs/"
logsPath = "./data/logs/{yyyy}-{mm}.log"
mediaPath = "./public_html/media/"
thumbnailsPath = "./public_html/thumbs/"
title = "szurubooru"
salt = "1A2/$_4xVa"
@ -31,9 +31,9 @@ postsPerPage=20
logsPerPage=250
tagsPerPage=100
tagsRelated=15
thumbWidth=150
thumbHeight=150
thumbStyle=outside
thumbnailWidth=150
thumbnailHeight=150
thumbnailStyle=outside
endlessScrollingDefault=1
showPostTagTitlesDefault=0
showDislikedPostsDefault=1
@ -95,7 +95,7 @@ favoritePost=registered
addPost=registered
addPostSafety=registered
addPostTags=registered
addPostThumb=power-user
addPostThumbnail=power-user
addPostSource=registered
addPostRelations=power-user
addPostContent=registered
@ -104,7 +104,7 @@ editPost=registered
editPostSafety.own=registered
editPostSafety.all=moderator
editPostTags=registered
editPostThumb=moderator
editPostThumbnail=moderator
editPostSource=moderator
editPostRelations.own=registered
editPostRelations.all=moderator

View file

@ -13,8 +13,8 @@ foreach ($posts as $post)
{
++ $i;
printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount);
if (!$post->tryGetWorkingThumbPath())
$post->generateThumb();
if (!$post->tryGetWorkingThumbnailPath())
$post->generateThumbnail();
}
echo 'Don\'t forget to check access rights.';
echo 'Don\'t forget to check access rights.' . PHP_EOL;

View file

@ -32,7 +32,7 @@ class JobArgs
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_THUMBNAIL_CONTENT = 'new-thumbnail-content';
const ARG_NEW_TAG_NAMES = 'new-tag-names';
const ARG_NEW_ACCESS_RANK = 'new-access-rank';

View file

@ -8,7 +8,7 @@ class AddPostJob extends AbstractJob
$this->addSubJob(new EditPostSourceJob());
$this->addSubJob(new EditPostRelationsJob());
$this->addSubJob(new EditPostContentJob());
$this->addSubJob(new EditPostThumbJob());
$this->addSubJob(new EditPostThumbnailJob());
}
public function execute()

View file

@ -11,7 +11,7 @@ class EditPostJob extends AbstractJob
$this->addSubJob(new EditPostSourceJob());
$this->addSubJob(new EditPostRelationsJob());
$this->addSubJob(new EditPostContentJob());
$this->addSubJob(new EditPostThumbJob());
$this->addSubJob(new EditPostThumbnailJob());
}
public function execute()

View file

@ -1,5 +1,5 @@
<?php
class EditPostThumbJob extends AbstractJob
class EditPostThumbnailJob extends AbstractJob
{
protected $postRetriever;
@ -11,7 +11,7 @@ class EditPostThumbJob extends AbstractJob
public function execute()
{
$post = $this->postRetriever->retrieve();
$file = $this->getArgument(JobArgs::ARG_NEW_THUMB_CONTENT);
$file = $this->getArgument(JobArgs::ARG_NEW_THUMBNAIL_CONTENT);
$post->setCustomThumbnailFromPath($file->filePath);
@ -29,14 +29,14 @@ class EditPostThumbJob extends AbstractJob
{
return JobArgs::Conjunction(
$this->postRetriever->getRequiredArguments(),
JobArgs::ARG_NEW_THUMB_CONTENT);
JobArgs::ARG_NEW_THUMBNAIL_CONTENT);
}
public function getRequiredMainPrivilege()
{
return $this->getContext() == self::CONTEXT_BATCH_ADD
? Privilege::AddPostThumb
: Privilege::EditPostThumb;
? Privilege::AddPostThumbnail
: Privilege::EditPostThumbnail;
}
public function getRequiredSubPrivileges()

View file

@ -1,5 +1,5 @@
<?php
class GetPostThumbJob extends AbstractJob
class GetPostThumbnailJob extends AbstractJob
{
protected $postRetriever;
@ -19,18 +19,18 @@ class GetPostThumbJob extends AbstractJob
$name = $post->getName();
}
$path = PostModel::tryGetWorkingThumbPath($name);
$path = PostModel::tryGetWorkingThumbnailPath($name);
if (!$path)
{
$post = PostModel::getByName($name);
$post = $this->postRetriever->retrieve();
$post->generateThumb();
$path = PostModel::tryGetWorkingThumbPath($name);
$post->generateThumbnail();
$path = PostModel::tryGetWorkingThumbnailPath($name);
if (!$path)
{
$path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg';
$path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumbnail.jpg';
$path = TextHelper::absolutePath($path);
}
}

View file

@ -186,12 +186,12 @@ class PostController extends AbstractController
$file['name']);
}
if (!empty($_FILES['thumb']['name']))
if (!empty($_FILES['thumbnail']['name']))
{
$file = $_FILES['thumb'];
$file = $_FILES['thumbnail'];
TransferHelper::handleUploadErrors($file);
$jobArgs[JobArgs::ARG_NEW_THUMB_CONTENT] = new ApiFileInput(
$jobArgs[JobArgs::ARG_NEW_THUMBNAIL_CONTENT] = new ApiFileInput(
$file['tmp_name'],
$file['name']);
}
@ -321,9 +321,9 @@ class PostController extends AbstractController
$this->renderFile();
}
public function thumbView($name)
public function thumbnailView($name)
{
$ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]);
$ret = Api::run(new GetPostThumbnailJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = Core::getContext();
$context->transport->cacheDaysToLive = 365;

View file

@ -14,7 +14,7 @@ class Privilege extends AbstractEnum implements IEnum
const EditPost = 'editPost';
const EditPostSafety = 'editPostSafety';
const EditPostTags = 'editPostTags';
const EditPostThumb = 'editPostThumb';
const EditPostThumbnail = 'editPostThumbnail';
const EditPostSource = 'editPostSource';
const EditPostRelations = 'editPostRelations';
const EditPostContent = 'editPostContent';
@ -22,7 +22,7 @@ class Privilege extends AbstractEnum implements IEnum
const AddPost = 'addPost';
const AddPostSafety = 'addPostSafety';
const AddPostTags = 'addPostTags';
const AddPostThumb = 'addPostThumb';
const AddPostThumbnail = 'addPostThumbnail';
const AddPostSource = 'addPostSource';
const AddPostRelations = 'addPostRelations';
const AddPostContent = 'addPostContent';

View file

@ -1,7 +1,7 @@
<?php
class Assets extends \Chibi\Util\Assets
{
private $pageThumb = null;
private $pageThumbnail = null;
private $subTitle = null;
public function setSubTitle($text)
@ -9,9 +9,9 @@ class Assets extends \Chibi\Util\Assets
$this->subTitle = $text;
}
public function setPageThumb($path)
public function setPageThumbnail($path)
{
$this->pageThumb = $path;
$this->pageThumbnail = $path;
}
public function addStylesheet($path)
@ -34,8 +34,8 @@ class Assets extends \Chibi\Util\Assets
$headSnippet = '<meta property="og:title" content="' . $this->title . '"/>';
$headSnippet .= '<meta property="og:url" content="' . \Chibi\Util\Url::currentUrl() . '"/>';
if (!empty($this->pageThumb))
$headSnippet .= '<meta property="og:image" content="' . $this->pageThumb . '"/>';
if (!empty($this->pageThumbnail))
$headSnippet .= '<meta property="og:image" content="' . $this->pageThumbnail . '"/>';
$bodySnippet = '<script type="text/javascript">';
$bodySnippet .= '$(function() {';

View file

@ -351,25 +351,25 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
return PostModel::getFullPath($this->getName());
}
public function tryGetWorkingThumbPath()
public function tryGetWorkingThumbnailPath()
{
return PostModel::tryGetWorkingThumbPath($this->getName());
return PostModel::tryGetWorkingThumbnailPath($this->getName());
}
public function getThumbCustomSourcePath()
public function getCustomThumbnailSourcePath()
{
return PostModel::getThumbCustomSourcePath($this->getName());
return PostModel::getCustomThumbnailSourcePath($this->getName());
}
public function getThumbPath()
public function getThumbnailPath()
{
return PostModel::getThumbPath($this->getName());
return PostModel::getThumbnailPath($this->getName());
}
public function hasCustomThumb()
public function hasCustomThumbnail()
{
$thumbPath = $this->getThumbCustomSourcePath();
return file_exists($thumbPath);
$thumbnailPath = $this->getCustomThumbnailSourcePath();
return file_exists($thumbnailPath);
}
public function setCustomThumbnailFromPath($srcPath)
@ -378,27 +378,27 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
$mimeType = mime_content_type($srcPath);
if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg']))
throw new SimpleException('Invalid thumbnail type "%s"', $mimeType);
throw new SimpleException('Invalid file type "%s"', $mimeType);
$dstPath = $this->getThumbCustomSourcePath();
$dstPath = $this->getCustomThumbnailSourcePath();
TransferHelper::copy($srcPath, $dstPath);
$this->generateThumb();
$this->generateThumbnail();
}
public function generateThumb()
public function generateThumbnail()
{
$width = Core::getConfig()->browsing->thumbWidth;
$height = Core::getConfig()->browsing->thumbHeight;
$dstPath = $this->getThumbPath($width, $height);
$width = Core::getConfig()->browsing->thumbnailWidth;
$height = Core::getConfig()->browsing->thumbnailHeight;
$dstPath = $this->getThumbnailPath($width, $height);
$thumbnailGenerator = new SmartThumbnailGenerator();
if (file_exists($this->getThumbCustomSourcePath()))
if (file_exists($this->getCustomThumbnailSourcePath()))
{
return $thumbnailGenerator->generateFromFile(
$this->getThumbCustomSourcePath(),
$this->getCustomThumbnailSourcePath(),
$dstPath,
$width,
$height);
@ -475,9 +475,9 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
TransferHelper::copy($srcPath, $dstPath);
$thumbPath = $this->getThumbPath();
if (file_exists($thumbPath))
unlink($thumbPath);
$thumbnailPath = $this->getThumbnailPath();
if (file_exists($thumbnailPath))
unlink($thumbnailPath);
}
public function setContentFromUrl($srcUrl)
@ -497,9 +497,9 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
$this->setImageWidth(null);
$this->setImageHeight(null);
$thumbPath = $this->getThumbPath();
if (file_exists($thumbPath))
unlink($thumbPath);
$thumbnailPath = $this->getThumbnailPath();
if (file_exists($thumbnailPath))
unlink($thumbnailPath);
$duplicatedPost = PostModel::tryGetByHash($youtubeId);
if ($duplicatedPost !== null and (!$this->getId() or $this->getId() != $duplicatedPost->getId()))

View file

@ -255,29 +255,23 @@ final class PostModel extends AbstractCrudModel
public static function tryGetWorkingThumbPath($name)
public static function tryGetWorkingThumbnailPath($name)
{
$path = PostModel::getThumbPath($name);
$path = PostModel::getThumbnailPath($name);
if (file_exists($path) and is_readable($path))
return $path;
return null;
}
public static function getThumbCustomSourcePath($name)
public static function getCustomThumbnailSourcePath($name)
{
return self::getThumbPathTokenized('{fullpath}.thumb_source', $name);
return Core::getConfig()->main->thumbnailsPath . DS . $name . '.thumb_source';
}
public static function getThumbPath($name)
public static function getThumbnailPath($name)
{
return self::getThumbPathTokenized('{fullpath}.thumb', $name);
}
private static function getThumbPathTokenized($text, $name)
{
return TextHelper::absolutePath(TextHelper::replaceTokens($text, [
'fullpath' => Core::getConfig()->main->thumbsPath . DS . $name]));
return Core::getConfig()->main->thumbnailsPath . DS . $name . '.thumb';
}
public static function tryGetWorkingFullPath($name)
@ -303,7 +297,7 @@ final class PostModel extends AbstractCrudModel
return PropertyModel::get(PropertyModel::PostSpaceUsage);
$totalBytes = 0;
$paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbsPath];
$paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbnailsPath];
foreach ($paths as $path)
{

View file

@ -24,7 +24,7 @@ class ImageGdThumbnailGenerator implements IThumbnailGenerator
}
$config = Core::getConfig();
switch ($config->browsing->thumbStyle)
switch ($config->browsing->thumbnailStyle)
{
case 'outside':
$dstImage = $this->cropOutside($srcImage, $width, $height);

View file

@ -7,7 +7,7 @@ class ImageImagickThumbnailGenerator implements IThumbnailGenerator
$image = $image->coalesceImages();
$config = Core::getConfig();
switch ($config->browsing->thumbStyle)
switch ($config->browsing->thumbnailStyle)
{
case 'outside':
$this->cropOutside($image, $width, $height);

View file

@ -89,13 +89,13 @@
}
if (Access::check(new Privilege(
Privilege::EditPostThumb,
Privilege::EditPostThumbnail,
Access::getIdentity($this->context->transport->post->getUploader()))))
{
$context = new StdClass;
$context->name = 'thumb';
$context->name = 'thumbnail';
$context->label = 'Thumb';
if ($this->context->transport->post->hasCustomThumb())
if ($this->context->transport->post->hasCustomThumbnail())
$context->additionalInfo = '(Currently using custom thumb)';
$this->renderExternal('input-file', $context);
}

View file

@ -1,6 +1,6 @@
<?php
$this->assets->setPageThumb(\Chibi\Router::linkTo(
['PostController', 'thumbView'],
$this->assets->setPageThumbnail(\Chibi\Router::linkTo(
['PostController', 'thumbnailView'],
['name' => $this->context->transport->post->getName()]));
$post = $this->context->transport->post;
?>

View file

@ -49,7 +49,7 @@ if ($masstag)
<img
class="thumb"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->getName()]) ?>"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbnailView'], ['name' => $this->context->post->getName()]) ?>"
alt="<?= TextHelper::reprPost($this->context->post) ?>"/>
<?php

View file

@ -11,7 +11,7 @@ $this->assets->addScript('../lib/tagit/jquery.tagit.js');
$editPostPrivileges = [
Privilege::EditPostSafety,
Privilege::EditPostTags,
Privilege::EditPostThumb,
Privilege::EditPostThumbnail,
Privilege::EditPostSource,
];
$editPostPrivileges = array_fill_keys($editPostPrivileges, false);

View file

@ -67,7 +67,7 @@ final class Core
$config = self::getConfig();
TransferHelper::createDirectory($config->main->filesPath);
TransferHelper::createDirectory($config->main->thumbsPath);
TransferHelper::createDirectory($config->main->thumbnailsPath);
//extension sanity checks
$requiredExtensions = ['pdo', 'pdo_' . $config->main->dbDriver, 'openssl', 'fileinfo'];

View file

@ -51,7 +51,7 @@ $postValidation =
\Chibi\Router::register(['PostController', 'genericView'], 'GET', '/post/{id}', $postValidation);
\Chibi\Router::register(['PostController', 'fileView'], 'GET', '/post/{name}/retrieve', $postValidation);
\Chibi\Router::register(['PostController', 'thumbView'], 'GET', '/post/{name}/thumb', $postValidation);
\Chibi\Router::register(['PostController', 'thumbnailView'], 'GET', '/post/{name}/thumb', $postValidation);
\Chibi\Router::register(['PostController', 'toggleTagAction'], null, '/post/{id}/toggle-tag/{tag}/{enable}', $postValidation);
\Chibi\Router::register(['PostController', 'flagAction'], null, '/post/{id}/flag', $postValidation);

View file

@ -112,7 +112,7 @@ class SzurubooruTestRunner implements ITestRunner
$folders =
[
realpath(Core::getConfig()->main->filesPath),
realpath(Core::getConfig()->main->thumbsPath),
realpath(Core::getConfig()->main->thumbnailsPath),
realpath(dirname(Core::getConfig()->main->logsPath)),
];

View file

@ -109,12 +109,12 @@ class ApiArgumentTest extends AbstractFullApiTest
JobArgs::ARG_NEW_TAG_NAMES));
}
public function testEditPostThumbJob()
public function testEditPostThumbnailJob()
{
$this->testArguments(new EditPostThumbJob(),
$this->testArguments(new EditPostThumbnailJob(),
JobArgs::Conjunction(
$this->getPostSelector(),
JobArgs::ARG_NEW_THUMB_CONTENT));
JobArgs::ARG_NEW_THUMBNAIL_CONTENT));
}
public function testEditUserAccessRankJob()
@ -201,9 +201,9 @@ class ApiArgumentTest extends AbstractFullApiTest
$this->getPostSelector());
}
public function testGetPostThumbJob()
public function testGetPostThumbnailJob()
{
$this->testArguments(new GetPostThumbJob(), $this->getPostSafeSelector());
$this->testArguments(new GetPostThumbnailJob(), $this->getPostSafeSelector());
}
public function testGetUserJob()

View file

@ -18,7 +18,7 @@ class ApiAuthTest extends AbstractFullApiTest
$this->testAuth(new EditPostSafetyJob(), false);
$this->testAuth(new EditPostSourceJob(), false);
$this->testAuth(new EditPostTagsJob(), false);
$this->testAuth(new EditPostThumbJob(), false);
$this->testAuth(new EditPostThumbnailJob(), false);
$this->testAuth(new EditUserJob(), false);
$this->testAuth(new EditUserAccessRankJob(), false);
$this->testAuth(new EditUserEmailJob(), false);
@ -32,7 +32,7 @@ class ApiAuthTest extends AbstractFullApiTest
$this->testAuth(new GetPropertyJob(), false);
$this->testAuth(new GetPostJob(), false);
$this->testAuth(new GetPostContentJob(), false);
$this->testAuth(new GetPostThumbJob(), false);
$this->testAuth(new GetPostThumbnailJob(), false);
$this->testAuth(new GetUserJob(), false);
$this->testAuth(new GetUserSettingsJob(), false);
$this->testAuth(new ListCommentsJob(), false);

View file

@ -19,7 +19,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testRegularEmailRequirement(new EditPostSafetyJob());
$this->testRegularEmailRequirement(new EditPostSourceJob());
$this->testRegularEmailRequirement(new EditPostTagsJob());
$this->testRegularEmailRequirement(new EditPostThumbJob());
$this->testRegularEmailRequirement(new EditPostThumbnailJob());
$this->testRegularEmailRequirement(new EditUserJob());
$this->testRegularEmailRequirement(new EditUserAccessRankJob());
$this->testRegularEmailRequirement(new EditUserEmailJob());
@ -33,7 +33,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testRegularEmailRequirement(new GetPropertyJob());
$this->testRegularEmailRequirement(new GetPostJob());
$this->testRegularEmailRequirement(new GetPostContentJob());
$this->testRegularEmailRequirement(new GetPostThumbJob());
$this->testRegularEmailRequirement(new GetPostThumbnailJob());
$this->testRegularEmailRequirement(new GetUserJob());
$this->testRegularEmailRequirement(new GetUserSettingsJob());
$this->testRegularEmailRequirement(new ListCommentsJob());

View file

@ -49,7 +49,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testDynamicPostPrivilege(new EditPostSafetyJob(), Privilege::EditPostSafety);
$this->testDynamicPostPrivilege(new EditPostSourceJob(), Privilege::EditPostSource);
$this->testDynamicPostPrivilege(new EditPostTagsJob(), Privilege::EditPostTags);
$this->testDynamicPostPrivilege(new EditPostThumbJob(), Privilege::EditPostThumb);
$this->testDynamicPostPrivilege(new EditPostThumbnailJob(), Privilege::EditPostThumbnail);
$ctx = function($job)
{
@ -61,7 +61,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testDynamicPostPrivilege($ctx(new EditPostSafetyJob), Privilege::AddPostSafety);
$this->testDynamicPostPrivilege($ctx(new EditPostSourceJob), Privilege::AddPostSource);
$this->testDynamicPostPrivilege($ctx(new EditPostTagsJob), Privilege::AddPostTags);
$this->testDynamicPostPrivilege($ctx(new EditPostThumbJob), Privilege::AddPostThumb);
$this->testDynamicPostPrivilege($ctx(new EditPostThumbnailJob), Privilege::AddPostThumbnail);
$this->testDynamicPostPrivilege(new FeaturePostJob(), Privilege::FeaturePost);
$this->testDynamicPostPrivilege(new FlagPostJob(), Privilege::FlagPost);
@ -117,9 +117,9 @@ class ApiPrivilegeTest extends AbstractFullApiTest
}
}
public function testDynamicPostThumbPrivileges()
public function testDynamicPostThumbnailPrivileges()
{
$job = new GetPostThumbJob();
$job = new GetPostThumbnailJob();
$this->testedJobs []= $job;
$this->assert->isNull($job->getRequiredMainPrivilege());
}

View file

@ -27,7 +27,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post)
{
$post->generateThumb();
$post->generateThumbnail();
});
}
@ -42,7 +42,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post)
{
$post->generateThumb();
$post->generateThumbnail();
});
}
@ -57,7 +57,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post)
{
$post->generateThumb();
$post->generateThumbnail();
});
}
@ -102,7 +102,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual('qWq_jydCUw4', $post->getFileHash());
$this->assert->doesNotThrow(function() use ($post)
{
$post->generateThumb();
$post->generateThumbnail();
});
$this->assert->doesNotThrow(function() use ($post)

View file

@ -1,25 +1,25 @@
<?php
class EditPostThumbJobTest extends AbstractTest
class EditPostThumbnailJobTest extends AbstractTest
{
public function testFile()
{
$this->grantAccess('editPostThumb');
$this->grantAccess('editPostThumbnail');
$post = $this->postMocker->mockSingle();
$this->assert->isFalse($post->hasCustomThumb());
$this->assert->isFalse($post->hasCustomThumbnail());
$post = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new EditPostThumbJob(),
new EditPostThumbnailJob(),
[
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_THUMB_CONTENT =>
JobArgs::ARG_NEW_THUMBNAIL_CONTENT =>
new ApiFileInput($this->testSupport->getPath('thumb.jpg'), 'test.jpg'),
]);
});
$this->assert->isTrue($post->hasCustomThumb());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbPath());
$this->assert->isTrue($post->hasCustomThumbnail());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbnailPath());
$this->assert->areEqual(150, imagesx($img));
$this->assert->areEqual(150, imagesy($img));
imagedestroy($img);
@ -27,23 +27,23 @@ class EditPostThumbJobTest extends AbstractTest
public function testFileDifferentDimensions()
{
$this->grantAccess('editPostThumb');
$this->grantAccess('editPostThumbnail');
$post = $this->postMocker->mockSingle();
$this->assert->isFalse($post->hasCustomThumb());
$this->assert->isFalse($post->hasCustomThumbnail());
$post = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new EditPostThumbJob(),
new EditPostThumbnailJob(),
[
JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_THUMB_CONTENT =>
JobArgs::ARG_NEW_THUMBNAIL_CONTENT =>
new ApiFileInput($this->testSupport->getPath('image.jpg'), 'test.jpg'),
]);
});
$this->assert->isTrue($post->hasCustomThumb());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbPath());
$this->assert->isTrue($post->hasCustomThumbnail());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbnailPath());
$this->assert->areEqual(150, imagesx($img));
$this->assert->areEqual(150, imagesy($img));
imagedestroy($img);

View file

@ -1,7 +1,7 @@
<?php
class GetPostThumbJobTest extends AbstractTest
class GetPostThumbnailJobTest extends AbstractTest
{
public function testThumbRetrieval()
public function testThumbnailRetrieval()
{
$this->grantAccess('viewPost');
$post = $this->postMocker->mockSingle();
@ -9,7 +9,7 @@ class GetPostThumbJobTest extends AbstractTest
$output = $this->assert->doesNotThrow(function() use ($post)
{
return Api::run(
new GetPostThumbJob(),
new GetPostThumbnailJob(),
[
JobArgs::ARG_POST_NAME => $post->getName(),
]);
@ -29,7 +29,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->throws(function()
{
Api::run(
new GetPostThumbJob(),
new GetPostThumbnailJob(),
[
JobArgs::ARG_POST_ID => 100,
]);
@ -43,7 +43,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->throws(function()
{
Api::run(
new GetPostThumbJob(),
new GetPostThumbnailJob(),
[
JobArgs::ARG_POST_NAME => 'nonsense',
]);

View file

@ -1,6 +1,6 @@
[main]
filesPath = "./tests/files/"
thumbsPath = "./tests/thumbs/"
thumbnailsPath = "./tests/thumbs/"
logsPath = "./tests/logs/{yyyy}-{mm}.log"
mediaPath = "./public_html/media/"
title = "szurubooru/tests"
@ -26,9 +26,9 @@ postsPerPage=20
logsPerPage=250
tagsPerPage=100
tagsRelated=15
thumbWidth=150
thumbHeight=150
thumbStyle=outside
thumbnailWidth=150
thumbnailHeight=150
thumbnailStyle=outside
endlessScrollingDefault=1
showPostTagTitlesDefault=0
showDislikedPostsDefault=1