2014-05-11 23:40:09 +02:00
|
|
|
<?php
|
|
|
|
class FeaturePostJobTest extends AbstractTest
|
|
|
|
{
|
|
|
|
public function testFeaturing()
|
|
|
|
{
|
|
|
|
$this->grantAccess('featurePost');
|
|
|
|
|
|
|
|
$user = $this->mockUser();
|
|
|
|
$this->login($user);
|
|
|
|
$post1 = $this->mockPost($user);
|
|
|
|
$post2 = $this->mockPost($user);
|
|
|
|
|
|
|
|
$this->assert->doesNotThrow(function() use ($post2)
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new FeaturePostJob(),
|
|
|
|
[
|
2014-05-12 00:13:18 +02:00
|
|
|
JobArgs::ARG_POST_ID => $post2->getId()
|
2014-05-11 23:40:09 +02:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->areEqual($post2->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');
|
|
|
|
|
|
|
|
$user = $this->mockUser();
|
|
|
|
$this->login($user);
|
|
|
|
$post1 = $this->mockPost($user);
|
|
|
|
$post2 = $this->mockPost($user);
|
|
|
|
|
|
|
|
$this->assert->doesNotThrow(function() use ($post2)
|
|
|
|
{
|
|
|
|
Api::run(
|
|
|
|
new FeaturePostJob(),
|
|
|
|
[
|
2014-05-12 00:13:18 +02:00
|
|
|
JobArgs::ARG_POST_ID => $post2->getId(),
|
|
|
|
JobArgs::ARG_ANONYMOUS => true,
|
2014-05-11 23:40:09 +02:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->assert->areEqual($post2->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
|
|
|
|
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostUserName));
|
|
|
|
}
|
|
|
|
}
|