2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class FeaturedTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testFeatured(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
// Set up
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_user();
|
|
|
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
2009-07-19 18:35:46 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
# FIXME: test that regular users can't feature things
|
2009-07-20 06:31:41 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Admin can feature things
|
2024-04-07 09:25:58 +00:00
|
|
|
$this->log_in_as_admin();
|
|
|
|
$page = $this->post_page("featured_image/set/$image_id");
|
|
|
|
$this->assertEquals(302, $page->code);
|
2015-09-21 09:05:32 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page("post/list");
|
2020-10-26 13:46:00 +00:00
|
|
|
$this->assert_text("Featured Post");
|
2012-03-10 17:39:38 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
# FIXME: test changing from one feature to another
|
2012-03-10 17:39:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page("featured_image/download");
|
|
|
|
$this->assertEquals(200, $page->code);
|
2012-03-10 17:39:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page("featured_image/view");
|
|
|
|
$this->assertEquals(200, $page->code);
|
2012-03-10 17:39:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// after deletion, there should be no feature
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->delete_image($image_id);
|
|
|
|
$this->get_page("post/list");
|
2020-10-26 13:46:00 +00:00
|
|
|
$this->assert_no_text("Featured Post");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-07-19 18:35:46 +00:00
|
|
|
}
|