From bb4085972bbdf713736ab6c6d03a884992fd888c Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 20:13:37 +0100 Subject: [PATCH 01/13] code coverage stuff --- core/util.inc.php | 21 +++++++++++++++++++++ index.php | 2 ++ 2 files changed, 23 insertions(+) diff --git a/core/util.inc.php b/core/util.inc.php index 9005f71c..c74231f5 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -803,4 +803,25 @@ function _end_cache() { } } } + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ +* Code coverage * +\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +function _start_debug() { + if(function_exists("xdebug_start_code_coverage")) { + #xdebug_start_code_coverage(XDEBUG_CC_UNUSED|XDEBUG_CC_DEAD_CODE); + xdebug_start_code_coverage(XDEBUG_CC_UNUSED); + } +} + +function _end_debug() { + if(function_exists("xdebug_get_code_coverage")) { + if(!file_exists("data/coverage")) mkdir("data/coverage"); + $n = 0; + $t = time(); + while(file_exists("data/coverage/$t.$n.log")) $n++; + file_put_contents("data/coverage/$t.$n.log", serialize(xdebug_get_code_coverage())); + } +} ?> diff --git a/index.php b/index.php index 4ab4bb1a..325abe87 100644 --- a/index.php +++ b/index.php @@ -64,6 +64,7 @@ if(!file_exists("config.php")) { require_once "config.php"; require_once "core/util.inc.php"; +if(DEBUG) {_start_debug();} _version_check(); _sanitise_environment(); _start_cache(); @@ -147,4 +148,5 @@ catch(Exception $e) { EOD; } +if(DEBUG) {_end_debug();} ?> From 6726f1360319085d60949d907809e194bba4985b Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 20:18:46 +0100 Subject: [PATCH 02/13] test the emoticon list --- contrib/emoticons/test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/emoticons/test.php b/contrib/emoticons/test.php index 6e6bc236..3758ce3b 100644 --- a/contrib/emoticons/test.php +++ b/contrib/emoticons/test.php @@ -10,6 +10,9 @@ class EmoticonTest extends ShimmieWebTestCase { $this->assert_no_text(":cool:"); # FIXME: test for working image link #$this->assert_text(":beans:"); # FIXME: this should be left as-is + $this->get_page("emote/list"); + $this->assert_text(":arrow:"); + $this->log_out(); $this->log_in_as_admin(); $this->delete_image($image_id); From d7038a0098f766f50dcfc159a33e8124ad58b6ad Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 20:19:09 +0100 Subject: [PATCH 03/13] test the next and prev buttons --- ext/view/test.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ext/view/test.php b/ext/view/test.php index d1beb96a..42a2719b 100644 --- a/ext/view/test.php +++ b/ext/view/test.php @@ -2,12 +2,22 @@ class ViewTest extends ShimmieWebTestCase { function testViewPage() { $this->log_in_as_user(); - $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test"); - $idp1 = $image_id + 1; + $image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test"); + $image_id_2 = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "test2"); + $idp1 = $image_id_2 + 1; $this->log_out(); - $this->get_page("post/view/$image_id"); - $this->assert_title("Image $image_id: test"); + $this->get_page("post/view/$image_id_1"); + $this->assert_title("Image $image_id_1: test"); + + $this->click("Prev"); + $this->assert_title("Image $image_id_2: test2"); + + $this->click("Next"); + $this->assert_title("Image $image_id_1: test"); + + $this->click("Next"); + $this->assert_title("Image not found"); $this->get_page("post/view/$idp1"); $this->assert_title('Image not found'); @@ -16,7 +26,8 @@ class ViewTest extends ShimmieWebTestCase { $this->assert_title('Image not found'); $this->log_in_as_admin(); - $this->delete_image($image_id); + $this->delete_image($image_id_1); + $this->delete_image($image_id_2); $this->log_out(); } } From 846801b76d9ecb4b13923290ad3961f56d15f9ae Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 20:23:48 +0100 Subject: [PATCH 04/13] test spoiler code --- ext/bbcode/test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index 99e1b40f..6951c5b6 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -38,6 +38,18 @@ class BBCodeUnitTest extends UnitTestCase { "
  • a
    • a
    • b
  • b
"); } + public function testSpoiler() { + $this->assertEqual( + $this->filter("[spoiler]ShishNet[/spoiler]"), + "ShishNet"); + $this->assertEqual( + $this->strip("[spoiler]ShishNet[/spoiler]"), + "FuvfuArg"); + #$this->assertEqual( + # $this->filter("[spoiler]ShishNet"), + # "[spoiler]ShishNet"); + } + public function testURL() { $this->assertEqual( $this->filter("[url]http://shishnet.org[/url]"), @@ -56,5 +68,12 @@ class BBCodeUnitTest extends UnitTestCase { $bb->receive_event($tfe); return $tfe->formatted; } + + private function strip($in) { + $bb = new BBCode(); + $tfe = new TextFormattingEvent($in); + $bb->receive_event($tfe); + return $tfe->stripped; + } } ?> From 281c34d64e1f9f3f665569c26123e8f317b1ba17 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 23:03:47 +0100 Subject: [PATCH 05/13] more testing --- contrib/bulk_add/test.php | 6 ++++++ contrib/downtime/test.php | 1 + ext/alias_editor/test.php | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/contrib/bulk_add/test.php b/contrib/bulk_add/test.php index 1eb6c744..8c1a5dcb 100644 --- a/contrib/bulk_add/test.php +++ b/contrib/bulk_add/test.php @@ -3,6 +3,12 @@ class BulkAddTest extends ShimmieWebTestCase { function testBulkAdd() { $this->log_in_as_admin(); + $this->get_page('admin'); + $this->assert_title("Admin Tools"); + $this->set_field('dir', "asdf"); + $this->click("Add"); + $this->assert_text("is not a directory"); + $this->get_page('admin'); $this->assert_title("Admin Tools"); $this->set_field('dir', "contrib/simpletest"); diff --git a/contrib/downtime/test.php b/contrib/downtime/test.php index 7d8d8b5d..868eeef6 100644 --- a/contrib/downtime/test.php +++ b/contrib/downtime/test.php @@ -9,6 +9,7 @@ class DowntimeTest extends SCoreWebTestCase { $this->assert_text("DOWNTIME MODE IS ON!"); $this->log_out(); + $this->get_page("post/list"); $this->assert_text("brb, unit testing"); $this->log_in_as_admin(); diff --git a/ext/alias_editor/test.php b/ext/alias_editor/test.php index 68b30450..5c36dad7 100644 --- a/ext/alias_editor/test.php +++ b/ext/alias_editor/test.php @@ -64,6 +64,11 @@ class AliasEditorTest extends ShimmieWebTestCase { $this->assert_no_text("test1"); $this->log_out(); + + + $this->get_page('alias/list'); + $this->assert_title("Alias List"); + $this->assert_no_text("Add"); } } ?> From 3a9b82ab1e9822364030615b9576786f17c9f3ad Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2009 23:07:39 +0100 Subject: [PATCH 06/13] this isn't slow any more --- ext/view/theme.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ext/view/theme.php b/ext/view/theme.php index 43c4a1b6..96ba5d31 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -22,13 +22,7 @@ class ViewImageTheme extends Themelet { } - var $pin = null; - protected function build_pin(Image $image) { - if(!is_null($this->pin)) { - return $this->pin; - } - global $database; if(isset($_GET['search'])) { @@ -44,8 +38,7 @@ class ViewImageTheme extends Themelet { $h_index = "Index"; $h_next = "Next"; - $this->pin = "$h_prev | $h_index | $h_next"; - return $this->pin; + return "$h_prev | $h_index | $h_next"; } protected function build_navigation(Image $image) { From 0f0bf5ff698f8bb69140ffc385d1fc1c5289a0b2 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:47:04 +0100 Subject: [PATCH 07/13] test blank lines --- contrib/ban_words/test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ban_words/test.php b/contrib/ban_words/test.php index d0052f3d..04a1cd32 100644 --- a/contrib/ban_words/test.php +++ b/contrib/ban_words/test.php @@ -21,7 +21,7 @@ class BanWordsTest extends ShimmieWebTestCase { $this->assert_title("Comment Blocked"); $this->get_page("post/view/$image_id"); - $this->set_field('comment', "kittens and viagra!"); + $this->set_field('comment', "kittens\n\n\n\nand viagra!"); $this->click("Post Comment"); $this->assert_title("Comment Blocked"); From c7a9c4b92c531e9aef111da825baa23fbf315e64 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:48:24 +0100 Subject: [PATCH 08/13] not finished, but add to test coverage --- ext/user/test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/user/test.php b/ext/user/test.php index b84d666d..8d468ad0 100644 --- a/ext/user/test.php +++ b/ext/user/test.php @@ -30,6 +30,9 @@ class UserPageTest extends SCoreWebTestCase { # FIXME: test user creation # FIXME: test adminifying # FIXME: test password reset + + $this->get_page('user/list'); + $this->assert_text("demo"); } } ?> From 3aa7424b129bf76353d23287a49b2831cedcda1a Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:48:52 +0100 Subject: [PATCH 09/13] nobody should be linking to pages like this any more... --- contrib/rss_images/main.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contrib/rss_images/main.php b/contrib/rss_images/main.php index 76527e7d..e73ba947 100644 --- a/contrib/rss_images/main.php +++ b/contrib/rss_images/main.php @@ -29,11 +29,6 @@ class RSS_Images extends SimpleExtension { if($event->count_args() == 1) { $page_number = int_escape($event->get_arg(0)); - // compat hack, deprecate this later - if($page_number == 0) { - $search_terms = explode(' ', $event->get_arg(0)); - $page_number = 1; - } } else if($event->count_args() == 2) { $search_terms = explode(' ', $event->get_arg(0)); From 7d88689c2bdacc356a7ef932679e1381d8024d54 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:50:32 +0100 Subject: [PATCH 10/13] another test --- contrib/site_description/test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/site_description/test.php b/contrib/site_description/test.php index 7ca0eb42..ee27e2fc 100644 --- a/contrib/site_description/test.php +++ b/contrib/site_description/test.php @@ -5,10 +5,12 @@ class SiteDescriptionTest extends SCoreWebTestCase { $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"); $header = ''; $this->assertTrue(strpos($raw, $header) > 0); + $this->assertTrue(strpos($raw, "foo") > 0); $this->log_out(); } From 619401dd4a04718b452df312da3eba91bc5ae323 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:53:24 +0100 Subject: [PATCH 11/13] test that this doesn't crash --- contrib/tag_history/test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/tag_history/test.php b/contrib/tag_history/test.php index c3cc4788..2c45d6e2 100644 --- a/contrib/tag_history/test.php +++ b/contrib/tag_history/test.php @@ -12,6 +12,10 @@ class TagHistoryTest extends ShimmieWebTestCase { $this->assert_text("new (Set by demo"); $this->click("Revert"); $this->assert_title("Image $image_id: pbx"); + + $this->get_page("tag_history"); + $this->click("Global Tag History"); + $this->delete_image($image_id); $this->log_out(); } From 39e1a56a94a9cc9fb687accb96c17ef5031a4428 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 03:58:50 +0100 Subject: [PATCH 12/13] test that comments work in the comment RSS --- contrib/rss_comments/test.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/rss_comments/test.php b/contrib/rss_comments/test.php index e55cf7be..554f9d09 100644 --- a/contrib/rss_comments/test.php +++ b/contrib/rss_comments/test.php @@ -1,11 +1,22 @@ log_in_as_user(); + $image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx"); + $this->get_page("post/view/$image_id"); + $this->set_field('comment', "Test Comment ASDFASDF"); + $this->click("Post Comment"); + $this->assert_text("ASDFASDF"); + $this->log_out(); + $this->get_page('rss/comments'); $this->assert_mime("application/rss+xml"); $this->assert_no_text("Exception"); + $this->assert_text("ASDFASDF"); - # FIXME: test that there are some comments here + $this->log_in_as_admin(); + $this->delete_image($image_id); + $this->log_out(); } } ?> From 9a3efd592a4917cac785b5253c59c99d2825433b Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 20 Sep 2009 04:10:34 +0100 Subject: [PATCH 13/13] more testes --- ext/tag_edit/test.php | 2 ++ ext/upload/test.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ext/tag_edit/test.php b/ext/tag_edit/test.php index ea281ee0..1bb5b4b2 100644 --- a/ext/tag_edit/test.php +++ b/ext/tag_edit/test.php @@ -14,6 +14,8 @@ class TagEditTest extends ShimmieWebTestCase { $this->log_out(); $this->log_in_as_admin(); + $this->get_page("admin"); + $this->assert_text("Mass Tag Edit"); // just test it exists $this->delete_image($image_id); $this->log_out(); diff --git a/ext/upload/test.php b/ext/upload/test.php index 83bbc2b4..7a9c1281 100644 --- a/ext/upload/test.php +++ b/ext/upload/test.php @@ -3,6 +3,9 @@ class UploadTest extends ShimmieWebTestCase { function testUpload() { $this->log_in_as_user(); + $this->get_page("upload"); + $this->assert_title("Upload"); + $image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot"); $this->assert_response(302);