From 2600ef042bc673ab2002da21244d8625bcfa0ef5 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2015 20:44:34 +0100 Subject: [PATCH] setup tests --- ext/cron_uploader/main.php | 2 +- ext/setup/test.php | 28 ++++++++++++++++++---------- ext/site_description/test.php | 29 +++++++++++++++++------------ 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 39069963..9fe1c35d 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -195,7 +195,7 @@ class CronUploader extends Extension { // Sets new default dir if not in config yet/anymore if ($dir == "") { - $dir = $_SERVER ['DOCUMENT_ROOT'] . "/data/cron_uploader"; + $dir = data_path("cron_uploader"); $config->set_string ('cron_uploader_dir', $dir); } diff --git a/ext/setup/test.php b/ext/setup/test.php index 2507c504..5af8fca9 100644 --- a/ext/setup/test.php +++ b/ext/setup/test.php @@ -1,31 +1,39 @@ get_page('setup'); - $this->assert_response(403); - $this->assert_title("Permission Denied"); - +class SetupTest extends ShimmiePHPUnitTestCase { + function testNiceUrlsTest() { # XXX: this only checks that the text is "ok", to check # for a bug where it was coming out as "\nok"; it doesn't # check that niceurls actually work - $raw = $this->get_page('nicetest'); - $this->assertTrue($raw == "ok"); + $this->get_page('nicetest'); + $this->assert_content("ok"); + $this->assert_no_content("\n"); + } + function testAuthAnon() { + $this->get_page('setup'); + $this->assert_response(403); + $this->assert_title("Permission Denied"); + } + + function testAuthUser() { $this->log_in_as_user(); $this->get_page('setup'); $this->assert_response(403); $this->assert_title("Permission Denied"); - $this->log_out(); + } + function testAuthAdmin() { $this->log_in_as_admin(); $this->get_page('setup'); $this->assert_title("Shimmie Setup"); $this->assert_text("General"); + } + function testAdvanced() { + $this->log_in_as_admin(); $this->get_page('setup/advanced'); $this->assert_title("Shimmie Setup"); $this->assert_text("thumb_quality"); - $this->log_out(); } } diff --git a/ext/site_description/test.php b/ext/site_description/test.php index 0679fc53..4309a3ac 100644 --- a/ext/site_description/test.php +++ b/ext/site_description/test.php @@ -1,18 +1,23 @@ log_in_as_admin(); - $this->get_page('setup'); - $this->assert_title("Shimmie Setup"); - $this->set_field("_config_site_description", "A Shimmie testbed"); - $this->set_field("_config_site_keywords", "foo,bar,baz"); - $raw = $this->click("Save Settings"); + global $config, $page; + $config->set_string("site_description", "A Shimmie testbed"); + $this->get_page("post/list"); + $this->assertContains( + '', + $page->html_headers + ); + } - $header = ''; - $this->assertTrue(strpos($raw, $header) > 0); - $this->assertTrue(strpos($raw, "foo") > 0); - - $this->log_out(); + function testSiteKeywords() { + global $config, $page; + $config->set_string("site_keywords", "foo,bar,baz"); + $this->get_page("post/list"); + $this->assertContains( + '', + $page->html_headers + ); } }