szurubooru/tests/Tests/JobTests/FeaturePostJobTest.php
Marcin Kurczewski c501ccdff1 Fixed issues with variable types
- False booleans were serialized as NULLs, which lead to problems with
  queries like 'SELECT ... WHERE NOT x'
- Fixed anonymous uploads
- More robust integer and boolean parsing in jobs
2014-05-18 21:32:47 +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 => '1',
]);
});
$this->assert->areEqual($posts[1]->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
$this->assert->isNull(PropertyModel::get(PropertyModel::FeaturedPostUserName));
}
}