4ba83e6834
Restored JobArgs approach. Previous introduction of hierarchic argument definitions has backfired: it was confusing what class to take arguments from, the concept of sharing arguments between different jobs was unintelligible and one never knew where given argument was actually defined. This appraoch makes it easier to maintain the arguments list and simplifies the code a lot.
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(),
|
|
[
|
|
JobArgs::ARG_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(),
|
|
[
|
|
JobArgs::ARG_POST_ID => $post2->getId(),
|
|
JobArgs::ARG_ANONYMOUS => true,
|
|
]);
|
|
});
|
|
|
|
$this->assert->areEqual($post2->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
|
|
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostUserName));
|
|
}
|
|
}
|