tests
This commit is contained in:
parent
1d563cf87f
commit
c81911893f
3 changed files with 40 additions and 15 deletions
|
@ -102,7 +102,8 @@ class Database
|
|||
}
|
||||
}
|
||||
|
||||
private function get_engine(): DBEngine {
|
||||
private function get_engine(): DBEngine
|
||||
{
|
||||
if (is_null($this->engine)) {
|
||||
$this->connect_engine();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,41 @@ require_once "core/util.php";
|
|||
|
||||
class UtilTest extends TestCase
|
||||
{
|
||||
public function test_get_theme()
|
||||
{
|
||||
$this->assertEquals("default", get_theme());
|
||||
}
|
||||
|
||||
public function test_get_memory_limit()
|
||||
{
|
||||
get_memory_limit();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function test_check_gd_version()
|
||||
{
|
||||
check_gd_version();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function test_check_im_version()
|
||||
{
|
||||
check_im_version();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function test_human_filesize()
|
||||
{
|
||||
$this->assertEquals("123.00B", human_filesize(123));
|
||||
$this->assertEquals("123B", human_filesize(123, 0));
|
||||
$this->assertEquals("120.56KB", human_filesize(123456));
|
||||
}
|
||||
|
||||
public function test_generate_key()
|
||||
{
|
||||
$this->assertEquals(20, strlen(generate_key()));
|
||||
}
|
||||
|
||||
public function test_warehouse_path()
|
||||
{
|
||||
$hash = "7ac19c10d6859415";
|
||||
|
|
|
@ -207,8 +207,9 @@ function get_session_ip(Config $config): string
|
|||
*/
|
||||
function format_text(string $string): string
|
||||
{
|
||||
$tfe = send_event(new TextFormattingEvent($string));
|
||||
return $tfe->formatted;
|
||||
$event = new TextFormattingEvent($string);
|
||||
send_event($event);
|
||||
return $event->formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,18 +398,6 @@ function path_to_tags(string $path): string
|
|||
return implode(" ", $tags);
|
||||
}
|
||||
|
||||
|
||||
function join_url(string $base, string ...$paths): string
|
||||
{
|
||||
$output = $base;
|
||||
foreach ($paths as $path) {
|
||||
$output = rtrim($output, "/");
|
||||
$path = ltrim($path, "/");
|
||||
$output .= "/".$path;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function get_dir_contents(string $dir): array
|
||||
{
|
||||
assert(!empty($dir));
|
||||
|
|
Reference in a new issue