From aa7969cdde5e3108ad58506a54390d887bdc544f Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 20 Jul 2009 06:51:36 +0100 Subject: [PATCH] MOAR TESTING. --- contrib/ban_words/test.php | 11 +++++++++++ contrib/bulk_add/test.php | 2 ++ contrib/downtime/test.php | 22 ++++++++++++++++++++++ contrib/emoticons/test.php | 19 +++++++++++++++++++ contrib/et/test.php | 10 ++++++++++ contrib/featured/test.php | 2 ++ contrib/handle_ico/test.php | 3 +++ contrib/handle_svg/test.php | 3 +++ contrib/home/test.php | 2 ++ contrib/image_hash_ban/test.php | 23 ----------------------- contrib/ipban/test.php | 2 ++ contrib/link_image/test.php | 22 ++++++++++++++++++++++ contrib/numeric_score/test.php | 21 +++++++++++++++++++++ contrib/random_image/test.php | 19 +++++++++++++++++++ contrib/regen_thumb/test.php | 15 +++++++++++++++ contrib/report_image/test.php | 3 +++ contrib/rss_comments/test.php | 2 ++ contrib/simpletest/main.php | 6 ++++-- contrib/site_description/test.php | 2 +- contrib/wiki/test.php | 2 ++ contrib/zoom/test.php | 11 +++++++++++ contrib/zoom/theme.php | 1 + ext/admin/test.php | 2 ++ ext/bbcode/test.php | 1 + ext/comment/test.php | 2 ++ ext/ext_manager/test.php | 2 ++ ext/handle_pixel/test.php | 3 +++ ext/index/test.php | 2 ++ ext/index/theme.php | 4 ++-- ext/tag_edit/test.php | 5 +++++ ext/tag_list/test.php | 2 ++ ext/user/test.php | 6 +++++- 32 files changed, 203 insertions(+), 29 deletions(-) create mode 100644 contrib/downtime/test.php create mode 100644 contrib/emoticons/test.php create mode 100644 contrib/et/test.php delete mode 100644 contrib/image_hash_ban/test.php create mode 100644 contrib/link_image/test.php create mode 100644 contrib/numeric_score/test.php create mode 100644 contrib/random_image/test.php create mode 100644 contrib/regen_thumb/test.php create mode 100644 contrib/zoom/test.php diff --git a/contrib/ban_words/test.php b/contrib/ban_words/test.php index a457c157..f14b4c01 100644 --- a/contrib/ban_words/test.php +++ b/contrib/ban_words/test.php @@ -15,6 +15,16 @@ class BanWordsTest extends ShimmieWebTestCase { $this->click("Post Comment"); $this->assertTitle("Comment Blocked"); + $this->get_page("post/view/$image_id"); + $this->setField('comment', "kittens and ViagrA"); + $this->click("Post Comment"); + $this->assertTitle("Comment Blocked"); + + $this->get_page("post/view/$image_id"); + $this->setField('comment', "kittens and viagra!"); + $this->click("Post Comment"); + $this->assertTitle("Comment Blocked"); + $this->get_page("post/view/$image_id"); $this->setField('comment', "some link to http://something.cn/"); $this->click("Post Comment"); @@ -23,6 +33,7 @@ class BanWordsTest extends ShimmieWebTestCase { $this->get_page('comment/list'); $this->assertTitle('Comments'); $this->assertNoText('viagra'); + $this->assertNoText('ViagrA'); $this->assertNoText('http://something.cn/'); $this->log_out(); diff --git a/contrib/bulk_add/test.php b/contrib/bulk_add/test.php index e8526f7c..3a9389dd 100644 --- a/contrib/bulk_add/test.php +++ b/contrib/bulk_add/test.php @@ -8,6 +8,8 @@ class BulkAddTest extends ShimmieWebTestCase { $this->setField('dir', "contrib/simpletest"); $this->click("Add"); + # FIXME: test that the output here makes sense, no "adding foo.php ... ok" + $this->get_page("post/list/hash=17fc89f372ed3636e28bd25cc7f3bac1/1"); $this->assertTitle(new PatternExpectation("/^Image \d+: data/")); $this->click("Delete"); diff --git a/contrib/downtime/test.php b/contrib/downtime/test.php new file mode 100644 index 00000000..b341a983 --- /dev/null +++ b/contrib/downtime/test.php @@ -0,0 +1,22 @@ +log_in_as_admin(); + $this->get_page("setup"); + $this->setField("_config_downtime", true); + $this->setField("_config_downtime_message", "brb, unit testing"); + $this->click("Save Settings"); + $this->assertText("DOWNTIME MODE IS ON!"); + $this->log_out(); + + $this->assertText("brb, unit testing"); + + $this->log_in_as_admin(); + $this->get_page("setup"); + $this->setField("_config_downtime", false); + $this->click("Save Settings"); + $this->assertNoText("DOWNTIME MODE IS ON!"); + $this->log_out(); + } +} +?> diff --git a/contrib/emoticons/test.php b/contrib/emoticons/test.php new file mode 100644 index 00000000..25ef3e43 --- /dev/null +++ b/contrib/emoticons/test.php @@ -0,0 +1,19 @@ +log_in_as_user(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot"); + $this->get_page("post/view/$image_id"); + + $this->setField('comment', ":cool: :beans:"); + $this->click("Post Comment"); + $this->assertNoText(":cool:"); # FIXME: test for working image link + #$this->assertText(":beans:"); # FIXME: this should be left as-is + + $this->log_out(); + $this->log_in_as_admin(); + $this->delete_image($image_id); + $this->log_out(); + } +} +?> diff --git a/contrib/et/test.php b/contrib/et/test.php new file mode 100644 index 00000000..6303e694 --- /dev/null +++ b/contrib/et/test.php @@ -0,0 +1,10 @@ +log_in_as_admin(); + $this->get_page("system_info"); + $this->assertTitle("System Info"); + $this->log_out(); + } +} +?> diff --git a/contrib/featured/test.php b/contrib/featured/test.php index 8f700695..02c8bd25 100644 --- a/contrib/featured/test.php +++ b/contrib/featured/test.php @@ -18,6 +18,8 @@ class FeaturedTest extends ShimmieWebTestCase { # after deletion, there should be no feature $this->get_page("post/list"); $this->assertNoText("Featured Image"); + + # FIXME: test changing from one feature to another } } ?> diff --git a/contrib/handle_ico/test.php b/contrib/handle_ico/test.php index b1fe8b83..f2900119 100644 --- a/contrib/handle_ico/test.php +++ b/contrib/handle_ico/test.php @@ -9,6 +9,9 @@ class IcoHandlerTest extends ShimmieWebTestCase { $this->log_in_as_admin(); $this->delete_image($image_id); $this->log_out(); + + # FIXME: test that the thumb works + # FIXME: test that it gets displayed properly } } ?> diff --git a/contrib/handle_svg/test.php b/contrib/handle_svg/test.php index fe0751ad..5349c0cc 100644 --- a/contrib/handle_svg/test.php +++ b/contrib/handle_svg/test.php @@ -26,6 +26,9 @@ class SVGHandlerTest extends ShimmieWebTestCase { $this->log_out(); unlink("test.svg"); + + # FIXME: test that the thumb works + # FIXME: test that it gets displayed properly } } ?> diff --git a/contrib/home/test.php b/contrib/home/test.php index e62d34d7..2fa1bf72 100644 --- a/contrib/home/test.php +++ b/contrib/home/test.php @@ -4,6 +4,8 @@ class HomeTest extends ShimmieWebTestCase { $this->get_page('home'); $this->assertTitle('Shimmie'); $this->assertText('Shimmie'); + + # FIXME: test search box } } ?> diff --git a/contrib/image_hash_ban/test.php b/contrib/image_hash_ban/test.php deleted file mode 100644 index 58e781ab..00000000 --- a/contrib/image_hash_ban/test.php +++ /dev/null @@ -1,23 +0,0 @@ -receive_event($due); - $this->assertTrue(false); // shouldn't work - } - catch(DataUploadException $ex) { - $this->assertTrue(true); // should fail - } - catch(Exception $ex) { - $this->assertTrue(false); // but not with any other error - } - } -} -?> diff --git a/contrib/ipban/test.php b/contrib/ipban/test.php index abbe46c3..d821a3bc 100644 --- a/contrib/ipban/test.php +++ b/contrib/ipban/test.php @@ -19,6 +19,8 @@ class IPBanTest extends ShimmieWebTestCase { $this->assertNoText("42.42.42.42"); $this->log_out(); + + # FIXME: test that the IP is actually banned } } ?> diff --git a/contrib/link_image/test.php b/contrib/link_image/test.php new file mode 100644 index 00000000..01a31afb --- /dev/null +++ b/contrib/link_image/test.php @@ -0,0 +1,22 @@ +log_in_as_user(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pie"); + + # look in the "plain text link to post" box, follow the link + # in there, see if it takes us to the right page + $raw = $this->get_page("post/view/$image_id"); + $matches = preg_match("/name='text_post-link'\s+value='([^']+)'/", $raw); + $this->assertTrue(count($matches) > 0); + $this->get($matches[1]); + $this->assertTitle("Image $image_id: pie"); + + $this->log_out(); + + $this->log_in_as_admin(); + $this->delete_image($image_id); + $this->log_out(); + } +} +?> diff --git a/contrib/numeric_score/test.php b/contrib/numeric_score/test.php new file mode 100644 index 00000000..4c335d83 --- /dev/null +++ b/contrib/numeric_score/test.php @@ -0,0 +1,21 @@ +log_in_as_user(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot"); + $this->get_page("post/view/$image_id"); + $this->assertText("Current Score: 0"); + $this->click("Vote Down"); + $this->assertText("Current Score: -1"); + $this->click("Vote Up"); + $this->assertText("Current Score: 1"); + # FIXME: "remove vote" button? + # FIXME: test that up and down are hidden if already voted up or down + $this->log_out(); + + $this->log_in_as_admin(); + $this->delete_image($image_id); + $this->log_out(); + } +} +?> diff --git a/contrib/random_image/test.php b/contrib/random_image/test.php new file mode 100644 index 00000000..39b65eea --- /dev/null +++ b/contrib/random_image/test.php @@ -0,0 +1,19 @@ +log_in_as_user(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test"); + $this->log_out(); + + $this->get_page("random_image/view"); + $this->assertTitle("Image $image_id: test"); + + $this->log_in_as_admin(); + $this->delete_image($image_id); + $this->log_out(); + + # FIXME: test random_image/download + # FIXME: test random_image/ratio=4:3/download + } +} +?> diff --git a/contrib/regen_thumb/test.php b/contrib/regen_thumb/test.php new file mode 100644 index 00000000..ab4622ad --- /dev/null +++ b/contrib/regen_thumb/test.php @@ -0,0 +1,15 @@ +log_in_as_admin(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot"); + $this->get_page("post/view/$image_id"); + $this->click("Regenerate"); + $this->assertTitle("Thumbnail Regenerated"); + $this->delete_image($image_id); + $this->log_out(); + + # FIXME: test that the thumb's modified time has been updated + } +} +?> diff --git a/contrib/report_image/test.php b/contrib/report_image/test.php index b347dde0..89f102d0 100644 --- a/contrib/report_image/test.php +++ b/contrib/report_image/test.php @@ -18,6 +18,9 @@ class ReportImageTest extends ShimmieWebTestCase { $this->delete_image($image_id); $this->log_out(); + + # FIXME: test delete image from report screen + # FIXME: test that >>123 works } } ?> diff --git a/contrib/rss_comments/test.php b/contrib/rss_comments/test.php index 4b3364ed..1ea92912 100644 --- a/contrib/rss_comments/test.php +++ b/contrib/rss_comments/test.php @@ -4,6 +4,8 @@ class RSSCommentsTest extends ShimmieWebTestCase { $this->get_page('rss/comments'); $this->assertMime("application/rss+xml"); $this->assertNoText("Exception"); + + # FIXME: test that there are some comments here } } ?> diff --git a/contrib/simpletest/main.php b/contrib/simpletest/main.php index 4747045d..9d210c0a 100644 --- a/contrib/simpletest/main.php +++ b/contrib/simpletest/main.php @@ -27,7 +27,7 @@ class SCoreWebTestCase extends WebTestCase { } protected function log_in_as_user() { - $this->get_page('post/list'); + $this->get_page('user_admin/login'); $this->assertText("Login"); $this->setField('user', USER_NAME); $this->setField('pass', USER_PASS); @@ -35,7 +35,7 @@ class SCoreWebTestCase extends WebTestCase { } protected function log_in_as_admin() { - $this->get_page('post/list'); + $this->get_page('user_admin/login'); $this->assertText("Login"); $this->setField('user', ADMIN_NAME); $this->setField('pass', ADMIN_PASS); @@ -96,6 +96,8 @@ class SimpleSCoreTest extends SimpleExtension { public function onPageRequest($event) { global $page; if($event->page_matches("test")) { + set_time_limit(0); + $page->set_title("Test Results"); $page->set_heading("Test Results"); $page->add_block(new NavBlock()); diff --git a/contrib/site_description/test.php b/contrib/site_description/test.php index ee20d2ec..033d507e 100644 --- a/contrib/site_description/test.php +++ b/contrib/site_description/test.php @@ -5,7 +5,7 @@ class SiteDescriptionTest extends ShimmieWebTestCase { $this->get_page('setup'); $this->assertTitle("Shimmie Setup"); $this->setField("_config_site_description", "A Shimmie testbed"); - $this->click("Save Settings") + $this->click("Save Settings"); $raw_headers = $this->getBrowser()->getHeaders(); $header = ''; diff --git a/contrib/wiki/test.php b/contrib/wiki/test.php index 26bac072..c411679d 100644 --- a/contrib/wiki/test.php +++ b/contrib/wiki/test.php @@ -5,6 +5,8 @@ class WikiTest extends ShimmieWebTestCase { $this->get_page("wiki"); $this->assertTitle("Index"); $this->log_out(); + + # FIXME: needs a ton of tests... } } ?> diff --git a/contrib/zoom/test.php b/contrib/zoom/test.php new file mode 100644 index 00000000..b27b3c1f --- /dev/null +++ b/contrib/zoom/test.php @@ -0,0 +1,11 @@ +log_in_as_admin(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot"); + $this->get("post/view/$image_id"); # just check that the page isn't borked + $this->delete_image($image_id); + $this->log_out(); + } +} +?> diff --git a/contrib/zoom/theme.php b/contrib/zoom/theme.php index 9cc59583..24b10735 100644 --- a/contrib/zoom/theme.php +++ b/contrib/zoom/theme.php @@ -9,6 +9,7 @@ class ZoomTheme extends Themelet { global $config; $default = $zoom_by_default ? "scale(img);" : ""; return << + //-->

diff --git a/ext/tag_edit/test.php b/ext/tag_edit/test.php index 48b5b1a5..0962cfb2 100644 --- a/ext/tag_edit/test.php +++ b/ext/tag_edit/test.php @@ -8,11 +8,16 @@ class TagEditTest extends ShimmieWebTestCase { $this->setField("tag_edit__tags", "new"); $this->click("Set"); $this->assertTitle("Image $image_id: new"); + $this->setField("tag_edit__tags", ""); + $this->click("Set"); + $this->assertTitle("Image $image_id: tagme"); $this->log_out(); $this->log_in_as_admin(); $this->delete_image($image_id); $this->log_out(); + + # FIXME: test mass tag editor } } ?> diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php index 6e69f6f4..25c822cc 100644 --- a/ext/tag_list/test.php +++ b/ext/tag_list/test.php @@ -12,6 +12,8 @@ class TagListTest extends ShimmieWebTestCase { $this->get_page('tags/categories'); $this->assertTitle('Tag List'); + + # FIXME: test that these show the right stuff } } ?> diff --git a/ext/user/test.php b/ext/user/test.php index bc6be2b2..384947af 100644 --- a/ext/user/test.php +++ b/ext/user/test.php @@ -2,7 +2,7 @@ class UserPageTest extends ShimmieWebTestCase { function testUserPage() { $this->get_page('user'); - $this->assertTitle("Anonymous's Page"); + $this->assertTitle("Not Logged In"); $this->assertNoText("Options"); $this->assertNoText("More Options"); @@ -25,6 +25,10 @@ class UserPageTest extends ShimmieWebTestCase { $this->assertText("Options"); $this->assertText("More Options"); $this->log_out(); + + # FIXME: test user creation + # FIXME: test adminifying + # FIXME: test password reset } } ?>