szurubooru/tests/Tests/JobTests/EditPostThumbJobTest.php
Marcin Kurczewski c7250ae0a9 Improved thumbnail generating
- Moved thumbs folder to public_html/
- Users can supply custom thumbs of any size and the system will treat
  them like normal image
- Removed distinction between various thumb sizes in file system
- Introduced custom rewrite rule, which isn't exactly good-looking, but
  its benefits far outweigh its shortcomings
- Loading up to 75 times faster (was: 100-300ms, is: 4-10ms on my
  machine) thanks to removal of PHP proxying
2014-05-14 23:44:48 +02:00

51 lines
1.4 KiB
PHP

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