2014-05-13 21:08:07 +02:00
|
|
|
<?php
|
|
|
|
class GetPostThumbJobTest extends AbstractTest
|
|
|
|
{
|
|
|
|
public function testThumbRetrieval()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
$post = $this->postMocker->mockSingle();
|
|
|
|
|
|
|
|
$output = $this->assert->doesNotThrow(function() use ($post)
|
|
|
|
{
|
|
|
|
return Api::run(
|
|
|
|
new GetPostThumbJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->isNotNull($post->tryGetWorkingFullPath());
|
|
|
|
$this->assert->areEqual('image/jpeg', $output->mimeType);
|
2014-05-13 21:21:24 +02:00
|
|
|
$this->assert->areNotEqual(
|
|
|
|
file_get_contents(getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'),
|
|
|
|
$output->fileContent);
|
2014-05-13 21:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIdFail()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
|
|
|
|
$this->assert->throws(function()
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new GetPostThumbJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_ID => 100,
|
|
|
|
]);
|
|
|
|
}, 'unsatisfied');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInvalidName()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
|
|
|
|
$this->assert->throws(function()
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new GetPostThumbJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_NAME => 'nonsense',
|
|
|
|
]);
|
|
|
|
}, 'Invalid post name');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|