This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/random_image/test.php

53 lines
1.7 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class RandomImageTest extends ShimmiePHPUnitTestCase
{
2024-01-15 14:31:51 +00:00
public function testRandom(): void
{
$this->log_in_as_user();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
$this->log_out();
$page = $this->get_page("random_image/view");
2020-10-26 15:17:15 +00:00
$this->assertEquals("Post $image_id: test", $page->title);
$page = $this->get_page("random_image/view/test");
2020-10-26 15:17:15 +00:00
$this->assertEquals("Post $image_id: test", $page->title);
$page = $this->get_page("random_image/download");
$this->assertNotNull($page->data);
# FIXME: assert($raw == file(blah.jpg))
}
2024-01-15 14:31:51 +00:00
public function testPostListBlock(): void
{
global $config;
$this->log_in_as_admin();
# enabled, no image = no text
$config->set_bool("show_random_block", true);
$page = $this->get_page("post/list");
$this->assertException(\Exception::class, function () use ($page) {$page->find_block("Random Post");});
# enabled, image = text
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
$page = $this->get_page("post/list");
2020-10-26 15:17:15 +00:00
$this->assertNotNull($page->find_block("Random Post"));
# disabled, image = no text
$config->set_bool("show_random_block", false);
$page = $this->get_page("post/list");
$this->assertException(\Exception::class, function () use ($page) {$page->find_block("Random Post");});
# disabled, no image = no image
$this->delete_image($image_id);
$page = $this->get_page("post/list");
$this->assertException(\Exception::class, function () use ($page) {$page->find_block("Random Post");});
}
2009-07-20 05:51:36 +00:00
}