more tests
This commit is contained in:
parent
2f2f8e2eda
commit
1f9de8dd5a
7 changed files with 70 additions and 6 deletions
|
@ -161,6 +161,9 @@ if(class_exists("\\PHPUnit\\Framework\\TestCase")) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the page contains the given text somewhere in the blocks
|
||||
*/
|
||||
protected function assert_text(string $text, string $section = null): void
|
||||
{
|
||||
$this->assertStringContainsString($text, $this->page_to_text($section));
|
||||
|
@ -171,6 +174,9 @@ if(class_exists("\\PHPUnit\\Framework\\TestCase")) {
|
|||
$this->assertStringNotContainsString($text, $this->page_to_text($section));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the page contains the given text somewhere in the binary data
|
||||
*/
|
||||
protected function assert_content(string $content): void
|
||||
{
|
||||
global $page;
|
||||
|
|
|
@ -14,17 +14,13 @@ class Download extends Extension
|
|||
return 99;
|
||||
}
|
||||
|
||||
|
||||
public function onImageDownloading(ImageDownloadingEvent $event)
|
||||
{
|
||||
global $page;
|
||||
|
||||
$page->set_mime($event->mime);
|
||||
|
||||
$page->set_mode(PageMode::FILE);
|
||||
|
||||
$page->set_file($event->path, $event->file_modified);
|
||||
|
||||
$event->stop_processing = true;
|
||||
}
|
||||
}
|
||||
|
|
16
ext/download/test.php
Normal file
16
ext/download/test.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
class DownloadTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testView()
|
||||
{
|
||||
global $page;
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->get_page("/image/$image_id");
|
||||
$this->assertEquals(PageMode::FILE, $page->mode);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ class ETServer extends Extension
|
|||
{
|
||||
global $database, $page, $user;
|
||||
if ($event->page_matches("register.php")) {
|
||||
error_log("register.php");
|
||||
if (isset($_POST["data"])) {
|
||||
$database->execute(
|
||||
"INSERT INTO registration(data) VALUES(:data)",
|
||||
|
|
21
ext/et_server/test.php
Normal file
21
ext/et_server/test.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
class ETServerTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testView()
|
||||
{
|
||||
$this->post_page("register.php", ["data" => "test entry"]);
|
||||
|
||||
$this->log_in_as_user();
|
||||
$this->get_page("register.php");
|
||||
$this->assert_no_text("test entry");
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("register.php");
|
||||
$this->assert_text("test entry");
|
||||
}
|
||||
}
|
23
ext/image_view_counter/test.php
Normal file
23
ext/image_view_counter/test.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
class ImageViewCounterTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testPostView()
|
||||
{
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("post/view/$image_id");
|
||||
$this->assert_text("Views");
|
||||
}
|
||||
|
||||
public function testPopular()
|
||||
{
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->get_page("popular_images");
|
||||
$this->assert_text("$image_id");
|
||||
}
|
||||
}
|
|
@ -6,7 +6,10 @@ namespace Shimmie2;
|
|||
|
||||
class ImageViewCounterTheme extends Themelet
|
||||
{
|
||||
public function view_popular($images)
|
||||
/**
|
||||
* @param Image[] $images
|
||||
*/
|
||||
public function view_popular(array $images)
|
||||
{
|
||||
global $page, $config;
|
||||
$pop_images = "";
|
||||
|
|
Reference in a new issue