8aa499a0b9
- Fixed main page view - Code moved from StaticPagesController to PostModel - Code split into semantically meaningful methods - Allowed anonymous featuring through API - Added protection against automatic featuring of hidden post
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?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(),
|
|
[
|
|
FeaturePostJob::POST_ID => $post2->getId()
|
|
]);
|
|
});
|
|
|
|
$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(),
|
|
[
|
|
FeaturePostJob::POST_ID => $post2->getId(),
|
|
FeaturePostJob::ANONYMOUS => true,
|
|
]);
|
|
});
|
|
|
|
$this->assert->areEqual($post2->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
|
|
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostUserName));
|
|
}
|
|
}
|