szurubooru/tests/Tests/JobTests/FeaturePostJobTest.php
2014-05-13 21:16:28 +02:00

46 lines
1.2 KiB
PHP

<?php
class FeaturePostJobTest extends AbstractTest
{
public function testFeaturing()
{
$this->grantAccess('featurePost');
$user = $this->userMocker->mockSingle();
$this->login($user);
$posts = $this->postMocker->mockMultiple(2);
$this->assert->doesNotThrow(function() use ($posts)
{
Api::run(
new FeaturePostJob(),
[
JobArgs::ARG_POST_ID => $posts[1]->getId()
]);
});
$this->assert->areEqual($posts[1]->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
$this->assert->areEqual($user->getName(), PropertyModel::get(PropertyModel::FeaturedPostUserName));
$this->assert->isNotNull(PropertyModel::get(PropertyModel::FeaturedPostUnixTime));
}
public function testAnonymousFeaturing()
{
$this->grantAccess('featurePost');
$this->login($this->userMocker->mockSingle());
$posts = $this->postMocker->mockMultiple(2);
$this->assert->doesNotThrow(function() use ($posts)
{
Api::run(
new FeaturePostJob(),
[
JobArgs::ARG_POST_ID => $posts[1]->getId(),
JobArgs::ARG_ANONYMOUS => true,
]);
});
$this->assert->areEqual($posts[1]->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostUserName));
}
}