2014-05-13 21:08:07 +02:00
|
|
|
<?php
|
|
|
|
class GetPostContentJobTest extends AbstractTest
|
|
|
|
{
|
|
|
|
public function testPostRetrieval()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
$post = $this->postMocker->mockSingle();
|
|
|
|
|
|
|
|
$output = $this->assert->doesNotThrow(function() use ($post)
|
|
|
|
{
|
|
|
|
return Api::run(
|
|
|
|
new GetPostContentJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_NAME => $post->getName(),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2014-06-01 13:51:29 +02:00
|
|
|
$this->assert->isNotNull($post->getContentPath());
|
|
|
|
$this->assert->isTrue(file_exists($post->getContentPath()));
|
2014-05-13 21:08:07 +02:00
|
|
|
$this->assert->areEqual(
|
|
|
|
file_get_contents($this->testSupport->getPath('image.jpg')),
|
|
|
|
$output->fileContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIdFail()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
|
|
|
|
$this->assert->throws(function()
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new GetPostContentJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_ID => 100,
|
|
|
|
]);
|
|
|
|
}, 'unsatisfied');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInvalidName()
|
|
|
|
{
|
|
|
|
$this->grantAccess('viewPost');
|
|
|
|
|
|
|
|
$this->assert->throws(function()
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new GetPostContentJob(),
|
|
|
|
[
|
|
|
|
JobArgs::ARG_POST_NAME => 'nonsense',
|
|
|
|
]);
|
|
|
|
}, 'Invalid post name');
|
|
|
|
}
|
|
|
|
}
|